Implement support for Chrome task origin tracing. #3.7/4
This CL completes migration to the new TaskQueueBase interface permitting location tracing in Chrome. Bug: chromium:1416199 Change-Id: Iff7ff5796752a1520384a3db0135a1d4b9438988 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294540 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39439}
This commit is contained in:
parent
bff2e27076
commit
ae61aca9b1
@ -63,10 +63,9 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueueBase {
|
|||||||
// Note that this guarantee does not apply to delayed tasks.
|
// Note that this guarantee does not apply to delayed tasks.
|
||||||
//
|
//
|
||||||
// May be called on any thread or task queue, including this task queue.
|
// May be called on any thread or task queue, including this task queue.
|
||||||
// TODO(crbug.com/1416199): Remove virtual and pass location of the caller
|
void PostTask(absl::AnyInvocable<void() &&> task,
|
||||||
// once subclasses migrated.
|
const Location& location = Location::Current()) {
|
||||||
virtual void PostTask(absl::AnyInvocable<void() &&> task) {
|
PostTaskImpl(std::move(task), PostTaskTraits{}, location);
|
||||||
PostTaskImpl(std::move(task), PostTaskTraits{}, Location::Current());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer PostDelayedTask() over PostDelayedHighPrecisionTask() whenever
|
// Prefer PostDelayedTask() over PostDelayedHighPrecisionTask() whenever
|
||||||
@ -92,13 +91,12 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueueBase {
|
|||||||
// https://crbug.com/webrtc/13583 for more information.
|
// https://crbug.com/webrtc/13583 for more information.
|
||||||
//
|
//
|
||||||
// May be called on any thread or task queue, including this task queue.
|
// May be called on any thread or task queue, including this task queue.
|
||||||
// TODO(crbug.com/1416199): Remove virtual and pass location of the caller
|
void PostDelayedTask(absl::AnyInvocable<void() &&> task,
|
||||||
// once subclasses migrated.
|
TimeDelta delay,
|
||||||
virtual void PostDelayedTask(absl::AnyInvocable<void() &&> task,
|
const Location& location = Location::Current()) {
|
||||||
TimeDelta delay) {
|
|
||||||
PostDelayedTaskImpl(std::move(task), delay,
|
PostDelayedTaskImpl(std::move(task), delay,
|
||||||
PostDelayedTaskTraits{.high_precision = false},
|
PostDelayedTaskTraits{.high_precision = false},
|
||||||
Location::Current());
|
location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer PostDelayedTask() over PostDelayedHighPrecisionTask() whenever
|
// Prefer PostDelayedTask() over PostDelayedHighPrecisionTask() whenever
|
||||||
@ -117,26 +115,28 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueueBase {
|
|||||||
// battery, when the timer precision can be as poor as 15 ms.
|
// battery, when the timer precision can be as poor as 15 ms.
|
||||||
//
|
//
|
||||||
// May be called on any thread or task queue, including this task queue.
|
// May be called on any thread or task queue, including this task queue.
|
||||||
// TODO(crbug.com/1416199): Remove virtual and pass location of the caller
|
void PostDelayedHighPrecisionTask(
|
||||||
// once subclasses migrated.
|
absl::AnyInvocable<void() &&> task,
|
||||||
virtual void PostDelayedHighPrecisionTask(absl::AnyInvocable<void() &&> task,
|
TimeDelta delay,
|
||||||
TimeDelta delay) {
|
const Location& location = Location::Current()) {
|
||||||
PostDelayedTaskImpl(std::move(task), delay,
|
PostDelayedTaskImpl(std::move(task), delay,
|
||||||
PostDelayedTaskTraits{.high_precision = true},
|
PostDelayedTaskTraits{.high_precision = true},
|
||||||
Location::Current());
|
location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// As specified by `precision`, calls either PostDelayedTask() or
|
// As specified by `precision`, calls either PostDelayedTask() or
|
||||||
// PostDelayedHighPrecisionTask().
|
// PostDelayedHighPrecisionTask().
|
||||||
void PostDelayedTaskWithPrecision(DelayPrecision precision,
|
void PostDelayedTaskWithPrecision(
|
||||||
absl::AnyInvocable<void() &&> task,
|
DelayPrecision precision,
|
||||||
TimeDelta delay) {
|
absl::AnyInvocable<void() &&> task,
|
||||||
|
TimeDelta delay,
|
||||||
|
const Location& location = Location::Current()) {
|
||||||
switch (precision) {
|
switch (precision) {
|
||||||
case DelayPrecision::kLow:
|
case DelayPrecision::kLow:
|
||||||
PostDelayedTask(std::move(task), delay);
|
PostDelayedTask(std::move(task), delay, location);
|
||||||
break;
|
break;
|
||||||
case DelayPrecision::kHigh:
|
case DelayPrecision::kHigh:
|
||||||
PostDelayedHighPrecisionTask(std::move(task), delay);
|
PostDelayedHighPrecisionTask(std::move(task), delay, location);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,19 +173,17 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueueBase {
|
|||||||
|
|
||||||
// Subclasses should implement this method to support the behavior defined in
|
// Subclasses should implement this method to support the behavior defined in
|
||||||
// the PostTask and PostTaskTraits docs above.
|
// the PostTask and PostTaskTraits docs above.
|
||||||
// TODO(crbug.com/1416199): make pure virtual once subclasses migrate.
|
|
||||||
virtual void PostTaskImpl(absl::AnyInvocable<void() &&> task,
|
virtual void PostTaskImpl(absl::AnyInvocable<void() &&> task,
|
||||||
const PostTaskTraits& traits,
|
const PostTaskTraits& traits,
|
||||||
const Location& location) {}
|
const Location& location) = 0;
|
||||||
|
|
||||||
// Subclasses should implement this method to support the behavior defined in
|
// Subclasses should implement this method to support the behavior defined in
|
||||||
// the PostDelayedTask/PostHighPrecisionDelayedTask and PostDelayedTaskTraits
|
// the PostDelayedTask/PostHighPrecisionDelayedTask and PostDelayedTaskTraits
|
||||||
// docs above.
|
// docs above.
|
||||||
// TODO(crbug.com/1416199): make pure virtual once subclasses migrate.
|
|
||||||
virtual void PostDelayedTaskImpl(absl::AnyInvocable<void() &&> task,
|
virtual void PostDelayedTaskImpl(absl::AnyInvocable<void() &&> task,
|
||||||
TimeDelta delay,
|
TimeDelta delay,
|
||||||
const PostDelayedTaskTraits& traits,
|
const PostDelayedTaskTraits& traits,
|
||||||
const Location& location) {}
|
const Location& location) = 0;
|
||||||
|
|
||||||
// Users of the TaskQueue should call Delete instead of directly deleting
|
// Users of the TaskQueue should call Delete instead of directly deleting
|
||||||
// this object.
|
// this object.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user