base: Factor task debug annotations out of MessageLoop
The MessageLoop has some code for adding debug annotations such as trace
flows and memory usage tags to posted tasks. Since we want to use these
annotations more generally for tasks that are scheduled outside the base
message loop, this patch factors it out into a standalone class.
TEST=TaskAnnotatorTest
BUG=391005
Review URL: https://codereview.chromium.org/455833004
Cr-Commit-Position: refs/heads/master@{#289560}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289560 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: ad8fb459e07068582588d72fd5dabdb72e70b689
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 1d13b12..39a1b68 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -11,6 +11,7 @@
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/callback_forward.h"
+#include "base/debug/task_annotator.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -426,10 +427,9 @@
// true if some work was done.
bool DeletePendingTasks();
- // Creates a process-wide unique ID to represent this task in trace events.
- // This will be mangled with a Process ID hash to reduce the likelyhood of
- // colliding with MessageLoop pointers on other processes.
- uint64 GetTaskTraceID(const PendingTask& task);
+ // Returns the TaskAnnotator which is used to add debug information to posted
+ // tasks.
+ debug::TaskAnnotator* task_annotator() { return &task_annotator_; }
// Loads tasks from the incoming queue to |work_queue_| if the latter is
// empty.
@@ -490,6 +490,8 @@
ObserverList<TaskObserver> task_observers_;
+ debug::TaskAnnotator task_annotator_;
+
scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_;
// The message loop proxy associated with this message loop.