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

Side by Side Diff: base/message_loop.cc

Issue 8430004: Revert 107895 - Fully enable about:tracking by default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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/message_loop.h ('k') | base/threading/thread.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "base/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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // and deliberately alias it to ensure it is on the stack if the task 479 // and deliberately alias it to ensure it is on the stack if the task
480 // crashes. Be careful not to assume that the variable itself will have the 480 // crashes. Be careful not to assume that the variable itself will have the
481 // expected value when displayed by the optimizer in an optimized build. 481 // expected value when displayed by the optimizer in an optimized build.
482 // Look at a memory dump of the stack. 482 // Look at a memory dump of the stack.
483 const void* program_counter = 483 const void* program_counter =
484 pending_task.posted_from.program_counter(); 484 pending_task.posted_from.program_counter();
485 base::debug::Alias(&program_counter); 485 base::debug::Alias(&program_counter);
486 486
487 HistogramEvent(kTaskRunEvent); 487 HistogramEvent(kTaskRunEvent);
488 488
489 tracked_objects::TrackedTime start_time = tracked_objects::ThreadData::Now(); 489 #if defined(TRACK_ALL_TASK_OBJECTS)
490 TimeTicks start_of_run = tracked_objects::ThreadData::Now();
491 #endif // defined(TRACK_ALL_TASK_OBJECTS)
490 492
491 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 493 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
492 WillProcessTask(pending_task.time_posted)); 494 WillProcessTask(pending_task.time_posted));
493 pending_task.task.Run(); 495 pending_task.task.Run();
494 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 496 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
495 DidProcessTask(pending_task.time_posted)); 497 DidProcessTask(pending_task.time_posted));
496 498 #if defined(TRACK_ALL_TASK_OBJECTS)
497 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(pending_task, 499 tracked_objects::ThreadData::TallyADeathIfActive(pending_task.post_births,
498 start_time, tracked_objects::ThreadData::Now()); 500 pending_task.time_posted, pending_task.delayed_run_time, start_of_run,
501 tracked_objects::ThreadData::Now());
502 #endif // defined(TRACK_ALL_TASK_OBJECTS)
499 503
500 nestable_tasks_allowed_ = true; 504 nestable_tasks_allowed_ = true;
501 } 505 }
502 506
503 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) { 507 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) {
504 if (pending_task.nestable || state_->run_depth == 1) { 508 if (pending_task.nestable || state_->run_depth == 1) {
505 RunTask(pending_task); 509 RunTask(pending_task);
506 // Show that we ran a task (Note: a new one might arrive as a 510 // Show that we ran a task (Note: a new one might arrive as a
507 // consequence!). 511 // consequence!).
508 return true; 512 return true;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 772 }
769 773
770 //------------------------------------------------------------------------------ 774 //------------------------------------------------------------------------------
771 // MessageLoop::PendingTask 775 // MessageLoop::PendingTask
772 776
773 MessageLoop::PendingTask::PendingTask( 777 MessageLoop::PendingTask::PendingTask(
774 const base::Closure& task, 778 const base::Closure& task,
775 const tracked_objects::Location& posted_from, 779 const tracked_objects::Location& posted_from,
776 TimeTicks delayed_run_time, 780 TimeTicks delayed_run_time,
777 bool nestable) 781 bool nestable)
778 : base::TrackingInfo(posted_from, delayed_run_time), 782 : task(task),
779 task(task), 783 time_posted(TimeTicks::Now()),
784 delayed_run_time(delayed_run_time),
780 posted_from(posted_from), 785 posted_from(posted_from),
781 sequence_num(0), 786 sequence_num(0),
782 nestable(nestable) { 787 nestable(nestable) {
788 #if defined(TRACK_ALL_TASK_OBJECTS)
789 post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
790 #endif // defined(TRACK_ALL_TASK_OBJECTS)
783 } 791 }
784 792
785 MessageLoop::PendingTask::~PendingTask() { 793 MessageLoop::PendingTask::~PendingTask() {
786 } 794 }
787 795
788 bool MessageLoop::PendingTask::operator<(const PendingTask& other) const { 796 bool MessageLoop::PendingTask::operator<(const PendingTask& other) const {
789 // Since the top of a priority queue is defined as the "greatest" element, we 797 // Since the top of a priority queue is defined as the "greatest" element, we
790 // need to invert the comparison here. We want the smaller time to be at the 798 // need to invert the comparison here. We want the smaller time to be at the
791 // top of the heap. 799 // top of the heap.
792 800
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 Watcher *delegate) { 871 Watcher *delegate) {
864 return pump_libevent()->WatchFileDescriptor( 872 return pump_libevent()->WatchFileDescriptor(
865 fd, 873 fd,
866 persistent, 874 persistent,
867 static_cast<base::MessagePumpLibevent::Mode>(mode), 875 static_cast<base::MessagePumpLibevent::Mode>(mode),
868 controller, 876 controller,
869 delegate); 877 delegate);
870 } 878 }
871 879
872 #endif 880 #endif
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698