diff options
Diffstat (limited to 'webrtc/system_wrappers/source')
24 files changed, 291 insertions, 629 deletions
diff --git a/webrtc/system_wrappers/source/Android.mk b/webrtc/system_wrappers/source/Android.mk index b58f902009..480af5177e 100644 --- a/webrtc/system_wrappers/source/Android.mk +++ b/webrtc/system_wrappers/source/Android.mk @@ -31,12 +31,10 @@ LOCAL_SRC_FILES := \ logging.cc \ metrics_default.cc \ rw_lock.cc \ - thread.cc \ trace_impl.cc \ condition_variable_posix.cc \ critical_section_posix.cc \ sleep.cc \ - thread_posix.cc \ trace_posix.cc \ rw_lock_posix.cc \ diff --git a/webrtc/system_wrappers/source/aligned_array_unittest.cc b/webrtc/system_wrappers/source/aligned_array_unittest.cc index 8d898af03e..01238f8342 100644 --- a/webrtc/system_wrappers/source/aligned_array_unittest.cc +++ b/webrtc/system_wrappers/source/aligned_array_unittest.cc @@ -16,7 +16,7 @@ namespace { -bool IsAligned(const void* ptr, int alignment) { +bool IsAligned(const void* ptr, size_t alignment) { return reinterpret_cast<uintptr_t>(ptr) % alignment == 0; } @@ -27,7 +27,7 @@ namespace webrtc { TEST(AlignedArrayTest, CheckAlignment) { AlignedArray<bool> arr(10, 7, 128); ASSERT_TRUE(IsAligned(arr.Array(), 128)); - for (int i = 0; i < 10; ++i) { + for (size_t i = 0; i < 10; ++i) { ASSERT_TRUE(IsAligned(arr.Row(i), 128)); ASSERT_EQ(arr.Row(i), arr.Array()[i]); } @@ -36,13 +36,13 @@ TEST(AlignedArrayTest, CheckAlignment) { TEST(AlignedArrayTest, CheckOverlap) { AlignedArray<size_t> arr(10, 7, 128); - for (int i = 0; i < 10; ++i) { + for (size_t i = 0; i < 10; ++i) { for (size_t j = 0; j < 7; ++j) { arr.At(i, j) = 20 * i + j; } } - for (int i = 0; i < 10; ++i) { + for (size_t i = 0; i < 10; ++i) { for (size_t j = 0; j < 7; ++j) { ASSERT_EQ(arr.At(i, j), 20 * i + j); ASSERT_EQ(arr.Row(i)[j], 20 * i + j); @@ -53,7 +53,7 @@ TEST(AlignedArrayTest, CheckOverlap) { TEST(AlignedArrayTest, CheckRowsCols) { AlignedArray<bool> arr(10, 7, 128); - ASSERT_EQ(arr.rows(), 10); + ASSERT_EQ(arr.rows(), 10u); ASSERT_EQ(arr.cols(), 7u); } diff --git a/webrtc/system_wrappers/source/condition_variable_unittest.cc b/webrtc/system_wrappers/source/condition_variable_unittest.cc index ed845cc21e..5a8dd0b36e 100644 --- a/webrtc/system_wrappers/source/condition_variable_unittest.cc +++ b/webrtc/system_wrappers/source/condition_variable_unittest.cc @@ -11,9 +11,9 @@ #include "webrtc/system_wrappers/include/condition_variable_wrapper.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/platform_thread.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/critical_section_wrapper.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" #include "webrtc/system_wrappers/include/tick_util.h" #include "webrtc/system_wrappers/include/trace.h" @@ -144,12 +144,10 @@ bool WaitingRunFunction(void* obj) { class CondVarTest : public ::testing::Test { public: - CondVarTest() {} + CondVarTest() : thread_(&WaitingRunFunction, &baton_, "CondVarTest") {} virtual void SetUp() { - thread_ = ThreadWrapper::CreateThread(&WaitingRunFunction, - &baton_, "CondVarTest"); - ASSERT_TRUE(thread_->Start()); + thread_.Start(); } virtual void TearDown() { @@ -160,14 +158,14 @@ class CondVarTest : public ::testing::Test { // and Pass). ASSERT_TRUE(baton_.Pass(kShortWaitMs)); ASSERT_TRUE(baton_.Grab(kShortWaitMs)); - ASSERT_TRUE(thread_->Stop()); + thread_.Stop(); } protected: Baton baton_; private: - rtc::scoped_ptr<ThreadWrapper> thread_; + rtc::PlatformThread thread_; }; // The SetUp and TearDown functions use condition variables. diff --git a/webrtc/system_wrappers/source/critical_section_unittest.cc b/webrtc/system_wrappers/source/critical_section_unittest.cc index 6848bdd06b..9abf8b8017 100644 --- a/webrtc/system_wrappers/source/critical_section_unittest.cc +++ b/webrtc/system_wrappers/source/critical_section_unittest.cc @@ -12,7 +12,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/system_wrappers/include/sleep.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" +#include "webrtc/base/platform_thread.h" #include "webrtc/system_wrappers/include/trace.h" namespace webrtc { @@ -78,10 +78,10 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS { CriticalSectionWrapper* crit_sect = CriticalSectionWrapper::CreateCriticalSection(); ProtectedCount count(crit_sect); - rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread( + rtc::PlatformThread thread( &LockUnlockThenStopRunFunction, &count, "ThreadWakesOnce"); crit_sect->Enter(); - ASSERT_TRUE(thread->Start()); + thread.Start(); SwitchProcess(); // The critical section is of reentrant mode, so this should not release // the lock, even though count.Count() locks and unlocks the critical section @@ -90,7 +90,7 @@ TEST_F(CritSectTest, ThreadWakesOnce) NO_THREAD_SAFETY_ANALYSIS { ASSERT_EQ(0, count.Count()); crit_sect->Leave(); // This frees the thread to act. EXPECT_TRUE(WaitForCount(1, &count)); - EXPECT_TRUE(thread->Stop()); + thread.Stop(); delete crit_sect; } @@ -105,10 +105,10 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS { CriticalSectionWrapper* crit_sect = CriticalSectionWrapper::CreateCriticalSection(); ProtectedCount count(crit_sect); - rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread( + rtc::PlatformThread thread( &LockUnlockRunFunction, &count, "ThreadWakesTwice"); crit_sect->Enter(); // Make sure counter stays 0 until we wait for it. - ASSERT_TRUE(thread->Start()); + thread.Start(); crit_sect->Leave(); // The thread is capable of grabbing the lock multiple times, @@ -128,7 +128,7 @@ TEST_F(CritSectTest, ThreadWakesTwice) NO_THREAD_SAFETY_ANALYSIS { SwitchProcess(); EXPECT_TRUE(WaitForCount(count_before + 1, &count)); - EXPECT_TRUE(thread->Stop()); + thread.Stop(); delete crit_sect; } diff --git a/webrtc/system_wrappers/source/data_log.cc b/webrtc/system_wrappers/source/data_log.cc index dbc8ea1505..778769603b 100644 --- a/webrtc/system_wrappers/source/data_log.cc +++ b/webrtc/system_wrappers/source/data_log.cc @@ -318,11 +318,12 @@ int DataLog::NextRow(const std::string& table_name) { } DataLogImpl::DataLogImpl() - : counter_(1), - tables_(), - flush_event_(EventWrapper::Create()), - tables_lock_(RWLockWrapper::CreateRWLock()) { -} + : counter_(1), + tables_(), + flush_event_(EventWrapper::Create()), + file_writer_thread_( + new rtc::PlatformThread(DataLogImpl::Run, instance_, "DataLog")), + tables_lock_(RWLockWrapper::CreateRWLock()) {} DataLogImpl::~DataLogImpl() { StopThread(); @@ -348,12 +349,8 @@ int DataLogImpl::CreateLog() { } int DataLogImpl::Init() { - file_writer_thread_ = ThreadWrapper::CreateThread( - DataLogImpl::Run, instance_, "DataLog"); - bool success = file_writer_thread_->Start(); - if (!success) - return -1; - file_writer_thread_->SetPriority(kHighestPriority); + file_writer_thread_->Start(); + file_writer_thread_->SetPriority(rtc::kHighestPriority); return 0; } @@ -406,13 +403,8 @@ int DataLogImpl::NextRow(const std::string& table_name) { if (tables_.count(table_name) == 0) return -1; tables_[table_name]->NextRow(); - if (!file_writer_thread_) { - // Write every row to file as they get complete. - tables_[table_name]->Flush(); - } else { - // Signal a complete row - flush_event_->Set(); - } + // Signal a complete row + flush_event_->Set(); return 0; } @@ -435,10 +427,8 @@ void DataLogImpl::Process() { } void DataLogImpl::StopThread() { - if (file_writer_thread_) { - flush_event_->Set(); - file_writer_thread_->Stop(); - } + flush_event_->Set(); + file_writer_thread_->Stop(); } } // namespace webrtc diff --git a/webrtc/system_wrappers/source/event_timer_posix.cc b/webrtc/system_wrappers/source/event_timer_posix.cc index 99eebcb70a..9f9a324bcb 100644 --- a/webrtc/system_wrappers/source/event_timer_posix.cc +++ b/webrtc/system_wrappers/source/event_timer_posix.cc @@ -154,14 +154,14 @@ bool EventTimerPosix::StartTimer(bool periodic, unsigned long time) { // Start the timer thread timer_event_.reset(new EventTimerPosix()); const char* thread_name = "WebRtc_event_timer_thread"; - timer_thread_ = ThreadWrapper::CreateThread(Run, this, thread_name); + timer_thread_.reset(new rtc::PlatformThread(Run, this, thread_name)); periodic_ = periodic; time_ = time; - bool started = timer_thread_->Start(); - timer_thread_->SetPriority(kRealtimePriority); + timer_thread_->Start(); + timer_thread_->SetPriority(rtc::kRealtimePriority); pthread_mutex_unlock(&mutex_); - return started; + return true; } bool EventTimerPosix::Run(void* obj) { @@ -215,9 +215,7 @@ bool EventTimerPosix::StopTimer() { timer_event_->Set(); } if (timer_thread_) { - if (!timer_thread_->Stop()) { - return false; - } + timer_thread_->Stop(); timer_thread_.reset(); } timer_event_.reset(); diff --git a/webrtc/system_wrappers/source/event_timer_posix.h b/webrtc/system_wrappers/source/event_timer_posix.h index 21c4ac702e..bbf51f72db 100644 --- a/webrtc/system_wrappers/source/event_timer_posix.h +++ b/webrtc/system_wrappers/source/event_timer_posix.h @@ -16,7 +16,7 @@ #include <pthread.h> #include <time.h> -#include "webrtc/system_wrappers/include/thread_wrapper.h" +#include "webrtc/base/platform_thread.h" namespace webrtc { @@ -46,7 +46,8 @@ class EventTimerPosix : public EventTimerWrapper { pthread_mutex_t mutex_; bool event_set_; - rtc::scoped_ptr<ThreadWrapper> timer_thread_; + // TODO(pbos): Remove scoped_ptr and use PlatformThread directly. + rtc::scoped_ptr<rtc::PlatformThread> timer_thread_; rtc::scoped_ptr<EventTimerPosix> timer_event_; timespec created_at_; diff --git a/webrtc/system_wrappers/source/event_tracer.cc b/webrtc/system_wrappers/source/event_tracer.cc deleted file mode 100644 index 9328e80036..0000000000 --- a/webrtc/system_wrappers/source/event_tracer.cc +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This file has moved. -// TODO(tommi): Delete after removing dependencies and updating Chromium. diff --git a/webrtc/system_wrappers/source/event_tracer_unittest.cc b/webrtc/system_wrappers/source/event_tracer_unittest.cc deleted file mode 100644 index 9328e80036..0000000000 --- a/webrtc/system_wrappers/source/event_tracer_unittest.cc +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This file has moved. -// TODO(tommi): Delete after removing dependencies and updating Chromium. diff --git a/webrtc/system_wrappers/source/field_trial_default.cc b/webrtc/system_wrappers/source/field_trial_default.cc index 1a9bd6bc79..0e2c286117 100644 --- a/webrtc/system_wrappers/source/field_trial_default.cc +++ b/webrtc/system_wrappers/source/field_trial_default.cc @@ -58,5 +58,9 @@ void InitFieldTrialsFromString(const char* trials_string) { trials_init_string = trials_string; } +const char* GetFieldTrialString() { + return trials_init_string; +} + } // namespace field_trial } // namespace webrtc diff --git a/webrtc/system_wrappers/source/logging_unittest.cc b/webrtc/system_wrappers/source/logging_unittest.cc index 633d84b76b..2da24b26f4 100644 --- a/webrtc/system_wrappers/source/logging_unittest.cc +++ b/webrtc/system_wrappers/source/logging_unittest.cc @@ -72,18 +72,5 @@ TEST_F(LoggingTest, LogStream) { } } -TEST_F(LoggingTest, LogFunctionError) { - { - CriticalSectionScoped cs(crit_.get()); - int bar = 42; - int baz = 99; - level_ = kTraceError; - expected_log_ << "(logging_unittest.cc:" << __LINE__ + 2 - << "): Foo failed: bar=" << bar << ", baz=" << baz; - LOG_FERR2(LS_ERROR, Foo, bar, baz); - cv_->SleepCS(*crit_.get(), 2000); - } -} - } // namespace } // namespace webrtc diff --git a/webrtc/system_wrappers/source/metrics_unittest.cc b/webrtc/system_wrappers/source/metrics_unittest.cc new file mode 100644 index 0000000000..8319b78ee0 --- /dev/null +++ b/webrtc/system_wrappers/source/metrics_unittest.cc @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "testing/gtest/include/gtest/gtest.h" + +#include "webrtc/system_wrappers/include/metrics.h" +#include "webrtc/test/histogram.h" + +namespace webrtc { +namespace { +const int kSample = 22; +const std::string kName = "Name"; + +void AddSparseSample(const std::string& name, int sample) { + RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample); +} +#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) +void AddSample(const std::string& name, int sample) { + RTC_HISTOGRAM_COUNTS_100(name, sample); +} +#endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) +} // namespace + +TEST(MetricsTest, InitiallyNoSamples) { + test::ClearHistograms(); + EXPECT_EQ(0, test::NumHistogramSamples(kName)); + EXPECT_EQ(-1, test::LastHistogramSample(kName)); +} + +TEST(MetricsTest, RtcHistogramPercent_AddSample) { + test::ClearHistograms(); + RTC_HISTOGRAM_PERCENTAGE(kName, kSample); + EXPECT_EQ(1, test::NumHistogramSamples(kName)); + EXPECT_EQ(kSample, test::LastHistogramSample(kName)); +} + +TEST(MetricsTest, RtcHistogramEnumeration_AddSample) { + test::ClearHistograms(); + RTC_HISTOGRAM_ENUMERATION(kName, kSample, kSample + 1); + EXPECT_EQ(1, test::NumHistogramSamples(kName)); + EXPECT_EQ(kSample, test::LastHistogramSample(kName)); +} + +TEST(MetricsTest, RtcHistogramCountsSparse_AddSample) { + test::ClearHistograms(); + RTC_HISTOGRAM_COUNTS_SPARSE_100(kName, kSample); + EXPECT_EQ(1, test::NumHistogramSamples(kName)); + EXPECT_EQ(kSample, test::LastHistogramSample(kName)); +} + +TEST(MetricsTest, RtcHistogramCounts_AddSample) { + test::ClearHistograms(); + RTC_HISTOGRAM_COUNTS_100(kName, kSample); + EXPECT_EQ(1, test::NumHistogramSamples(kName)); + EXPECT_EQ(kSample, test::LastHistogramSample(kName)); +} + +TEST(MetricsTest, RtcHistogramCounts_AddMultipleSamples) { + test::ClearHistograms(); + const int kNumSamples = 10; + for (int i = 0; i < kNumSamples; ++i) { + RTC_HISTOGRAM_COUNTS_100(kName, i); + } + EXPECT_EQ(kNumSamples, test::NumHistogramSamples(kName)); + EXPECT_EQ(kNumSamples - 1, test::LastHistogramSample(kName)); +} + +TEST(MetricsTest, RtcHistogramSparse_NonConstantNameWorks) { + test::ClearHistograms(); + AddSparseSample("Name1", kSample); + AddSparseSample("Name2", kSample); + EXPECT_EQ(1, test::NumHistogramSamples("Name1")); + EXPECT_EQ(1, test::NumHistogramSamples("Name2")); +} + +#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) +TEST(MetricsTest, RtcHistogram_FailsForNonConstantName) { + test::ClearHistograms(); + AddSample("Name1", kSample); + EXPECT_DEATH(AddSample("Name2", kSample), ""); +} +#endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) + +} // namespace webrtc diff --git a/webrtc/system_wrappers/source/ntp_time_unittest.cc b/webrtc/system_wrappers/source/ntp_time_unittest.cc new file mode 100644 index 0000000000..ff11288c1b --- /dev/null +++ b/webrtc/system_wrappers/source/ntp_time_unittest.cc @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "testing/gtest/include/gtest/gtest.h" + +#include "webrtc/system_wrappers/include/ntp_time.h" + +namespace webrtc { +namespace { + +const uint32_t kNtpSec = 0x12345678; +const uint32_t kNtpFrac = 0x23456789; + +TEST(NtpTimeTest, NoValueMeansInvalid) { + NtpTime ntp; + EXPECT_FALSE(ntp.Valid()); +} + +TEST(NtpTimeTest, CanResetValue) { + NtpTime ntp(kNtpSec, kNtpFrac); + EXPECT_TRUE(ntp.Valid()); + ntp.Reset(); + EXPECT_FALSE(ntp.Valid()); +} + +TEST(NtpTimeTest, CanGetWhatIsSet) { + NtpTime ntp; + ntp.Set(kNtpSec, kNtpFrac); + EXPECT_EQ(kNtpSec, ntp.seconds()); + EXPECT_EQ(kNtpFrac, ntp.fractions()); +} + +TEST(NtpTimeTest, SetIsSameAs2ParameterConstructor) { + NtpTime ntp1(kNtpSec, kNtpFrac); + NtpTime ntp2; + EXPECT_NE(ntp1, ntp2); + + ntp2.Set(kNtpSec, kNtpFrac); + EXPECT_EQ(ntp1, ntp2); +} + +TEST(NtpTimeTest, SetCurrentIsSameAs1ParameterConstructor) { + SimulatedClock clock(0x0123456789abcdef); + + NtpTime ntp1(clock); + NtpTime ntp2; + EXPECT_NE(ntp1, ntp2); + + ntp2.SetCurrent(clock); + EXPECT_EQ(ntp1, ntp2); +} + +TEST(NtpTimeTest, ToMsMeansToNtpMilliseconds) { + SimulatedClock clock(0x123456789abc); + + NtpTime ntp(clock); + EXPECT_EQ(ntp.ToMs(), Clock::NtpToMs(ntp.seconds(), ntp.fractions())); + EXPECT_EQ(ntp.ToMs(), clock.CurrentNtpInMilliseconds()); +} + +} // namespace +} // namespace webrtc diff --git a/webrtc/system_wrappers/source/scoped_vector_unittest.cc b/webrtc/system_wrappers/source/scoped_vector_unittest.cc index b049e4a340..6e38f01f0b 100644 --- a/webrtc/system_wrappers/source/scoped_vector_unittest.cc +++ b/webrtc/system_wrappers/source/scoped_vector_unittest.cc @@ -221,7 +221,8 @@ TEST(ScopedVectorTest, MoveConstruct) { EXPECT_FALSE(scoped_vector.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); - ScopedVector<LifeCycleObject> scoped_vector_copy(scoped_vector.Pass()); + ScopedVector<LifeCycleObject> scoped_vector_copy( + scoped_vector.DEPRECATED_Pass()); EXPECT_TRUE(scoped_vector.empty()); EXPECT_FALSE(scoped_vector_copy.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back())); @@ -241,7 +242,7 @@ TEST(ScopedVectorTest, MoveAssign) { EXPECT_FALSE(scoped_vector.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); - scoped_vector_assign = scoped_vector.Pass(); + scoped_vector_assign = scoped_vector.DEPRECATED_Pass(); EXPECT_TRUE(scoped_vector.empty()); EXPECT_FALSE(scoped_vector_assign.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector_assign.back())); @@ -273,10 +274,11 @@ class DeleteCounter { template <typename T> class PassThru { public: - explicit PassThru(ScopedVector<T> scoper) : scoper_(scoper.Pass()) {} + explicit PassThru(ScopedVector<T> scoper) + : scoper_(scoper.DEPRECATED_Pass()) {} ScopedVector<T> Run() { - return scoper_.Pass(); + return scoper_.DEPRECATED_Pass(); } private: @@ -288,7 +290,7 @@ TEST(ScopedVectorTest, Passed) { ScopedVector<DeleteCounter> deleter_vector; deleter_vector.push_back(new DeleteCounter(&deletes)); EXPECT_EQ(0, deletes); - PassThru<DeleteCounter> pass_thru(deleter_vector.Pass()); + PassThru<DeleteCounter> pass_thru(deleter_vector.DEPRECATED_Pass()); EXPECT_EQ(0, deletes); ScopedVector<DeleteCounter> result = pass_thru.Run(); EXPECT_EQ(0, deletes); diff --git a/webrtc/system_wrappers/source/thread.cc b/webrtc/system_wrappers/source/thread.cc deleted file mode 100644 index 7da1e3d591..0000000000 --- a/webrtc/system_wrappers/source/thread.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/system_wrappers/include/thread_wrapper.h" - -#if defined(_WIN32) -#include "webrtc/system_wrappers/source/thread_win.h" -#else -#include "webrtc/system_wrappers/source/thread_posix.h" -#endif - -namespace webrtc { - -#if defined(_WIN32) -typedef ThreadWindows ThreadType; -#else -typedef ThreadPosix ThreadType; -#endif - -rtc::scoped_ptr<ThreadWrapper> ThreadWrapper::CreateThread( - ThreadRunFunction func, void* obj, const char* thread_name) { - return rtc::scoped_ptr<ThreadWrapper>( - new ThreadType(func, obj, thread_name)).Pass(); -} - -} // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_posix.cc b/webrtc/system_wrappers/source/thread_posix.cc deleted file mode 100644 index 32ab13c780..0000000000 --- a/webrtc/system_wrappers/source/thread_posix.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/system_wrappers/source/thread_posix.h" - -#include <algorithm> - -#include <errno.h> -#include <unistd.h> -#ifdef WEBRTC_LINUX -#include <linux/unistd.h> -#include <sched.h> -#include <sys/types.h> -#endif - -#include "webrtc/base/checks.h" -#include "webrtc/base/platform_thread.h" -#include "webrtc/system_wrappers/include/critical_section_wrapper.h" -#include "webrtc/system_wrappers/include/event_wrapper.h" -#include "webrtc/system_wrappers/include/sleep.h" -#include "webrtc/system_wrappers/include/trace.h" - -namespace webrtc { -namespace { -struct ThreadAttributes { - ThreadAttributes() { pthread_attr_init(&attr); } - ~ThreadAttributes() { pthread_attr_destroy(&attr); } - pthread_attr_t* operator&() { return &attr; } - pthread_attr_t attr; -}; -} // namespace - -int ConvertToSystemPriority(ThreadPriority priority, int min_prio, - int max_prio) { - RTC_DCHECK(max_prio - min_prio > 2); - const int top_prio = max_prio - 1; - const int low_prio = min_prio + 1; - - switch (priority) { - case kLowPriority: - return low_prio; - case kNormalPriority: - // The -1 ensures that the kHighPriority is always greater or equal to - // kNormalPriority. - return (low_prio + top_prio - 1) / 2; - case kHighPriority: - return std::max(top_prio - 2, low_prio); - case kHighestPriority: - return std::max(top_prio - 1, low_prio); - case kRealtimePriority: - return top_prio; - } - RTC_DCHECK(false); - return low_prio; -} - -// static -void* ThreadPosix::StartThread(void* param) { - static_cast<ThreadPosix*>(param)->Run(); - return 0; -} - -ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj, - const char* thread_name) - : run_function_(func), - obj_(obj), - stop_event_(false, false), - name_(thread_name ? thread_name : "webrtc"), - thread_(0) { - RTC_DCHECK(name_.length() < 64); -} - -uint32_t ThreadWrapper::GetThreadId() { - return rtc::CurrentThreadId(); -} - -ThreadPosix::~ThreadPosix() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); -} - -// TODO(pbos): Make Start void, calling code really doesn't support failures -// here. -bool ThreadPosix::Start() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); - RTC_DCHECK(!thread_) << "Thread already started?"; - - ThreadAttributes attr; - // Set the stack stack size to 1M. - pthread_attr_setstacksize(&attr, 1024 * 1024); - RTC_CHECK_EQ(0, pthread_create(&thread_, &attr, &StartThread, this)); - return true; -} - -bool ThreadPosix::Stop() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); - if (!thread_) - return true; - - stop_event_.Set(); - RTC_CHECK_EQ(0, pthread_join(thread_, nullptr)); - thread_ = 0; - - return true; -} - -bool ThreadPosix::SetPriority(ThreadPriority priority) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); - if (!thread_) - return false; -#if defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX) - // TODO(tommi): Switch to the same mechanism as Chromium uses for - // changing thread priorities. - return true; -#else -#ifdef WEBRTC_THREAD_RR - const int policy = SCHED_RR; -#else - const int policy = SCHED_FIFO; -#endif - const int min_prio = sched_get_priority_min(policy); - const int max_prio = sched_get_priority_max(policy); - if (min_prio == -1 || max_prio == -1) { - WEBRTC_TRACE(kTraceError, kTraceUtility, -1, - "unable to retreive min or max priority for threads"); - return false; - } - - if (max_prio - min_prio <= 2) - return false; - - sched_param param; - param.sched_priority = ConvertToSystemPriority(priority, min_prio, max_prio); - if (pthread_setschedparam(thread_, policy, ¶m) != 0) { - WEBRTC_TRACE( - kTraceError, kTraceUtility, -1, "unable to set thread priority"); - return false; - } - - return true; -#endif // defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX) -} - -void ThreadPosix::Run() { - if (!name_.empty()) { - // Setting the thread name may fail (harmlessly) if running inside a - // sandbox. Ignore failures if they happen. - rtc::SetCurrentThreadName(name_.substr(0, 63).c_str()); - } - - // It's a requirement that for successful thread creation that the run - // function be called at least once (see RunFunctionIsCalled unit test), - // so to fullfill that requirement, we use a |do| loop and not |while|. - do { - if (!run_function_(obj_)) - break; - } while (!stop_event_.Wait(0)); -} - -} // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_posix.h b/webrtc/system_wrappers/source/thread_posix.h deleted file mode 100644 index bcdd732f86..0000000000 --- a/webrtc/system_wrappers/source/thread_posix.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ - -#include "webrtc/base/event.h" -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/base/thread_checker.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" - -#include <pthread.h> - -namespace webrtc { - -int ConvertToSystemPriority(ThreadPriority priority, int min_prio, - int max_prio); - -class ThreadPosix : public ThreadWrapper { - public: - ThreadPosix(ThreadRunFunction func, void* obj, const char* thread_name); - ~ThreadPosix() override; - - // From ThreadWrapper. - bool Start() override; - bool Stop() override; - - bool SetPriority(ThreadPriority priority) override; - - private: - static void* StartThread(void* param); - - void Run(); - - rtc::ThreadChecker thread_checker_; - ThreadRunFunction const run_function_; - void* const obj_; - rtc::Event stop_event_; - const std::string name_; - - pthread_t thread_; -}; - -} // namespace webrtc - -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ diff --git a/webrtc/system_wrappers/source/thread_posix_unittest.cc b/webrtc/system_wrappers/source/thread_posix_unittest.cc deleted file mode 100644 index edfb14502e..0000000000 --- a/webrtc/system_wrappers/source/thread_posix_unittest.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/system_wrappers/source/thread_posix.h" - -#include "testing/gtest/include/gtest/gtest.h" - -TEST(ThreadTestPosix, PrioritySettings) { - // API assumes that max_prio - min_prio > 2. Test the extreme case. - const int kMinPrio = -1; - const int kMaxPrio = 2; - - int last_priority = kMinPrio; - for (int priority = webrtc::kLowPriority; - priority <= webrtc::kRealtimePriority; ++priority) { - int system_priority = webrtc::ConvertToSystemPriority( - static_cast<webrtc::ThreadPriority>(priority), kMinPrio, kMaxPrio); - EXPECT_GT(system_priority, kMinPrio); - EXPECT_LT(system_priority, kMaxPrio); - EXPECT_GE(system_priority, last_priority); - last_priority = system_priority; - } -} diff --git a/webrtc/system_wrappers/source/thread_unittest.cc b/webrtc/system_wrappers/source/thread_unittest.cc deleted file mode 100644 index c8e180ba32..0000000000 --- a/webrtc/system_wrappers/source/thread_unittest.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/system_wrappers/include/thread_wrapper.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/system_wrappers/include/sleep.h" - -namespace webrtc { - -// Function that does nothing, and reports success. -bool NullRunFunction(void* obj) { - SleepMs(0); // Hand over timeslice, prevents busy looping. - return true; -} - -TEST(ThreadTest, StartStop) { - rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread( - &NullRunFunction, nullptr, "ThreadTest"); - ASSERT_TRUE(thread->Start()); - EXPECT_TRUE(thread->Stop()); -} - -// Function that sets a boolean. -bool SetFlagRunFunction(void* obj) { - bool* obj_as_bool = static_cast<bool*>(obj); - *obj_as_bool = true; - SleepMs(0); // Hand over timeslice, prevents busy looping. - return true; -} - -TEST(ThreadTest, RunFunctionIsCalled) { - bool flag = false; - rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread( - &SetFlagRunFunction, &flag, "RunFunctionIsCalled"); - ASSERT_TRUE(thread->Start()); - - // At this point, the flag may be either true or false. - EXPECT_TRUE(thread->Stop()); - - // We expect the thread to have run at least once. - EXPECT_TRUE(flag); -} - -} // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_win.cc b/webrtc/system_wrappers/source/thread_win.cc deleted file mode 100644 index c42196722e..0000000000 --- a/webrtc/system_wrappers/source/thread_win.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/system_wrappers/source/thread_win.h" - -#include <process.h> -#include <stdio.h> -#include <windows.h> - -#include "webrtc/base/checks.h" -#include "webrtc/base/platform_thread.h" -#include "webrtc/system_wrappers/include/trace.h" - -namespace webrtc { -namespace { -void CALLBACK RaiseFlag(ULONG_PTR param) { - *reinterpret_cast<bool*>(param) = true; -} -} - -ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj, - const char* thread_name) - : run_function_(func), - obj_(obj), - stop_(false), - thread_(NULL), - name_(thread_name ? thread_name : "webrtc") { - RTC_DCHECK(func); -} - -ThreadWindows::~ThreadWindows() { - RTC_DCHECK(main_thread_.CalledOnValidThread()); - RTC_DCHECK(!thread_); -} - -// static -uint32_t ThreadWrapper::GetThreadId() { - return GetCurrentThreadId(); -} - -// static -DWORD WINAPI ThreadWindows::StartThread(void* param) { - static_cast<ThreadWindows*>(param)->Run(); - return 0; -} - -bool ThreadWindows::Start() { - RTC_DCHECK(main_thread_.CalledOnValidThread()); - RTC_DCHECK(!thread_); - - stop_ = false; - - // See bug 2902 for background on STACK_SIZE_PARAM_IS_A_RESERVATION. - // Set the reserved stack stack size to 1M, which is the default on Windows - // and Linux. - DWORD thread_id; - thread_ = ::CreateThread(NULL, 1024 * 1024, &StartThread, this, - STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_id); - if (!thread_ ) { - RTC_DCHECK(false) << "CreateThread failed"; - return false; - } - - return true; -} - -bool ThreadWindows::Stop() { - RTC_DCHECK(main_thread_.CalledOnValidThread()); - if (thread_) { - // Set stop_ to |true| on the worker thread. - QueueUserAPC(&RaiseFlag, thread_, reinterpret_cast<ULONG_PTR>(&stop_)); - WaitForSingleObject(thread_, INFINITE); - CloseHandle(thread_); - thread_ = nullptr; - } - - return true; -} - -bool ThreadWindows::SetPriority(ThreadPriority priority) { - RTC_DCHECK(main_thread_.CalledOnValidThread()); - return thread_ && SetThreadPriority(thread_, priority); -} - -void ThreadWindows::Run() { - if (!name_.empty()) - rtc::SetCurrentThreadName(name_.c_str()); - - do { - // The interface contract of Start/Stop is that for a successfull call to - // Start, there should be at least one call to the run function. So we - // call the function before checking |stop_|. - if (!run_function_(obj_)) - break; - // Alertable sleep to permit RaiseFlag to run and update |stop_|. - SleepEx(0, true); - } while (!stop_); -} - -} // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_win.h b/webrtc/system_wrappers/source/thread_win.h deleted file mode 100644 index 34edd6d6c0..0000000000 --- a/webrtc/system_wrappers/source/thread_win.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ - -#include "webrtc/system_wrappers/include/thread_wrapper.h" - -#include <windows.h> - -#include "webrtc/base/thread_checker.h" - -namespace webrtc { - -class ThreadWindows : public ThreadWrapper { - public: - ThreadWindows(ThreadRunFunction func, void* obj, const char* thread_name); - ~ThreadWindows() override; - - bool Start() override; - bool Stop() override; - - bool SetPriority(ThreadPriority priority) override; - - protected: - void Run(); - - private: - static DWORD WINAPI StartThread(void* param); - - ThreadRunFunction const run_function_; - void* const obj_; - bool stop_; - HANDLE thread_; - const std::string name_; - rtc::ThreadChecker main_thread_; -}; - -} // namespace webrtc - -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_WIN_H_ diff --git a/webrtc/system_wrappers/source/tick_util.cc b/webrtc/system_wrappers/source/tick_util.cc index bc8fcfe91b..8d94289417 100644 --- a/webrtc/system_wrappers/source/tick_util.cc +++ b/webrtc/system_wrappers/source/tick_util.cc @@ -14,33 +14,79 @@ namespace webrtc { -bool TickTime::use_fake_clock_ = false; -int64_t TickTime::fake_ticks_ = 0; +int64_t TickTime::MillisecondTimestamp() { + return TicksToMilliseconds(TickTime::Now().Ticks()); +} -void TickTime::UseFakeClock(int64_t start_millisecond) { - use_fake_clock_ = true; - fake_ticks_ = MillisecondsToTicks(start_millisecond); +int64_t TickTime::MicrosecondTimestamp() { + return TicksToMicroseconds(TickTime::Now().Ticks()); } -void TickTime::AdvanceFakeClock(int64_t milliseconds) { - assert(use_fake_clock_); - fake_ticks_ += MillisecondsToTicks(milliseconds); +int64_t TickTime::MillisecondsToTicks(const int64_t ms) { +#if _WIN32 + return ms; +#elif defined(WEBRTC_LINUX) + return ms * 1000000LL; +#elif defined(WEBRTC_MAC) + // TODO(pbos): Fix unsafe use of static locals. + static double timebase_from_millisecond_fract = 0.0; + if (timebase_from_millisecond_fract == 0.0) { + mach_timebase_info_data_t timebase; + (void)mach_timebase_info(&timebase); + timebase_from_millisecond_fract = (timebase.denom * 1e6) / timebase.numer; + } + return ms * timebase_from_millisecond_fract; +#else + return ms * 1000LL; +#endif } -int64_t TickTime::QueryOsForTicks() { - TickTime result; +int64_t TickTime::TicksToMilliseconds(const int64_t ticks) { #if _WIN32 - // TODO(wu): Remove QueryPerformanceCounter implementation. -#ifdef USE_QUERY_PERFORMANCE_COUNTER - // QueryPerformanceCounter returns the value from the TSC which is - // incremented at the CPU frequency. The algorithm used requires - // the CPU frequency to be constant. Technology like speed stepping - // which has variable CPU frequency will therefore yield unpredictable, - // incorrect time estimations. - LARGE_INTEGER qpcnt; - QueryPerformanceCounter(&qpcnt); - result.ticks_ = qpcnt.QuadPart; + return ticks; +#elif defined(WEBRTC_LINUX) + return ticks / 1000000LL; +#elif defined(WEBRTC_MAC) + // TODO(pbos): Fix unsafe use of static locals. + static double timebase_microsecond_fract = 0.0; + if (timebase_microsecond_fract == 0.0) { + mach_timebase_info_data_t timebase; + (void)mach_timebase_info(&timebase); + timebase_microsecond_fract = timebase.numer / (timebase.denom * 1e6); + } + return ticks * timebase_microsecond_fract; #else + return ticks; +#endif +} + +int64_t TickTime::TicksToMicroseconds(const int64_t ticks) { +#if _WIN32 + return ticks * 1000LL; +#elif defined(WEBRTC_LINUX) + return ticks / 1000LL; +#elif defined(WEBRTC_MAC) + // TODO(pbos): Fix unsafe use of static locals. + static double timebase_microsecond_fract = 0.0; + if (timebase_microsecond_fract == 0.0) { + mach_timebase_info_data_t timebase; + (void)mach_timebase_info(&timebase); + timebase_microsecond_fract = timebase.numer / (timebase.denom * 1e3); + } + return ticks * timebase_microsecond_fract; +#else + return ticks; +#endif +} + +// Gets the native system tick count. The actual unit, resolution, and epoch +// varies by platform: +// Windows: Milliseconds of uptime with rollover count in the upper 32-bits. +// Linux/Android: Nanoseconds since the Unix epoch. +// Mach (Mac/iOS): "absolute" time since first call. +// Unknown POSIX: Microseconds since the Unix epoch. +int64_t TickTime::QueryOsForTicks() { +#if _WIN32 static volatile LONG last_time_get_time = 0; static volatile int64_t num_wrap_time_get_time = 0; volatile LONG* last_time_get_time_ptr = &last_time_get_time; @@ -53,11 +99,11 @@ int64_t TickTime::QueryOsForTicks() { // 0x0fffffff ~3.1 days, the code will not take that long to execute // so it must have been a wrap around. if (old > 0xf0000000 && now < 0x0fffffff) { + // TODO(pbos): Fix unsafe use of static locals. num_wrap_time_get_time++; } } - result.ticks_ = now + (num_wrap_time_get_time << 32); -#endif + return now + (num_wrap_time_get_time << 32); #elif defined(WEBRTC_LINUX) struct timespec ts; // TODO(wu): Remove CLOCK_REALTIME implementation. @@ -66,33 +112,24 @@ int64_t TickTime::QueryOsForTicks() { #else clock_gettime(CLOCK_MONOTONIC, &ts); #endif - result.ticks_ = 1000000000LL * static_cast<int64_t>(ts.tv_sec) + - static_cast<int64_t>(ts.tv_nsec); + return 1000000000LL * ts.tv_sec + ts.tv_nsec; #elif defined(WEBRTC_MAC) - static mach_timebase_info_data_t timebase; - if (timebase.denom == 0) { - // Get the timebase if this is the first time we run. - // Recommended by Apple's QA1398. - kern_return_t retval = mach_timebase_info(&timebase); - if (retval != KERN_SUCCESS) { - // TODO(wu): Implement RTC_CHECK for all the platforms. Then replace this - // with a RTC_CHECK_EQ(retval, KERN_SUCCESS); -#ifndef WEBRTC_IOS - asm("int3"); -#else - __builtin_trap(); -#endif // WEBRTC_IOS - } + // Return absolute time as an offset from the first call to this function, so + // that we can do floating-point (double) operations on it without losing + // precision. This holds true until the elapsed time is ~11 days, + // at which point we'll start to lose some precision, though not enough to + // matter for millisecond accuracy for another couple years after that. + // TODO(pbos): Fix unsafe use of static locals. + static uint64_t timebase_start = 0; + if (timebase_start == 0) { + timebase_start = mach_absolute_time(); } - // Use timebase to convert absolute time tick units into nanoseconds. - result.ticks_ = mach_absolute_time() * timebase.numer / timebase.denom; + return mach_absolute_time() - timebase_start; #else struct timeval tv; gettimeofday(&tv, NULL); - result.ticks_ = 1000000LL * static_cast<int64_t>(tv.tv_sec) + - static_cast<int64_t>(tv.tv_usec); + return 1000000LL * tv.tv_sec + tv.tv_usec; #endif - return result.ticks_; } } // namespace webrtc diff --git a/webrtc/system_wrappers/source/trace_impl.cc b/webrtc/system_wrappers/source/trace_impl.cc index ffe79b9862..5029f5ab6e 100644 --- a/webrtc/system_wrappers/source/trace_impl.cc +++ b/webrtc/system_wrappers/source/trace_impl.cc @@ -16,6 +16,7 @@ #include <string.h> #include "webrtc/base/atomicops.h" +#include "webrtc/base/platform_thread.h" #ifdef _WIN32 #include "webrtc/system_wrappers/source/trace_win.h" #else @@ -76,7 +77,7 @@ TraceImpl::~TraceImpl() { } int32_t TraceImpl::AddThreadId(char* trace_message) const { - uint32_t thread_id = ThreadWrapper::GetThreadId(); + uint32_t thread_id = rtc::CurrentThreadId(); // Messages is 12 characters. return sprintf(trace_message, "%10u; ", thread_id); } diff --git a/webrtc/system_wrappers/source/trace_impl.h b/webrtc/system_wrappers/source/trace_impl.h index ed49d9d0aa..c6d81d5b0b 100644 --- a/webrtc/system_wrappers/source/trace_impl.h +++ b/webrtc/system_wrappers/source/trace_impl.h @@ -16,7 +16,7 @@ #include "webrtc/system_wrappers/include/event_wrapper.h" #include "webrtc/system_wrappers/include/file_wrapper.h" #include "webrtc/system_wrappers/include/static_instance.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" +#include "webrtc/base/platform_thread.h" #include "webrtc/system_wrappers/include/trace.h" namespace webrtc { |