Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: base/debug/task_annotator.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/debug/stack_trace_win.cc ('k') | base/debug/task_annotator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_DEBUG_TASK_ANNOTATOR_H_
6 #define BASE_DEBUG_TASK_ANNOTATOR_H_
7
8 #include "base/base_export.h"
9 #include "base/basictypes.h"
10
11 namespace base {
12 struct PendingTask;
13 namespace debug {
14
15 // Implements common debug annotations for posted tasks. This includes data
16 // such as task origins, queueing durations and memory usage.
17 class BASE_EXPORT TaskAnnotator {
18 public:
19 TaskAnnotator();
20 ~TaskAnnotator();
21
22 // Called to indicate that a task has been queued to run in the future.
23 // |queue_function| is used as the trace flow event name.
24 void DidQueueTask(const char* queue_function,
25 const PendingTask& pending_task);
26
27 // Run a previously queued task. |queue_function| should match what was
28 // passed into |DidQueueTask| for this task.
29 void RunTask(const char* queue_function, const PendingTask& pending_task);
30
31 private:
32 // Creates a process-wide unique ID to represent this task in trace events.
33 // This will be mangled with a Process ID hash to reduce the likelyhood of
34 // colliding with TaskAnnotator pointers on other processes.
35 uint64 GetTaskTraceID(const PendingTask& task) const;
36
37 DISALLOW_COPY_AND_ASSIGN(TaskAnnotator);
38 };
39
40 #define TRACE_TASK_EXECUTION(run_function, task) \
41 TRACE_EVENT_WITH_MEMORY_TAG2( \
42 "toplevel", (run_function), \
43 (task).posted_from.function_name(), /* Name for memory tracking. */ \
44 "src_file", (task).posted_from.file_name(), "src_func", \
45 (task).posted_from.function_name());
46
47 } // namespace debug
48 } // namespace base
49
50 #endif // BASE_DEBUG_TASK_ANNOTATOR_H_
OLDNEW
« no previous file with comments | « base/debug/stack_trace_win.cc ('k') | base/debug/task_annotator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698