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

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

Issue 18083015: Add queued_time_ms trace for events in message loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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 | « no previous file | base/tracked_objects.cc » ('j') | 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 return false; 449 return false;
450 450
451 PendingTask pending_task = deferred_non_nestable_work_queue_.front(); 451 PendingTask pending_task = deferred_non_nestable_work_queue_.front();
452 deferred_non_nestable_work_queue_.pop(); 452 deferred_non_nestable_work_queue_.pop();
453 453
454 RunTask(pending_task); 454 RunTask(pending_task);
455 return true; 455 return true;
456 } 456 }
457 457
458 void MessageLoop::RunTask(const PendingTask& pending_task) { 458 void MessageLoop::RunTask(const PendingTask& pending_task) {
459 TRACE_EVENT_FLOW_END0("task", "MessageLoop::PostTask", 459 tracked_objects::TrackedTime start_time =
460 TRACE_ID_MANGLE(GetTaskTraceID(pending_task, this))); 460 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
461
462 TRACE_EVENT_FLOW_END1("task", "MessageLoop::PostTask",
463 TRACE_ID_MANGLE(GetTaskTraceID(pending_task, this)),
464 "queue_duration",
465 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds());
461 TRACE_EVENT2("task", "MessageLoop::RunTask", 466 TRACE_EVENT2("task", "MessageLoop::RunTask",
462 "src_file", pending_task.posted_from.file_name(), 467 "src_file", pending_task.posted_from.file_name(),
463 "src_func", pending_task.posted_from.function_name()); 468 "src_func", pending_task.posted_from.function_name());
469
464 DCHECK(nestable_tasks_allowed_); 470 DCHECK(nestable_tasks_allowed_);
465 // Execute the task and assume the worst: It is probably not reentrant. 471 // Execute the task and assume the worst: It is probably not reentrant.
466 nestable_tasks_allowed_ = false; 472 nestable_tasks_allowed_ = false;
467 473
468 // Before running the task, store the program counter where it was posted 474 // Before running the task, store the program counter where it was posted
469 // and deliberately alias it to ensure it is on the stack if the task 475 // and deliberately alias it to ensure it is on the stack if the task
470 // crashes. Be careful not to assume that the variable itself will have the 476 // crashes. Be careful not to assume that the variable itself will have the
471 // expected value when displayed by the optimizer in an optimized build. 477 // expected value when displayed by the optimizer in an optimized build.
472 // Look at a memory dump of the stack. 478 // Look at a memory dump of the stack.
473 const void* program_counter = 479 const void* program_counter =
474 pending_task.posted_from.program_counter(); 480 pending_task.posted_from.program_counter();
475 debug::Alias(&program_counter); 481 debug::Alias(&program_counter);
476 482
477 HistogramEvent(kTaskRunEvent); 483 HistogramEvent(kTaskRunEvent);
478 484
479 tracked_objects::TrackedTime start_time =
480 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
481
482 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 485 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
483 WillProcessTask(pending_task)); 486 WillProcessTask(pending_task));
484 pending_task.task.Run(); 487 pending_task.task.Run();
485 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 488 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
486 DidProcessTask(pending_task)); 489 DidProcessTask(pending_task));
487 490
488 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, 491 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(pending_task,
489 start_time, tracked_objects::ThreadData::NowForEndOfRun()); 492 start_time, tracked_objects::ThreadData::NowForEndOfRun());
490 493
491 nestable_tasks_allowed_ = true; 494 nestable_tasks_allowed_ = true;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 fd, 828 fd,
826 persistent, 829 persistent,
827 mode, 830 mode,
828 controller, 831 controller,
829 delegate); 832 delegate);
830 } 833 }
831 834
832 #endif 835 #endif
833 836
834 } // namespace base 837 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/tracked_objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698