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