OLD | NEW |
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" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_pump_default.h" | 14 #include "base/message_loop/message_pump_default.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/metrics/statistics_recorder.h" | 16 #include "base/metrics/statistics_recorder.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
20 #include "base/threading/thread_local.h" | 20 #include "base/threading/thread_local.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/trace_event/trace_event.h" |
22 #include "base/tracked_objects.h" | 23 #include "base/tracked_objects.h" |
23 | 24 |
24 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
25 #include "base/message_loop/message_pump_mac.h" | 26 #include "base/message_loop/message_pump_mac.h" |
26 #endif | 27 #endif |
27 #if defined(OS_POSIX) && !defined(OS_IOS) | 28 #if defined(OS_POSIX) && !defined(OS_IOS) |
28 #include "base/message_loop/message_pump_libevent.h" | 29 #include "base/message_loop/message_pump_libevent.h" |
29 #endif | 30 #endif |
30 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
31 #include "base/message_loop/message_pump_android.h" | 32 #include "base/message_loop/message_pump_android.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 pending_high_res_tasks_--; | 467 pending_high_res_tasks_--; |
467 CHECK_GE(pending_high_res_tasks_, 0); | 468 CHECK_GE(pending_high_res_tasks_, 0); |
468 } | 469 } |
469 #endif | 470 #endif |
470 | 471 |
471 // Execute the task and assume the worst: It is probably not reentrant. | 472 // Execute the task and assume the worst: It is probably not reentrant. |
472 nestable_tasks_allowed_ = false; | 473 nestable_tasks_allowed_ = false; |
473 | 474 |
474 HistogramEvent(kTaskRunEvent); | 475 HistogramEvent(kTaskRunEvent); |
475 | 476 |
| 477 TRACE_EVENT_WITH_MEMORY_TAG2( |
| 478 "toplevel", |
| 479 "MessageLoop::PostTask", |
| 480 pending_task.posted_from.function_name(), // Name for memory tracking. |
| 481 "src_file", |
| 482 pending_task.posted_from.file_name(), |
| 483 "src_func", |
| 484 pending_task.posted_from.function_name()); |
| 485 |
476 FOR_EACH_OBSERVER(TaskObserver, task_observers_, | 486 FOR_EACH_OBSERVER(TaskObserver, task_observers_, |
477 WillProcessTask(pending_task)); | 487 WillProcessTask(pending_task)); |
478 task_annotator_.RunTask( | 488 task_annotator_.RunTask("MessageLoop::RunTask", pending_task); |
479 "MessageLoop::PostTask", "MessageLoop::RunTask", pending_task); | |
480 FOR_EACH_OBSERVER(TaskObserver, task_observers_, | 489 FOR_EACH_OBSERVER(TaskObserver, task_observers_, |
481 DidProcessTask(pending_task)); | 490 DidProcessTask(pending_task)); |
482 | 491 |
483 nestable_tasks_allowed_ = true; | 492 nestable_tasks_allowed_ = true; |
484 } | 493 } |
485 | 494 |
486 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) { | 495 bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) { |
487 if (pending_task.nestable || run_loop_->run_depth_ == 1) { | 496 if (pending_task.nestable || run_loop_->run_depth_ == 1) { |
488 RunTask(pending_task); | 497 RunTask(pending_task); |
489 // Show that we ran a task (Note: a new one might arrive as a | 498 // Show that we ran a task (Note: a new one might arrive as a |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 persistent, | 754 persistent, |
746 mode, | 755 mode, |
747 controller, | 756 controller, |
748 delegate); | 757 delegate); |
749 } | 758 } |
750 #endif | 759 #endif |
751 | 760 |
752 #endif // !defined(OS_NACL_SFI) | 761 #endif // !defined(OS_NACL_SFI) |
753 | 762 |
754 } // namespace base | 763 } // namespace base |
OLD | NEW |