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

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

Issue 445413003: Creating a framework for suppressing pollution of the profiler data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « no previous file | base/profiler/scoped_profile.h » ('j') | base/tracked_objects.h » ('J')
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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 PendingTask pending_task = deferred_non_nestable_work_queue_.front(); 410 PendingTask pending_task = deferred_non_nestable_work_queue_.front();
411 deferred_non_nestable_work_queue_.pop(); 411 deferred_non_nestable_work_queue_.pop();
412 412
413 RunTask(pending_task); 413 RunTask(pending_task);
414 return true; 414 return true;
415 } 415 }
416 416
417 void MessageLoop::RunTask(const PendingTask& pending_task) { 417 void MessageLoop::RunTask(const PendingTask& pending_task) {
418 tracked_objects::TrackedTime start_time = 418 tracked_objects::TrackedTime start_time =
419 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); 419 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
420 tracked_objects::TaskStopwatch stopwatch;
421 stopwatch.Start(start_time);
420 422
421 TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), 423 TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
422 "MessageLoop::PostTask", TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), 424 "MessageLoop::PostTask", TRACE_ID_MANGLE(GetTaskTraceID(pending_task)),
423 "queue_duration", 425 "queue_duration",
424 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds()); 426 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds());
425 // When tracing memory for posted tasks it's more valuable to attribute the 427 // When tracing memory for posted tasks it's more valuable to attribute the
426 // memory allocations to the source function than generically to "RunTask". 428 // memory allocations to the source function than generically to "RunTask".
427 TRACE_EVENT_WITH_MEMORY_TAG2( 429 TRACE_EVENT_WITH_MEMORY_TAG2(
428 "toplevel", "MessageLoop::RunTask", 430 "toplevel", "MessageLoop::RunTask",
429 pending_task.posted_from.function_name(), // Name for memory tracking. 431 pending_task.posted_from.function_name(), // Name for memory tracking.
(...skipping 14 matching lines...) Expand all
444 debug::Alias(&program_counter); 446 debug::Alias(&program_counter);
445 447
446 HistogramEvent(kTaskRunEvent); 448 HistogramEvent(kTaskRunEvent);
447 449
448 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 450 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
449 WillProcessTask(pending_task)); 451 WillProcessTask(pending_task));
450 pending_task.task.Run(); 452 pending_task.task.Run();
451 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 453 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
452 DidProcessTask(pending_task)); 454 DidProcessTask(pending_task));
453 455
454 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, 456 stopwatch.Stop();
455 start_time, tracked_objects::ThreadData::NowForEndOfRun()); 457 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(
jar (doing other things) 2014/08/08 01:34:48 It is pretty critical that NowForEndOFRun() is use
vadimt 2014/08/08 20:39:33 No, it was just a stupid mistake. I wanted to use
458 pending_task, stopwatch);
456 459
457 nestable_tasks_allowed_ = true; 460 nestable_tasks_allowed_ = true;
458 } 461 }
459 462
460 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) { 463 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) {
461 if (pending_task.nestable || run_loop_->run_depth_ == 1) { 464 if (pending_task.nestable || run_loop_->run_depth_ == 1) {
462 RunTask(pending_task); 465 RunTask(pending_task);
463 // Show that we ran a task (Note: a new one might arrive as a 466 // Show that we ran a task (Note: a new one might arrive as a
464 // consequence!). 467 // consequence!).
465 return true; 468 return true;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 persistent, 736 persistent,
734 mode, 737 mode,
735 controller, 738 controller,
736 delegate); 739 delegate);
737 } 740 }
738 #endif 741 #endif
739 742
740 #endif // !defined(OS_NACL) 743 #endif // !defined(OS_NACL)
741 744
742 } // namespace base 745 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/profiler/scoped_profile.h » ('j') | base/tracked_objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698