| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_RUN_LOOP_H_ | 5 #ifndef BASE_RUN_LOOP_H_ |
| 6 #define BASE_RUN_LOOP_H_ | 6 #define BASE_RUN_LOOP_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
| 15 class MessagePumpForUI; | 15 class MessagePumpForUI; |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #if defined(OS_IOS) |
| 19 class MessagePumpUIApplication; |
| 20 #endif |
| 21 |
| 18 // Helper class to Run a nested MessageLoop. Please do not use nested | 22 // Helper class to Run a nested MessageLoop. Please do not use nested |
| 19 // MessageLoops in production code! If you must, use this class instead of | 23 // MessageLoops in production code! If you must, use this class instead of |
| 20 // calling MessageLoop::Run/Quit directly. RunLoop::Run can only be called once | 24 // calling MessageLoop::Run/Quit directly. RunLoop::Run can only be called once |
| 21 // per RunLoop lifetime. Create a RunLoop on the stack and call Run/Quit to run | 25 // per RunLoop lifetime. Create a RunLoop on the stack and call Run/Quit to run |
| 22 // a nested MessageLoop. | 26 // a nested MessageLoop. |
| 23 class BASE_EXPORT RunLoop { | 27 class BASE_EXPORT RunLoop { |
| 24 public: | 28 public: |
| 25 RunLoop(); | 29 RunLoop(); |
| 26 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 30 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 27 explicit RunLoop(MessageLoop::Dispatcher* dispatcher); | 31 explicit RunLoop(MessageLoop::Dispatcher* dispatcher); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 base::Closure QuitClosure(); | 73 base::Closure QuitClosure(); |
| 70 | 74 |
| 71 private: | 75 private: |
| 72 friend class ::MessageLoop; | 76 friend class ::MessageLoop; |
| 73 #if defined(OS_ANDROID) | 77 #if defined(OS_ANDROID) |
| 74 // Android doesn't support the blocking MessageLoop::Run, so it calls | 78 // Android doesn't support the blocking MessageLoop::Run, so it calls |
| 75 // BeforeRun and AfterRun directly. | 79 // BeforeRun and AfterRun directly. |
| 76 friend class base::MessagePumpForUI; | 80 friend class base::MessagePumpForUI; |
| 77 #endif | 81 #endif |
| 78 | 82 |
| 83 #if defined(OS_IOS) |
| 84 // iOS doesn't support the blocking MessageLoop::Run, so it calls |
| 85 // BeforeRun directly. |
| 86 friend class base::MessagePumpUIApplication; |
| 87 #endif |
| 88 |
| 79 // Return false to abort the Run. | 89 // Return false to abort the Run. |
| 80 bool BeforeRun(); | 90 bool BeforeRun(); |
| 81 void AfterRun(); | 91 void AfterRun(); |
| 82 | 92 |
| 83 MessageLoop* loop_; | 93 MessageLoop* loop_; |
| 84 | 94 |
| 85 // WeakPtrFactory for QuitClosure safety. | 95 // WeakPtrFactory for QuitClosure safety. |
| 86 base::WeakPtrFactory<RunLoop> weak_factory_; | 96 base::WeakPtrFactory<RunLoop> weak_factory_; |
| 87 | 97 |
| 88 // Parent RunLoop or NULL if this is the top-most RunLoop. | 98 // Parent RunLoop or NULL if this is the top-most RunLoop. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 102 // Used to record that QuitWhenIdle() was called on the MessageLoop, meaning | 112 // Used to record that QuitWhenIdle() was called on the MessageLoop, meaning |
| 103 // that we should quit Run once it becomes idle. | 113 // that we should quit Run once it becomes idle. |
| 104 bool quit_when_idle_received_; | 114 bool quit_when_idle_received_; |
| 105 | 115 |
| 106 DISALLOW_COPY_AND_ASSIGN(RunLoop); | 116 DISALLOW_COPY_AND_ASSIGN(RunLoop); |
| 107 }; | 117 }; |
| 108 | 118 |
| 109 } // namespace base | 119 } // namespace base |
| 110 | 120 |
| 111 #endif // BASE_RUN_LOOP_H_ | 121 #endif // BASE_RUN_LOOP_H_ |
| OLD | NEW |