From 8cb31cf1255a722d9a6591ddd8ccd76aae9eec9c Mon Sep 17 00:00:00 2001 From: Markus Handell Date: Wed, 1 Mar 2023 14:55:50 +0100 Subject: [PATCH] Implement support for Chrome task origin tracing. #4/4 This CL forwards BlockingCall client locations to BlockingCallImpl. Fixed: chromium:1416199 Change-Id: Ic5865280ec5c72a09a64419940b8343e8a54986b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295624 Commit-Queue: Markus Handell Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#39442} --- rtc_base/thread.h | 14 ++++++++------ test/time_controller/simulated_thread.cc | 3 ++- test/time_controller/simulated_thread.h | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/rtc_base/thread.h b/rtc_base/thread.h index b3c824ccf8..1f48b6d923 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h @@ -309,18 +309,20 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { // See ScopedDisallowBlockingCalls for details. // NOTE: Blocking calls are DISCOURAGED, consider if what you're doing can // be achieved with PostTask() and callbacks instead. - // TODO(crbug.com/1416199): Remove virtual and pass location of the caller - // once subclasses migrated. - virtual void BlockingCall(FunctionView functor) { - BlockingCallImpl(std::move(functor), webrtc::Location::Current()); + void BlockingCall( + FunctionView functor, + const webrtc::Location& location = webrtc::Location::Current()) { + BlockingCallImpl(std::move(functor), location); } template , typename = typename std::enable_if_t>> - ReturnT BlockingCall(Functor&& functor) { + ReturnT BlockingCall( + Functor&& functor, + const webrtc::Location& location = webrtc::Location::Current()) { ReturnT result; - BlockingCall([&] { result = std::forward(functor)(); }); + BlockingCall([&] { result = std::forward(functor)(); }, location); return result; } diff --git a/test/time_controller/simulated_thread.cc b/test/time_controller/simulated_thread.cc index 0973a75ccf..e8a5a22a71 100644 --- a/test/time_controller/simulated_thread.cc +++ b/test/time_controller/simulated_thread.cc @@ -61,7 +61,8 @@ void SimulatedThread::RunReady(Timestamp at_time) { } } -void SimulatedThread::BlockingCall(rtc::FunctionView functor) { +void SimulatedThread::BlockingCallImpl(rtc::FunctionView functor, + const Location& /*location*/) { if (IsQuitting()) return; diff --git a/test/time_controller/simulated_thread.h b/test/time_controller/simulated_thread.h index 97b85604b6..8c6c728a48 100644 --- a/test/time_controller/simulated_thread.h +++ b/test/time_controller/simulated_thread.h @@ -36,7 +36,8 @@ class SimulatedThread : public rtc::Thread, TaskQueueBase* GetAsTaskQueue() override { return this; } // Thread interface - void BlockingCall(rtc::FunctionView functor) override; + void BlockingCallImpl(rtc::FunctionView functor, + const Location& location) override; void PostTaskImpl(absl::AnyInvocable task, const PostTaskTraits& traits, const Location& location) override;