OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return; | 291 return; |
292 // Start the native pump if we are not already pumping. | 292 // Start the native pump if we are not already pumping. |
293 pump_->ScheduleWork(); | 293 pump_->ScheduleWork(); |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 bool MessageLoop::NestableTasksAllowed() const { | 297 bool MessageLoop::NestableTasksAllowed() const { |
298 return nestable_tasks_allowed_; | 298 return nestable_tasks_allowed_; |
299 } | 299 } |
300 | 300 |
| 301 bool MessageLoop::IsNested() { |
| 302 return state_->run_depth > 1; |
| 303 } |
| 304 |
301 //------------------------------------------------------------------------------ | 305 //------------------------------------------------------------------------------ |
302 | 306 |
303 void MessageLoop::RunTask(Task* task) { | 307 void MessageLoop::RunTask(Task* task) { |
304 DCHECK(nestable_tasks_allowed_); | 308 DCHECK(nestable_tasks_allowed_); |
305 // Execute the task and assume the worst: It is probably not reentrant. | 309 // Execute the task and assume the worst: It is probably not reentrant. |
306 nestable_tasks_allowed_ = false; | 310 nestable_tasks_allowed_ = false; |
307 | 311 |
308 HistogramEvent(kTaskRunEvent); | 312 HistogramEvent(kTaskRunEvent); |
309 task->Run(); | 313 task->Run(); |
310 delete task; | 314 delete task; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 Watcher *delegate) { | 623 Watcher *delegate) { |
620 return pump_libevent()->WatchFileDescriptor( | 624 return pump_libevent()->WatchFileDescriptor( |
621 fd, | 625 fd, |
622 persistent, | 626 persistent, |
623 static_cast<base::MessagePumpLibevent::Mode>(mode), | 627 static_cast<base::MessagePumpLibevent::Mode>(mode), |
624 controller, | 628 controller, |
625 delegate); | 629 delegate); |
626 } | 630 } |
627 | 631 |
628 #endif | 632 #endif |
OLD | NEW |