mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
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 <handellm@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39442}
This commit is contained in:
parent
0925fe36cf
commit
8cb31cf125
3 changed files with 12 additions and 8 deletions
|
@ -309,18 +309,20 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
|
||||||
// See ScopedDisallowBlockingCalls for details.
|
// See ScopedDisallowBlockingCalls for details.
|
||||||
// NOTE: Blocking calls are DISCOURAGED, consider if what you're doing can
|
// NOTE: Blocking calls are DISCOURAGED, consider if what you're doing can
|
||||||
// be achieved with PostTask() and callbacks instead.
|
// be achieved with PostTask() and callbacks instead.
|
||||||
// TODO(crbug.com/1416199): Remove virtual and pass location of the caller
|
void BlockingCall(
|
||||||
// once subclasses migrated.
|
FunctionView<void()> functor,
|
||||||
virtual void BlockingCall(FunctionView<void()> functor) {
|
const webrtc::Location& location = webrtc::Location::Current()) {
|
||||||
BlockingCallImpl(std::move(functor), webrtc::Location::Current());
|
BlockingCallImpl(std::move(functor), location);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor,
|
template <typename Functor,
|
||||||
typename ReturnT = std::invoke_result_t<Functor>,
|
typename ReturnT = std::invoke_result_t<Functor>,
|
||||||
typename = typename std::enable_if_t<!std::is_void_v<ReturnT>>>
|
typename = typename std::enable_if_t<!std::is_void_v<ReturnT>>>
|
||||||
ReturnT BlockingCall(Functor&& functor) {
|
ReturnT BlockingCall(
|
||||||
|
Functor&& functor,
|
||||||
|
const webrtc::Location& location = webrtc::Location::Current()) {
|
||||||
ReturnT result;
|
ReturnT result;
|
||||||
BlockingCall([&] { result = std::forward<Functor>(functor)(); });
|
BlockingCall([&] { result = std::forward<Functor>(functor)(); }, location);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ void SimulatedThread::RunReady(Timestamp at_time) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatedThread::BlockingCall(rtc::FunctionView<void()> functor) {
|
void SimulatedThread::BlockingCallImpl(rtc::FunctionView<void()> functor,
|
||||||
|
const Location& /*location*/) {
|
||||||
if (IsQuitting())
|
if (IsQuitting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ class SimulatedThread : public rtc::Thread,
|
||||||
TaskQueueBase* GetAsTaskQueue() override { return this; }
|
TaskQueueBase* GetAsTaskQueue() override { return this; }
|
||||||
|
|
||||||
// Thread interface
|
// Thread interface
|
||||||
void BlockingCall(rtc::FunctionView<void()> functor) override;
|
void BlockingCallImpl(rtc::FunctionView<void()> functor,
|
||||||
|
const Location& location) override;
|
||||||
void PostTaskImpl(absl::AnyInvocable<void() &&> task,
|
void PostTaskImpl(absl::AnyInvocable<void() &&> task,
|
||||||
const PostTaskTraits& traits,
|
const PostTaskTraits& traits,
|
||||||
const Location& location) override;
|
const Location& location) override;
|
||||||
|
|
Loading…
Reference in a new issue