| 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 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 void MessageLoop::AddNestingObserver(NestingObserver* observer) { | 269 void MessageLoop::AddNestingObserver(NestingObserver* observer) { |
| 270 DCHECK_EQ(this, current()); | 270 DCHECK_EQ(this, current()); |
| 271 nesting_observers_.AddObserver(observer); | 271 nesting_observers_.AddObserver(observer); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void MessageLoop::RemoveNestingObserver(NestingObserver* observer) { | 274 void MessageLoop::RemoveNestingObserver(NestingObserver* observer) { |
| 275 DCHECK_EQ(this, current()); | 275 DCHECK_EQ(this, current()); |
| 276 nesting_observers_.RemoveObserver(observer); | 276 nesting_observers_.RemoveObserver(observer); |
| 277 } | 277 } |
| 278 | 278 |
| 279 #if !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| 279 void MessageLoop::PostTask( | 280 void MessageLoop::PostTask( |
| 280 const tracked_objects::Location& from_here, | 281 const tracked_objects::Location& from_here, |
| 281 const Closure& task) { | 282 const Closure& task) { |
| 282 task_runner_->PostTask(from_here, task); | 283 task_runner_->PostTask(from_here, task); |
| 283 } | 284 } |
| 284 | 285 |
| 285 void MessageLoop::PostDelayedTask( | 286 void MessageLoop::PostDelayedTask( |
| 286 const tracked_objects::Location& from_here, | 287 const tracked_objects::Location& from_here, |
| 287 const Closure& task, | 288 const Closure& task, |
| 288 TimeDelta delay) { | 289 TimeDelta delay) { |
| 289 task_runner_->PostDelayedTask(from_here, task, delay); | 290 task_runner_->PostDelayedTask(from_here, task, delay); |
| 290 } | 291 } |
| 292 #endif // !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| 291 | 293 |
| 292 void MessageLoop::Run() { | 294 void MessageLoop::Run() { |
| 293 DCHECK(pump_); | 295 DCHECK(pump_); |
| 294 RunLoop run_loop; | 296 RunLoop run_loop; |
| 295 run_loop.Run(); | 297 run_loop.Run(); |
| 296 } | 298 } |
| 297 | 299 |
| 298 void MessageLoop::RunUntilIdle() { | 300 void MessageLoop::RunUntilIdle() { |
| 299 DCHECK(pump_); | 301 DCHECK(pump_); |
| 300 RunLoop run_loop; | 302 RunLoop run_loop; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // for some tasks. | 683 // for some tasks. |
| 682 bool high_res = pending_high_res_tasks_ > 0; | 684 bool high_res = pending_high_res_tasks_ > 0; |
| 683 if (high_res != in_high_res_mode_) { | 685 if (high_res != in_high_res_mode_) { |
| 684 in_high_res_mode_ = high_res; | 686 in_high_res_mode_ = high_res; |
| 685 Time::ActivateHighResolutionTimer(in_high_res_mode_); | 687 Time::ActivateHighResolutionTimer(in_high_res_mode_); |
| 686 } | 688 } |
| 687 #endif | 689 #endif |
| 688 return false; | 690 return false; |
| 689 } | 691 } |
| 690 | 692 |
| 693 #if !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| 691 void MessageLoop::DeleteSoonInternal(const tracked_objects::Location& from_here, | 694 void MessageLoop::DeleteSoonInternal(const tracked_objects::Location& from_here, |
| 692 void(*deleter)(const void*), | 695 void(*deleter)(const void*), |
| 693 const void* object) { | 696 const void* object) { |
| 694 task_runner()->PostNonNestableTask(from_here, Bind(deleter, object)); | 697 task_runner()->PostNonNestableTask(from_here, Bind(deleter, object)); |
| 695 } | 698 } |
| 696 | 699 |
| 697 void MessageLoop::ReleaseSoonInternal( | 700 void MessageLoop::ReleaseSoonInternal( |
| 698 const tracked_objects::Location& from_here, | 701 const tracked_objects::Location& from_here, |
| 699 void(*releaser)(const void*), | 702 void(*releaser)(const void*), |
| 700 const void* object) { | 703 const void* object) { |
| 701 task_runner()->PostNonNestableTask(from_here, Bind(releaser, object)); | 704 task_runner()->PostNonNestableTask(from_here, Bind(releaser, object)); |
| 702 } | 705 } |
| 706 #endif // !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| 703 | 707 |
| 704 #if !defined(OS_NACL) | 708 #if !defined(OS_NACL) |
| 705 //------------------------------------------------------------------------------ | 709 //------------------------------------------------------------------------------ |
| 706 // MessageLoopForUI | 710 // MessageLoopForUI |
| 707 | 711 |
| 708 MessageLoopForUI::MessageLoopForUI(std::unique_ptr<MessagePump> pump) | 712 MessageLoopForUI::MessageLoopForUI(std::unique_ptr<MessagePump> pump) |
| 709 : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) {} | 713 : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) {} |
| 710 | 714 |
| 711 #if defined(OS_ANDROID) | 715 #if defined(OS_ANDROID) |
| 712 void MessageLoopForUI::Start() { | 716 void MessageLoopForUI::Start() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 persistent, | 771 persistent, |
| 768 mode, | 772 mode, |
| 769 controller, | 773 controller, |
| 770 delegate); | 774 delegate); |
| 771 } | 775 } |
| 772 #endif | 776 #endif |
| 773 | 777 |
| 774 #endif // !defined(OS_NACL_SFI) | 778 #endif // !defined(OS_NACL_SFI) |
| 775 | 779 |
| 776 } // namespace base | 780 } // namespace base |
| OLD | NEW |