diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-03 17:51:25 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-03 17:51:25 +0000 |
commit | 19d8a90fbc1fd7c26a873dc84fcbc875c509cf11 (patch) | |
tree | fc4334d1a7764649899ee6bbfef21c347f1a11fb /base/message_loop.cc | |
parent | e4a2d08560a6853ce728c142ee71a104f14acea0 (diff) | |
download | chromium_src-19d8a90fbc1fd7c26a873dc84fcbc875c509cf11.zip chromium_src-19d8a90fbc1fd7c26a873dc84fcbc875c509cf11.tar.gz chromium_src-19d8a90fbc1fd7c26a873dc84fcbc875c509cf11.tar.bz2 |
Add trace code to track all posted tasks in message_loop and WorkerThreads (non-official builds only).
It's very helpful to understand what chrome is doing at runtime. Sometimes a thread in chrome does something expensive that causes a frame hitch. With this change, any expensive task will show up clearly in traces, with the file/function of where the task was posted.
TEST=go to about:tracing, run a trace and notice that all tasks are traced.
Review URL: http://codereview.chromium.org/7778033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.cc')
-rw-r--r-- | base/message_loop.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index d96b57d..b4af87d 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/debug/alias.h" +#include "base/debug/trace_event.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -458,6 +459,9 @@ bool MessageLoop::ProcessNextDelayedNonNestableTask() { } void MessageLoop::RunTask(const PendingTask& pending_task) { + UNSHIPPED_TRACE_EVENT2("task", "MessageLoop::RunTask", + "src_file", pending_task.posted_from.file_name(), + "src_func", pending_task.posted_from.function_name()); DCHECK(nestable_tasks_allowed_); // Execute the task and assume the worst: It is probably not reentrant. nestable_tasks_allowed_ = false; @@ -467,7 +471,8 @@ void MessageLoop::RunTask(const PendingTask& pending_task) { // crashes. Be careful not to assume that the variable itself will have the // expected value when displayed by the optimizer in an optimized build. // Look at a memory dump of the stack. - const void* program_counter = pending_task.birth_program_counter; + const void* program_counter = + pending_task.posted_from.program_counter(); base::debug::Alias(&program_counter); HistogramEvent(kTaskRunEvent); @@ -765,9 +770,9 @@ MessageLoop::PendingTask::PendingTask( : task(task), time_posted(TimeTicks::Now()), delayed_run_time(delayed_run_time), + posted_from(posted_from), sequence_num(0), - nestable(nestable), - birth_program_counter(posted_from.program_counter()) { + nestable(nestable) { #if defined(TRACK_ALL_TASK_OBJECTS) post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from); #endif // defined(TRACK_ALL_TASK_OBJECTS) |