diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc index dcc08d8dde..3a84e81a0b 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc @@ -18,8 +18,8 @@ #include #include +#include "webrtc/base/platform_thread.h" #include "webrtc/system_wrappers/include/critical_section_wrapper.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" namespace webrtc { namespace testing { @@ -57,27 +57,27 @@ Logging* Logging::GetInstance() { void Logging::SetGlobalContext(uint32_t name) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = ToString(name); + thread_map_[rtc::CurrentThreadId()].global_state.tag = ToString(name); } void Logging::SetGlobalContext(const std::string& name) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = name; + thread_map_[rtc::CurrentThreadId()].global_state.tag = name; } void Logging::SetGlobalContext(const char* name) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = name; + thread_map_[rtc::CurrentThreadId()].global_state.tag = name; } void Logging::SetGlobalEnable(bool enabled) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.enabled = enabled; + thread_map_[rtc::CurrentThreadId()].global_state.enabled = enabled; } void Logging::Log(const char format[], ...) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -96,7 +96,7 @@ void Logging::Plot(int figure, double value) { void Logging::Plot(int figure, double value, const std::string& alg_name) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); std::string label = state.tag + '@' + alg_name; @@ -119,7 +119,7 @@ void Logging::PlotBar(int figure, double value, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -132,7 +132,7 @@ void Logging::PlotBaselineBar(int figure, double value, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -148,7 +148,7 @@ void Logging::PlotErrorBar(int figure, const std::string& error_title, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -167,7 +167,7 @@ void Logging::PlotLimitErrorBar(int figure, const std::string& limit_title, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -182,7 +182,7 @@ void Logging::PlotLabel(int figure, const std::string& y_label, int num_flows) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -219,7 +219,7 @@ void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms, bool enabled) { CriticalSectionScoped cs(crit_sect_.get()); State new_state(append_to_tag, timestamp_ms, enabled); - ThreadState* thread_state = &thread_map_[ThreadWrapper::GetThreadId()]; + ThreadState* thread_state = &thread_map_[rtc::CurrentThreadId()]; std::stack* stack = &thread_state->stack; if (stack->empty()) { new_state.MergePrevious(thread_state->global_state); @@ -231,7 +231,7 @@ void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms, void Logging::PopState() { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); std::stack* stack = &it->second.stack; int64_t newest_timestamp_ms = stack->top().timestamp_ms; diff --git a/webrtc/system_wrappers/include/thread_wrapper.h b/webrtc/system_wrappers/include/thread_wrapper.h index d475302139..dbd548dfd9 100644 --- a/webrtc/system_wrappers/include/thread_wrapper.h +++ b/webrtc/system_wrappers/include/thread_wrapper.h @@ -67,12 +67,6 @@ class ThreadWrapper { static rtc::scoped_ptr CreateThread(ThreadRunFunction func, void* obj, const char* thread_name); - // Get the current thread's thread ID. - // NOTE: This is a static method. It returns the id of the calling thread, - // *not* the id of the worker thread that a ThreadWrapper instance represents. - // TODO(tommi): Move outside of the ThreadWrapper class to avoid confusion. - static uint32_t GetThreadId(); - // Tries to spawns a thread and returns true if that was successful. // Additionally, it tries to set thread priority according to the priority // from when CreateThread was called. However, failure to set priority will diff --git a/webrtc/system_wrappers/source/thread_posix.cc b/webrtc/system_wrappers/source/thread_posix.cc index 32ab13c780..952a3cd0f9 100644 --- a/webrtc/system_wrappers/source/thread_posix.cc +++ b/webrtc/system_wrappers/source/thread_posix.cc @@ -21,7 +21,6 @@ #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" @@ -77,10 +76,6 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj, RTC_DCHECK(name_.length() < 64); } -uint32_t ThreadWrapper::GetThreadId() { - return rtc::CurrentThreadId(); -} - ThreadPosix::~ThreadPosix() { RTC_DCHECK(thread_checker_.CalledOnValidThread()); } diff --git a/webrtc/system_wrappers/source/thread_win.cc b/webrtc/system_wrappers/source/thread_win.cc index c42196722e..b1c513c250 100644 --- a/webrtc/system_wrappers/source/thread_win.cc +++ b/webrtc/system_wrappers/source/thread_win.cc @@ -15,7 +15,6 @@ #include #include "webrtc/base/checks.h" -#include "webrtc/base/platform_thread.h" #include "webrtc/system_wrappers/include/trace.h" namespace webrtc { @@ -40,11 +39,6 @@ ThreadWindows::~ThreadWindows() { RTC_DCHECK(!thread_); } -// static -uint32_t ThreadWrapper::GetThreadId() { - return GetCurrentThreadId(); -} - // static DWORD WINAPI ThreadWindows::StartThread(void* param) { static_cast(param)->Run(); 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 #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); }