| 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" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 in_high_res_mode_(false), | 121 in_high_res_mode_(false), |
| 122 nestable_tasks_allowed_(true), | 122 nestable_tasks_allowed_(true), |
| 123 #if defined(OS_WIN) | 123 #if defined(OS_WIN) |
| 124 os_modal_loop_(false), | 124 os_modal_loop_(false), |
| 125 #endif // OS_WIN | 125 #endif // OS_WIN |
| 126 message_histogram_(NULL), | 126 message_histogram_(NULL), |
| 127 run_loop_(NULL) { | 127 run_loop_(NULL) { |
| 128 Init(); | 128 Init(); |
| 129 | 129 |
| 130 pump_ = CreateMessagePumpForType(type).Pass(); | 130 pump_ = CreateMessagePumpForType(type).Pass(); |
| 131 on_render_thread_ = false; |
| 131 } | 132 } |
| 132 | 133 |
| 133 MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump) | 134 MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump) |
| 134 : pump_(pump.Pass()), | 135 : pump_(pump.Pass()), |
| 135 type_(TYPE_CUSTOM), | 136 type_(TYPE_CUSTOM), |
| 136 pending_high_res_tasks_(0), | 137 pending_high_res_tasks_(0), |
| 137 in_high_res_mode_(false), | 138 in_high_res_mode_(false), |
| 138 nestable_tasks_allowed_(true), | 139 nestable_tasks_allowed_(true), |
| 139 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
| 140 os_modal_loop_(false), | 141 os_modal_loop_(false), |
| 141 #endif // OS_WIN | 142 #endif // OS_WIN |
| 142 message_histogram_(NULL), | 143 message_histogram_(NULL), |
| 143 run_loop_(NULL) { | 144 run_loop_(NULL) { |
| 144 DCHECK(pump_.get()); | 145 DCHECK(pump_.get()); |
| 145 Init(); | 146 Init(); |
| 147 on_render_thread_ = false; |
| 146 } | 148 } |
| 147 | 149 |
| 148 MessageLoop::~MessageLoop() { | 150 MessageLoop::~MessageLoop() { |
| 149 DCHECK_EQ(this, current()); | 151 DCHECK_EQ(this, current()); |
| 150 | 152 |
| 151 DCHECK(!run_loop_); | 153 DCHECK(!run_loop_); |
| 152 #if defined(OS_WIN) | 154 #if defined(OS_WIN) |
| 153 if (in_high_res_mode_) | 155 if (in_high_res_mode_) |
| 154 Time::ActivateHighResolutionTimer(false); | 156 Time::ActivateHighResolutionTimer(false); |
| 155 #endif | 157 #endif |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 426 |
| 425 if (pending_task.is_high_res) { | 427 if (pending_task.is_high_res) { |
| 426 pending_high_res_tasks_--; | 428 pending_high_res_tasks_--; |
| 427 CHECK(pending_high_res_tasks_ >= 0); | 429 CHECK(pending_high_res_tasks_ >= 0); |
| 428 } | 430 } |
| 429 // Execute the task and assume the worst: It is probably not reentrant. | 431 // Execute the task and assume the worst: It is probably not reentrant. |
| 430 nestable_tasks_allowed_ = false; | 432 nestable_tasks_allowed_ = false; |
| 431 | 433 |
| 432 HistogramEvent(kTaskRunEvent); | 434 HistogramEvent(kTaskRunEvent); |
| 433 | 435 |
| 436 bool mute = strcmp(pending_task.posted_from.function_name(), |
| 437 "setSharedTimerFireInterval") == 0 || |
| 438 strcmp(pending_task.posted_from.function_name(), |
| 439 "MaybePostDoWorkOnMainRunner") == 0; |
| 440 |
| 441 if (mute) { |
| 442 on_render_thread_ = true; |
| 443 } |
| 444 |
| 445 if (on_render_thread_ && !mute) { |
| 446 printf(">>>>>>>>>> MessageLoop::RunTask %s %s:%d\n", |
| 447 pending_task.posted_from.function_name() , |
| 448 pending_task.posted_from.file_name(), |
| 449 pending_task.posted_from.line_number()); |
| 450 } |
| 451 |
| 434 FOR_EACH_OBSERVER(TaskObserver, task_observers_, | 452 FOR_EACH_OBSERVER(TaskObserver, task_observers_, |
| 435 WillProcessTask(pending_task)); | 453 WillProcessTask(pending_task)); |
| 436 task_annotator_.RunTask( | 454 task_annotator_.RunTask( |
| 437 "MessageLoop::PostTask", "MessageLoop::RunTask", pending_task); | 455 "MessageLoop::PostTask", "MessageLoop::RunTask", pending_task); |
| 438 FOR_EACH_OBSERVER(TaskObserver, task_observers_, | 456 FOR_EACH_OBSERVER(TaskObserver, task_observers_, |
| 439 DidProcessTask(pending_task)); | 457 DidProcessTask(pending_task)); |
| 440 | 458 |
| 441 nestable_tasks_allowed_ = true; | 459 nestable_tasks_allowed_ = true; |
| 442 } | 460 } |
| 443 | 461 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 persistent, | 717 persistent, |
| 700 mode, | 718 mode, |
| 701 controller, | 719 controller, |
| 702 delegate); | 720 delegate); |
| 703 } | 721 } |
| 704 #endif | 722 #endif |
| 705 | 723 |
| 706 #endif // !defined(OS_NACL_SFI) | 724 #endif // !defined(OS_NACL_SFI) |
| 707 | 725 |
| 708 } // namespace base | 726 } // namespace base |
| OLD | NEW |