blob: 179c623940f2bf4ff0bb091dd79399d9bc5dad76 [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
11#include <memory>
12#include <utility>
13
tzikf0e926f2018-10-15 13:52:10 +090014#include "absl/memory/memory.h"
Patrik Höglundd8f3c172018-09-26 14:39:17 +020015#include "api/test/test_dependency_factory.h"
16#include "rtc_base/thread_checker.h"
17
18namespace webrtc {
19
20// This checks everything in this file gets called on the same thread. It's
21// static because it needs to look at the static methods too.
22rtc::ThreadChecker* GetThreadChecker() {
23 static rtc::ThreadChecker checker;
24 return &checker;
25}
26
27std::unique_ptr<TestDependencyFactory> TestDependencyFactory::instance_ =
28 nullptr;
29
30const TestDependencyFactory& TestDependencyFactory::GetInstance() {
31 RTC_DCHECK(GetThreadChecker()->CalledOnValidThread());
32 if (instance_ == nullptr) {
33 instance_ = absl::make_unique<TestDependencyFactory>();
34 }
35 return *instance_;
36}
37
38void TestDependencyFactory::SetInstance(
39 std::unique_ptr<TestDependencyFactory> instance) {
40 RTC_DCHECK(GetThreadChecker()->CalledOnValidThread());
41 RTC_CHECK(instance_ == nullptr);
42 instance_ = std::move(instance);
43}
44
45std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
46TestDependencyFactory::CreateComponents() const {
47 RTC_DCHECK(GetThreadChecker()->CalledOnValidThread());
48 return nullptr;
49}
50
51} // namespace webrtc