blob: 4294b1b7a29f2d7588eeef3b4bac879d46dda5f8 [file] [log] [blame]
Patrik Höglundd8f3c172018-09-26 14:39:17 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Jonas Olssona4d87372019-07-05 19:08:33 +020011#include "api/test/test_dependency_factory.h"
12
Patrik Höglundd8f3c172018-09-26 14:39:17 +020013#include <memory>
14#include <utility>
15
tzikf0e926f2018-10-15 13:52:10 +090016#include "absl/memory/memory.h"
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "rtc_base/checks.h"
Patrik Höglundd8f3c172018-09-26 14:39:17 +020018#include "rtc_base/thread_checker.h"
19
20namespace webrtc {
21
22// This checks everything in this file gets called on the same thread. It's
23// static because it needs to look at the static methods too.
24rtc::ThreadChecker* GetThreadChecker() {
25 static rtc::ThreadChecker checker;
26 return &checker;
27}
28
29std::unique_ptr<TestDependencyFactory> TestDependencyFactory::instance_ =
30 nullptr;
31
32const TestDependencyFactory& TestDependencyFactory::GetInstance() {
Sebastian Janssonc01367d2019-04-08 15:20:44 +020033 RTC_DCHECK(GetThreadChecker()->IsCurrent());
Patrik Höglundd8f3c172018-09-26 14:39:17 +020034 if (instance_ == nullptr) {
35 instance_ = absl::make_unique<TestDependencyFactory>();
36 }
37 return *instance_;
38}
39
40void TestDependencyFactory::SetInstance(
41 std::unique_ptr<TestDependencyFactory> instance) {
Sebastian Janssonc01367d2019-04-08 15:20:44 +020042 RTC_DCHECK(GetThreadChecker()->IsCurrent());
Patrik Höglundd8f3c172018-09-26 14:39:17 +020043 RTC_CHECK(instance_ == nullptr);
44 instance_ = std::move(instance);
45}
46
47std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
48TestDependencyFactory::CreateComponents() const {
Sebastian Janssonc01367d2019-04-08 15:20:44 +020049 RTC_DCHECK(GetThreadChecker()->IsCurrent());
Patrik Höglundd8f3c172018-09-26 14:39:17 +020050 return nullptr;
51}
52
53} // namespace webrtc