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

Side by Side Diff: base/message_loop.cc

Issue 8233037: Update task tracking to not depend on message_loop_ singleton (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/threading/thread.cc » ('j') | base/threading/worker_pool_posix.cc » ('J')
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Before running the task, store the program counter where it was posted 469 // 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 470 // 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 471 // 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. 472 // expected value when displayed by the optimizer in an optimized build.
473 // Look at a memory dump of the stack. 473 // Look at a memory dump of the stack.
474 const void* program_counter = 474 const void* program_counter =
475 pending_task.posted_from.program_counter(); 475 pending_task.posted_from.program_counter();
476 base::debug::Alias(&program_counter); 476 base::debug::Alias(&program_counter);
477 477
478 HistogramEvent(kTaskRunEvent); 478 HistogramEvent(kTaskRunEvent);
479
480 TimeTicks start_of_run = tracked_objects::ThreadData::Now();
479 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 481 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
480 WillProcessTask(pending_task.time_posted)); 482 WillProcessTask(pending_task.time_posted));
481 pending_task.task.Run(); 483 pending_task.task.Run();
482 FOR_EACH_OBSERVER(TaskObserver, task_observers_, 484 FOR_EACH_OBSERVER(TaskObserver, task_observers_,
483 DidProcessTask(pending_task.time_posted)); 485 DidProcessTask(pending_task.time_posted));
484 486 tracked_objects::ThreadData::TallyADeathIfActive(pending_task.post_births,
485 #if defined(TRACK_ALL_TASK_OBJECTS) 487 pending_task.time_posted,
486 tracked_objects::ThreadData::TallyADeathIfActive( 488 start_of_run,
jar (doing other things) 2011/10/14 02:29:53 I changed this code so that I don't need to ifdef
487 pending_task.post_births, 489 this);
488 TimeTicks::Now() - pending_task.time_posted);
489 #endif // defined(TRACK_ALL_TASK_OBJECTS)
490 490
491 nestable_tasks_allowed_ = true; 491 nestable_tasks_allowed_ = true;
492 } 492 }
493 493
494 bool MessageLoop::DeferOrRunPendingTask( 494 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) {
495 const PendingTask& pending_task) {
496 if (pending_task.nestable || state_->run_depth == 1) { 495 if (pending_task.nestable || state_->run_depth == 1) {
497 RunTask(pending_task); 496 RunTask(pending_task);
498 // Show that we ran a task (Note: a new one might arrive as a 497 // Show that we ran a task (Note: a new one might arrive as a
499 // consequence!). 498 // consequence!).
500 return true; 499 return true;
501 } 500 }
502 501
503 // We couldn't run the task now because we're in a nested message loop 502 // We couldn't run the task now because we're in a nested message loop
504 // and the task isn't nestable. 503 // and the task isn't nestable.
505 deferred_non_nestable_work_queue_.push(pending_task); 504 deferred_non_nestable_work_queue_.push(pending_task);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 Watcher *delegate) { 858 Watcher *delegate) {
860 return pump_libevent()->WatchFileDescriptor( 859 return pump_libevent()->WatchFileDescriptor(
861 fd, 860 fd,
862 persistent, 861 persistent,
863 static_cast<base::MessagePumpLibevent::Mode>(mode), 862 static_cast<base::MessagePumpLibevent::Mode>(mode),
864 controller, 863 controller,
865 delegate); 864 delegate);
866 } 865 }
867 866
868 #endif 867 #endif
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread.cc » ('j') | base/threading/worker_pool_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698