| OLD | NEW |
| 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 Loading... |
| 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 #if defined(TRACK_ALL_TASK_OBJECTS) |
| 481 TimeTicks start_of_run = tracked_objects::ThreadData::Now(); |
| 482 #endif // defined(TRACK_ALL_TASK_OBJECTS) |
| 483 |
| 479 FOR_EACH_OBSERVER(TaskObserver, task_observers_, | 484 FOR_EACH_OBSERVER(TaskObserver, task_observers_, |
| 480 WillProcessTask(pending_task.time_posted)); | 485 WillProcessTask(pending_task.time_posted)); |
| 481 pending_task.task.Run(); | 486 pending_task.task.Run(); |
| 482 FOR_EACH_OBSERVER(TaskObserver, task_observers_, | 487 FOR_EACH_OBSERVER(TaskObserver, task_observers_, |
| 483 DidProcessTask(pending_task.time_posted)); | 488 DidProcessTask(pending_task.time_posted)); |
| 484 | |
| 485 #if defined(TRACK_ALL_TASK_OBJECTS) | 489 #if defined(TRACK_ALL_TASK_OBJECTS) |
| 486 tracked_objects::ThreadData::TallyADeathIfActive( | 490 tracked_objects::ThreadData::TallyADeathIfActive(pending_task.post_births, |
| 487 pending_task.post_births, | 491 pending_task.time_posted, pending_task.delayed_run_time, start_of_run); |
| 488 TimeTicks::Now() - pending_task.time_posted); | |
| 489 #endif // defined(TRACK_ALL_TASK_OBJECTS) | 492 #endif // defined(TRACK_ALL_TASK_OBJECTS) |
| 490 | 493 |
| 491 nestable_tasks_allowed_ = true; | 494 nestable_tasks_allowed_ = true; |
| 492 } | 495 } |
| 493 | 496 |
| 494 bool MessageLoop::DeferOrRunPendingTask( | 497 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) { |
| 495 const PendingTask& pending_task) { | |
| 496 if (pending_task.nestable || state_->run_depth == 1) { | 498 if (pending_task.nestable || state_->run_depth == 1) { |
| 497 RunTask(pending_task); | 499 RunTask(pending_task); |
| 498 // Show that we ran a task (Note: a new one might arrive as a | 500 // Show that we ran a task (Note: a new one might arrive as a |
| 499 // consequence!). | 501 // consequence!). |
| 500 return true; | 502 return true; |
| 501 } | 503 } |
| 502 | 504 |
| 503 // We couldn't run the task now because we're in a nested message loop | 505 // We couldn't run the task now because we're in a nested message loop |
| 504 // and the task isn't nestable. | 506 // and the task isn't nestable. |
| 505 deferred_non_nestable_work_queue_.push(pending_task); | 507 deferred_non_nestable_work_queue_.push(pending_task); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 Watcher *delegate) { | 861 Watcher *delegate) { |
| 860 return pump_libevent()->WatchFileDescriptor( | 862 return pump_libevent()->WatchFileDescriptor( |
| 861 fd, | 863 fd, |
| 862 persistent, | 864 persistent, |
| 863 static_cast<base::MessagePumpLibevent::Mode>(mode), | 865 static_cast<base::MessagePumpLibevent::Mode>(mode), |
| 864 controller, | 866 controller, |
| 865 delegate); | 867 delegate); |
| 866 } | 868 } |
| 867 | 869 |
| 868 #endif | 870 #endif |
| OLD | NEW |