| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // AutoreleasePoolType* instead. | 74 // AutoreleasePoolType* instead. |
| 75 #if !defined(__OBJC__) || __has_feature(objc_arc) | 75 #if !defined(__OBJC__) || __has_feature(objc_arc) |
| 76 class AutoreleasePoolType; | 76 class AutoreleasePoolType; |
| 77 #else // !defined(__OBJC__) || __has_feature(objc_arc) | 77 #else // !defined(__OBJC__) || __has_feature(objc_arc) |
| 78 typedef NSAutoreleasePool AutoreleasePoolType; | 78 typedef NSAutoreleasePool AutoreleasePoolType; |
| 79 #endif // !defined(__OBJC__) || __has_feature(objc_arc) | 79 #endif // !defined(__OBJC__) || __has_feature(objc_arc) |
| 80 | 80 |
| 81 class MessagePumpCFRunLoopBase : public MessagePump { | 81 class MessagePumpCFRunLoopBase : public MessagePump { |
| 82 // Needs access to CreateAutoreleasePool. | 82 // Needs access to CreateAutoreleasePool. |
| 83 friend class MessagePumpScopedAutoreleasePool; | 83 friend class MessagePumpScopedAutoreleasePool; |
| 84 friend class TestMessagePumpCFRunLoopBase; |
| 85 |
| 84 public: | 86 public: |
| 85 MessagePumpCFRunLoopBase(); | 87 MessagePumpCFRunLoopBase(); |
| 86 ~MessagePumpCFRunLoopBase() override; | 88 ~MessagePumpCFRunLoopBase() override; |
| 87 | 89 |
| 88 // Subclasses should implement the work they need to do in MessagePump::Run | 90 // Subclasses should implement the work they need to do in MessagePump::Run |
| 89 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. | 91 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. |
| 90 // This arrangement is used because MessagePumpCFRunLoopBase needs to set | 92 // This arrangement is used because MessagePumpCFRunLoopBase needs to set |
| 91 // up and tear down things before and after the "meat" of DoRun. | 93 // up and tear down things before and after the "meat" of DoRun. |
| 92 void Run(Delegate* delegate) override; | 94 void Run(Delegate* delegate) override; |
| 93 virtual void DoRun(Delegate* delegate) = 0; | 95 virtual void DoRun(Delegate* delegate) = 0; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 Delegate* delegate_; | 189 Delegate* delegate_; |
| 188 | 190 |
| 189 // The time that delayed_work_timer_ is scheduled to fire. This is tracked | 191 // The time that delayed_work_timer_ is scheduled to fire. This is tracked |
| 190 // independently of CFRunLoopTimerGetNextFireDate(delayed_work_timer_) | 192 // independently of CFRunLoopTimerGetNextFireDate(delayed_work_timer_) |
| 191 // to be able to reset the timer properly after waking from system sleep. | 193 // to be able to reset the timer properly after waking from system sleep. |
| 192 // See PowerStateNotification. | 194 // See PowerStateNotification. |
| 193 CFAbsoluteTime delayed_work_fire_time_; | 195 CFAbsoluteTime delayed_work_fire_time_; |
| 194 | 196 |
| 195 base::TimerSlack timer_slack_; | 197 base::TimerSlack timer_slack_; |
| 196 | 198 |
| 199 // True if private API for validating/invalidating CFRunLoopTimers is |
| 200 // available for use. |
| 201 bool can_invalidate_timers_; |
| 202 |
| 197 // The recursion depth of the currently-executing CFRunLoopRun loop on the | 203 // The recursion depth of the currently-executing CFRunLoopRun loop on the |
| 198 // run loop's thread. 0 if no run loops are running inside of whatever scope | 204 // run loop's thread. 0 if no run loops are running inside of whatever scope |
| 199 // the object was created in. | 205 // the object was created in. |
| 200 int nesting_level_; | 206 int nesting_level_; |
| 201 | 207 |
| 202 // The recursion depth (calculated in the same way as nesting_level_) of the | 208 // The recursion depth (calculated in the same way as nesting_level_) of the |
| 203 // innermost executing CFRunLoopRun loop started by a call to Run. | 209 // innermost executing CFRunLoopRun loop started by a call to Run. |
| 204 int run_nesting_level_; | 210 int run_nesting_level_; |
| 205 | 211 |
| 206 // The deepest (numerically highest) recursion depth encountered since the | 212 // The deepest (numerically highest) recursion depth encountered since the |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); | 351 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); |
| 346 }; | 352 }; |
| 347 | 353 |
| 348 // Tasks posted to the message loop are posted under this mode, as well | 354 // Tasks posted to the message loop are posted under this mode, as well |
| 349 // as kCFRunLoopCommonModes. | 355 // as kCFRunLoopCommonModes. |
| 350 extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode; | 356 extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode; |
| 351 | 357 |
| 352 } // namespace base | 358 } // namespace base |
| 353 | 359 |
| 354 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 360 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
| OLD | NEW |