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

Side by Side Diff: base/message_loop.cc

Issue 8391019: Fully enable about:tracking by default (Closed) Base URL: svn://chrome-svn/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 #if defined(TRACK_ALL_TASK_OBJECTS) 489 tracked_objects::TrackedTime start_time = tracked_objects::ThreadData::Now();
490 TimeTicks start_of_run = tracked_objects::ThreadData::Now();
491 #endif // defined(TRACK_ALL_TASK_OBJECTS)
492 490
493 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 491 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
494 WillProcessTask(pending_task.time_posted)); 492 WillProcessTask(pending_task.time_posted));
495 pending_task.task.Run(); 493 pending_task.task.Run();
496 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 494 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
497 DidProcessTask(pending_task.time_posted)); 495 DidProcessTask(pending_task.time_posted));
498 #if defined(TRACK_ALL_TASK_OBJECTS) 496
499 tracked_objects::ThreadData::TallyADeathIfActive(pending_task.post_births, 497 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(pending_task,
500 pending_task.time_posted, pending_task.delayed_run_time, start_of_run, 498 start_time, tracked_objects::ThreadData::Now());
501 tracked_objects::ThreadData::Now());
502 #endif // defined(TRACK_ALL_TASK_OBJECTS)
503 499
504 nestable_tasks_allowed_ = true; 500 nestable_tasks_allowed_ = true;
505 } 501 }
506 502
507 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) { 503 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) {
508 if (pending_task.nestable || state_->run_depth == 1) { 504 if (pending_task.nestable || state_->run_depth == 1) {
509 RunTask(pending_task); 505 RunTask(pending_task);
510 // Show that we ran a task (Note: a new one might arrive as a 506 // Show that we ran a task (Note: a new one might arrive as a
511 // consequence!). 507 // consequence!).
512 return true; 508 return true;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 761 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
766 dispatcher = NULL; 762 dispatcher = NULL;
767 #endif 763 #endif
768 } 764 }
769 765
770 MessageLoop::AutoRunState::~AutoRunState() { 766 MessageLoop::AutoRunState::~AutoRunState() {
771 loop_->state_ = previous_state_; 767 loop_->state_ = previous_state_;
772 } 768 }
773 769
774 //------------------------------------------------------------------------------ 770 //------------------------------------------------------------------------------
771 // MessageLoop::TrackingInfo
772
773 MessageLoop::TrackingInfo::TrackingInfo(
774 const tracked_objects::Location& posted_from,
775 base::TimeTicks delayed_run_time)
776 : birth_tally(
777 tracked_objects::ThreadData::TallyABirthIfActive(posted_from)),
778 time_posted(TimeTicks::Now()),
779 delayed_run_time(delayed_run_time) {
780 }
781
782 MessageLoop::TrackingInfo::~TrackingInfo() {}
783
784 //------------------------------------------------------------------------------
775 // MessageLoop::PendingTask 785 // MessageLoop::PendingTask
776
777 MessageLoop::PendingTask::PendingTask( 786 MessageLoop::PendingTask::PendingTask(
778 const base::Closure& task, 787 const base::Closure& task,
779 const tracked_objects::Location& posted_from, 788 const tracked_objects::Location& posted_from,
780 TimeTicks delayed_run_time, 789 TimeTicks delayed_run_time,
781 bool nestable) 790 bool nestable)
782 : task(task), 791 : TrackingInfo(posted_from, delayed_run_time),
783 time_posted(TimeTicks::Now()), 792 task(task),
784 delayed_run_time(delayed_run_time),
785 posted_from(posted_from), 793 posted_from(posted_from),
786 sequence_num(0), 794 sequence_num(0),
787 nestable(nestable) { 795 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)
791 } 796 }
792 797
793 MessageLoop::PendingTask::~PendingTask() { 798 MessageLoop::PendingTask::~PendingTask() {
794 } 799 }
795 800
796 bool MessageLoop::PendingTask::operator<(const PendingTask& other) const { 801 bool MessageLoop::PendingTask::operator<(const PendingTask& other) const {
797 // Since the top of a priority queue is defined as the "greatest" element, we 802 // Since the top of a priority queue is defined as the "greatest" element, we
798 // need to invert the comparison here. We want the smaller time to be at the 803 // need to invert the comparison here. We want the smaller time to be at the
799 // top of the heap. 804 // top of the heap.
800 805
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 Watcher *delegate) { 876 Watcher *delegate) {
872 return pump_libevent()->WatchFileDescriptor( 877 return pump_libevent()->WatchFileDescriptor(
873 fd, 878 fd,
874 persistent, 879 persistent,
875 static_cast<base::MessagePumpLibevent::Mode>(mode), 880 static_cast<base::MessagePumpLibevent::Mode>(mode),
876 controller, 881 controller,
877 delegate); 882 delegate);
878 } 883 }
879 884
880 #endif 885 #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