OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 // The basis for all native run loops on the Mac is the CFRunLoop. It can be | 5 // The basis for all native run loops on the Mac is the CFRunLoop. It can be |
6 // used directly, it can be used as the driving force behind the similar | 6 // used directly, it can be used as the driving force behind the similar |
7 // Foundation NSRunLoop, and it can be used to implement higher-level event | 7 // Foundation NSRunLoop, and it can be used to implement higher-level event |
8 // loops such as the NSApplication event loop. | 8 // loops such as the NSApplication event loop. |
9 // | 9 // |
10 // This file introduces a basic CFRunLoop-based implementation of the | 10 // This file introduces a basic CFRunLoop-based implementation of the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 protected: | 56 protected: |
57 // The thread's run loop. | 57 // The thread's run loop. |
58 CFRunLoopRef run_loop_; | 58 CFRunLoopRef run_loop_; |
59 | 59 |
60 // The recursion depth of the currently-executing CFRunLoopRun loop on the | 60 // The recursion depth of the currently-executing CFRunLoopRun loop on the |
61 // run loop's thread. 0 if no run loops are running inside of whatever scope | 61 // run loop's thread. 0 if no run loops are running inside of whatever scope |
62 // the object was created in. | 62 // the object was created in. |
63 int nesting_level_; | 63 int nesting_level_; |
64 | 64 |
| 65 // The recursion depth (calculated in the same way as nesting_level_) of the |
| 66 // innermost executing CFRunLoopRun loop started by a call to Run. |
| 67 int run_nesting_level_; |
| 68 |
65 private: | 69 private: |
66 // Timer callback scheduled by ScheduleDelayedWork. This does not do any | 70 // Timer callback scheduled by ScheduleDelayedWork. This does not do any |
67 // work, but it signals delayed_work_source_ so that delayed work can be | 71 // work, but it signals delayed_work_source_ so that delayed work can be |
68 // performed within the appropriate priority constraints. | 72 // performed within the appropriate priority constraints. |
69 static void RunDelayedWorkTimer(CFRunLoopTimerRef timer, void* info); | 73 static void RunDelayedWorkTimer(CFRunLoopTimerRef timer, void* info); |
70 | 74 |
71 // Perform highest-priority work. This is associated with work_source_ | 75 // Perform highest-priority work. This is associated with work_source_ |
72 // signalled by ScheduleWork. The static method calls the instance method; | 76 // signalled by ScheduleWork. The static method calls the instance method; |
73 // the instance method returns true if work was done. | 77 // the instance method returns true if work was done. |
74 static void RunWorkSource(void* info); | 78 static void RunWorkSource(void* info); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase { | 147 class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase { |
144 public: | 148 public: |
145 MessagePumpCFRunLoop(); | 149 MessagePumpCFRunLoop(); |
146 | 150 |
147 virtual void DoRun(Delegate* delegate); | 151 virtual void DoRun(Delegate* delegate); |
148 virtual void Quit(); | 152 virtual void Quit(); |
149 | 153 |
150 private: | 154 private: |
151 virtual void EnterExitRunLoop(CFRunLoopActivity activity); | 155 virtual void EnterExitRunLoop(CFRunLoopActivity activity); |
152 | 156 |
153 // The recursion depth (calculated in the same way as nesting_level_) of the | |
154 // innermost executing CFRunLoopRun loop started by a call to Run. | |
155 int innermost_quittable_; | |
156 | |
157 // True if Quit is called to stop the innermost MessagePump | 157 // True if Quit is called to stop the innermost MessagePump |
158 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_) | 158 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_) |
159 // is running inside the MessagePump's innermost Run call. | 159 // is running inside the MessagePump's innermost Run call. |
160 bool quit_pending_; | 160 bool quit_pending_; |
161 | 161 |
162 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop); | 162 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop); |
163 }; | 163 }; |
164 | 164 |
165 class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase { | 165 class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase { |
166 public: | 166 public: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // thread. Otherwise, returns a new instance of MessagePumpNSRunLoop. | 208 // thread. Otherwise, returns a new instance of MessagePumpNSRunLoop. |
209 static MessagePump* Create(); | 209 static MessagePump* Create(); |
210 | 210 |
211 private: | 211 private: |
212 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); | 212 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); |
213 }; | 213 }; |
214 | 214 |
215 } // namespace base | 215 } // namespace base |
216 | 216 |
217 #endif // BASE_MESSAGE_PUMP_MAC_H_ | 217 #endif // BASE_MESSAGE_PUMP_MAC_H_ |
OLD | NEW |