| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 static void QuitCurrentWhenIdle() { | 351 static void QuitCurrentWhenIdle() { |
| 352 MessageLoop::current()->QuitWhenIdle(); | 352 MessageLoop::current()->QuitWhenIdle(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 // static | 355 // static |
| 356 Closure MessageLoop::QuitWhenIdleClosure() { | 356 Closure MessageLoop::QuitWhenIdleClosure() { |
| 357 return Bind(&QuitCurrentWhenIdle); | 357 return Bind(&QuitCurrentWhenIdle); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void MessageLoop::SetNestableTasksAllowed(bool allowed) { | 360 void MessageLoop::SetNestableTasksAllowed(bool allowed) { |
| 361 if (nestable_tasks_allowed_ != allowed) { | 361 if (allowed) { |
| 362 nestable_tasks_allowed_ = allowed; | 362 // Kick the native pump just in case we enter a OS-driven nested message |
| 363 if (!nestable_tasks_allowed_) | 363 // loop. |
| 364 return; | |
| 365 // Start the native pump if we are not already pumping. | |
| 366 pump_->ScheduleWork(); | 364 pump_->ScheduleWork(); |
| 367 } | 365 } |
| 366 nestable_tasks_allowed_ = allowed; |
| 368 } | 367 } |
| 369 | 368 |
| 370 bool MessageLoop::NestableTasksAllowed() const { | 369 bool MessageLoop::NestableTasksAllowed() const { |
| 371 return nestable_tasks_allowed_; | 370 return nestable_tasks_allowed_; |
| 372 } | 371 } |
| 373 | 372 |
| 374 bool MessageLoop::IsNested() { | 373 bool MessageLoop::IsNested() { |
| 375 return run_loop_->run_depth_ > 1; | 374 return run_loop_->run_depth_ > 1; |
| 376 } | 375 } |
| 377 | 376 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 fd, | 782 fd, |
| 784 persistent, | 783 persistent, |
| 785 mode, | 784 mode, |
| 786 controller, | 785 controller, |
| 787 delegate); | 786 delegate); |
| 788 } | 787 } |
| 789 | 788 |
| 790 #endif | 789 #endif |
| 791 | 790 |
| 792 } // namespace base | 791 } // namespace base |
| OLD | NEW |