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 // 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 14 matching lines...) Expand all Loading... |
25 // any other thread, one of the other concrete subclasses is preferrable. | 25 // any other thread, one of the other concrete subclasses is preferrable. |
26 // MessagePumpMac::Create is defined, which returns a new NSApplication-based | 26 // MessagePumpMac::Create is defined, which returns a new NSApplication-based |
27 // or NSRunLoop-based MessagePump subclass depending on which thread it is | 27 // or NSRunLoop-based MessagePump subclass depending on which thread it is |
28 // called on. | 28 // called on. |
29 | 29 |
30 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 30 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
31 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 31 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
32 | 32 |
33 #include "base/message_loop/message_pump.h" | 33 #include "base/message_loop/message_pump.h" |
34 | 34 |
| 35 #include <CoreFoundation/CoreFoundation.h> |
| 36 #include <stack> |
| 37 |
35 #include "base/basictypes.h" | 38 #include "base/basictypes.h" |
36 | 39 |
37 #include <CoreFoundation/CoreFoundation.h> | |
38 | |
39 #if !defined(__OBJC__) | 40 #if !defined(__OBJC__) |
40 class NSAutoreleasePool; | 41 class NSAutoreleasePool; |
41 #else // !defined(__OBJC__) | 42 #else // !defined(__OBJC__) |
42 #if defined(OS_IOS) | 43 #if defined(OS_IOS) |
43 #import <Foundation/Foundation.h> | 44 #import <Foundation/Foundation.h> |
44 #else | 45 #else |
45 #import <AppKit/AppKit.h> | 46 #import <AppKit/AppKit.h> |
46 | 47 |
47 // Clients must subclass NSApplication and implement this protocol if they use | 48 // Clients must subclass NSApplication and implement this protocol if they use |
48 // MessagePumpMac. | 49 // MessagePumpMac. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // independently of CFRunLoopTimerGetNextFireDate(delayed_work_timer_) | 172 // independently of CFRunLoopTimerGetNextFireDate(delayed_work_timer_) |
172 // to be able to reset the timer properly after waking from system sleep. | 173 // to be able to reset the timer properly after waking from system sleep. |
173 // See PowerStateNotification. | 174 // See PowerStateNotification. |
174 CFAbsoluteTime delayed_work_fire_time_; | 175 CFAbsoluteTime delayed_work_fire_time_; |
175 | 176 |
176 // The recursion depth of the currently-executing CFRunLoopRun loop on the | 177 // The recursion depth of the currently-executing CFRunLoopRun loop on the |
177 // run loop's thread. 0 if no run loops are running inside of whatever scope | 178 // run loop's thread. 0 if no run loops are running inside of whatever scope |
178 // the object was created in. | 179 // the object was created in. |
179 int nesting_level_; | 180 int nesting_level_; |
180 | 181 |
| 182 std::stack<uint32> nesting_stack_; |
| 183 |
181 // The recursion depth (calculated in the same way as nesting_level_) of the | 184 // The recursion depth (calculated in the same way as nesting_level_) of the |
182 // innermost executing CFRunLoopRun loop started by a call to Run. | 185 // innermost executing CFRunLoopRun loop started by a call to Run. |
183 int run_nesting_level_; | 186 int run_nesting_level_; |
184 | 187 |
185 // The deepest (numerically highest) recursion depth encountered since the | 188 // The deepest (numerically highest) recursion depth encountered since the |
186 // most recent attempt to run nesting-deferred work. | 189 // most recent attempt to run nesting-deferred work. |
187 int deepest_nesting_level_; | 190 int deepest_nesting_level_; |
188 | 191 |
189 // "Delegateless" work flags are set when work is ready to be performed but | 192 // "Delegateless" work flags are set when work is ready to be performed but |
190 // must wait until a delegate is available to process it. This can happen | 193 // must wait until a delegate is available to process it. This can happen |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 BASE_EXPORT static bool IsHandlingSendEvent(); | 323 BASE_EXPORT static bool IsHandlingSendEvent(); |
321 #endif // !defined(OS_IOS) | 324 #endif // !defined(OS_IOS) |
322 | 325 |
323 private: | 326 private: |
324 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); | 327 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); |
325 }; | 328 }; |
326 | 329 |
327 } // namespace base | 330 } // namespace base |
328 | 331 |
329 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 332 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
OLD | NEW |