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

Side by Side Diff: base/message_loop/message_loop.cc

Issue 22909045: Trace memory records source function for posted tasks instead of "RunTask" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better macro style Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 451 }
452 452
453 void MessageLoop::RunTask(const PendingTask& pending_task) { 453 void MessageLoop::RunTask(const PendingTask& pending_task) {
454 tracked_objects::TrackedTime start_time = 454 tracked_objects::TrackedTime start_time =
455 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); 455 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
456 456
457 TRACE_EVENT_FLOW_END1("task", "MessageLoop::PostTask", 457 TRACE_EVENT_FLOW_END1("task", "MessageLoop::PostTask",
458 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), 458 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)),
459 "queue_duration", 459 "queue_duration",
460 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds()); 460 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds());
461 TRACE_EVENT2("task", "MessageLoop::RunTask", 461 // When tracing memory for posted tasks it's more valuable to attribute the
462 "src_file", pending_task.posted_from.file_name(), 462 // memory allocations to the source function than generically to "RunTask".
463 "src_func", pending_task.posted_from.function_name()); 463 TRACE_EVENT_WITH_MEMORY_TAG2(
464 "task", "MessageLoop::RunTask",
465 pending_task.posted_from.function_name(), // Name for memory tracking.
466 "src_file", pending_task.posted_from.file_name(),
467 "src_func", pending_task.posted_from.function_name());
464 468
465 DCHECK(nestable_tasks_allowed_); 469 DCHECK(nestable_tasks_allowed_);
466 // Execute the task and assume the worst: It is probably not reentrant. 470 // Execute the task and assume the worst: It is probably not reentrant.
467 nestable_tasks_allowed_ = false; 471 nestable_tasks_allowed_ = false;
468 472
469 // Before running the task, store the program counter where it was posted 473 // Before running the task, store the program counter where it was posted
470 // and deliberately alias it to ensure it is on the stack if the task 474 // and deliberately alias it to ensure it is on the stack if the task
471 // crashes. Be careful not to assume that the variable itself will have the 475 // crashes. Be careful not to assume that the variable itself will have the
472 // expected value when displayed by the optimizer in an optimized build. 476 // expected value when displayed by the optimizer in an optimized build.
473 // Look at a memory dump of the stack. 477 // Look at a memory dump of the stack.
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 fd, 749 fd,
746 persistent, 750 persistent,
747 mode, 751 mode,
748 controller, 752 controller,
749 delegate); 753 delegate);
750 } 754 }
751 755
752 #endif 756 #endif
753 757
754 } // namespace base 758 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698