Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: base/message_pump_mac.h

Issue 342011: Reset the Mac message pump's delayed work timer upon waking from system sleep (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gyp ('k') | base/message_pump_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
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_PUMP_MAC_H_ 30 #ifndef BASE_MESSAGE_PUMP_MAC_H_
31 #define BASE_MESSAGE_PUMP_MAC_H_ 31 #define BASE_MESSAGE_PUMP_MAC_H_
32 32
33 #include "base/message_pump.h" 33 #include "base/message_pump.h"
34 34
35 #include <CoreFoundation/CoreFoundation.h> 35 #include <CoreFoundation/CoreFoundation.h>
36 #include <IOKit/IOKitLib.h>
36 37
37 namespace base { 38 namespace base {
38 39
39 class Time; 40 class Time;
40 41
41 class MessagePumpCFRunLoopBase : public MessagePump { 42 class MessagePumpCFRunLoopBase : public MessagePump {
42 public: 43 public:
43 MessagePumpCFRunLoopBase(); 44 MessagePumpCFRunLoopBase();
44 virtual ~MessagePumpCFRunLoopBase(); 45 virtual ~MessagePumpCFRunLoopBase();
45 46
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // beginning and end of calls to CFRunLoopRun. This is used to maintain 118 // beginning and end of calls to CFRunLoopRun. This is used to maintain
118 // nesting_level_. Associated with enter_exit_observer_. 119 // nesting_level_. Associated with enter_exit_observer_.
119 static void EnterExitObserver(CFRunLoopObserverRef observer, 120 static void EnterExitObserver(CFRunLoopObserverRef observer,
120 CFRunLoopActivity activity, void* info); 121 CFRunLoopActivity activity, void* info);
121 122
122 // Called by EnterExitObserver after performing maintenance on nesting_level_. 123 // Called by EnterExitObserver after performing maintenance on nesting_level_.
123 // This allows subclasses an opportunity to perform additional processing on 124 // This allows subclasses an opportunity to perform additional processing on
124 // the basis of run loops starting and stopping. 125 // the basis of run loops starting and stopping.
125 virtual void EnterExitRunLoop(CFRunLoopActivity activity); 126 virtual void EnterExitRunLoop(CFRunLoopActivity activity);
126 127
128 // IOKit power state change notification callback, called when the system
129 // enters and leaves the sleep state.
130 static void PowerStateNotification(void* info, io_service_t service,
131 uint32_t message_type,
132 void* message_argument);
133
127 // The thread's run loop. 134 // The thread's run loop.
128 CFRunLoopRef run_loop_; 135 CFRunLoopRef run_loop_;
129 136
130 // The timer, sources, and observers are described above alongside their 137 // The timer, sources, and observers are described above alongside their
131 // callbacks. 138 // callbacks.
132 CFRunLoopTimerRef delayed_work_timer_; 139 CFRunLoopTimerRef delayed_work_timer_;
133 CFRunLoopSourceRef work_source_; 140 CFRunLoopSourceRef work_source_;
134 CFRunLoopSourceRef delayed_work_source_; 141 CFRunLoopSourceRef delayed_work_source_;
135 CFRunLoopSourceRef idle_work_source_; 142 CFRunLoopSourceRef idle_work_source_;
136 CFRunLoopSourceRef nesting_deferred_work_source_; 143 CFRunLoopSourceRef nesting_deferred_work_source_;
137 CFRunLoopObserverRef pre_wait_observer_; 144 CFRunLoopObserverRef pre_wait_observer_;
138 CFRunLoopObserverRef pre_source_observer_; 145 CFRunLoopObserverRef pre_source_observer_;
139 CFRunLoopObserverRef enter_exit_observer_; 146 CFRunLoopObserverRef enter_exit_observer_;
140 147
148 // Objects used for power state notification. See PowerStateNotification.
149 io_connect_t root_power_domain_;
150 IONotificationPortRef power_notification_port_;
151 io_object_t power_notification_object_;
152
141 // (weak) Delegate passed as an argument to the innermost Run call. 153 // (weak) Delegate passed as an argument to the innermost Run call.
142 Delegate* delegate_; 154 Delegate* delegate_;
143 155
156 // The time that delayed_work_timer_ is scheduled to fire. This is tracked
157 // independently of CFRunLoopTimerGetNextFireDate(delayed_work_timer_)
158 // to be able to reset the timer properly after waking from system sleep.
159 // See PowerStateNotification.
160 CFAbsoluteTime delayed_work_fire_time_;
161
144 // The recursion depth of the currently-executing CFRunLoopRun loop on the 162 // The recursion depth of the currently-executing CFRunLoopRun loop on the
145 // run loop's thread. 0 if no run loops are running inside of whatever scope 163 // run loop's thread. 0 if no run loops are running inside of whatever scope
146 // the object was created in. 164 // the object was created in.
147 int nesting_level_; 165 int nesting_level_;
148 166
149 // The recursion depth (calculated in the same way as nesting_level_) of the 167 // The recursion depth (calculated in the same way as nesting_level_) of the
150 // innermost executing CFRunLoopRun loop started by a call to Run. 168 // innermost executing CFRunLoopRun loop started by a call to Run.
151 int run_nesting_level_; 169 int run_nesting_level_;
152 170
153 // The deepest (numerically highest) recursion depth encountered since the 171 // The deepest (numerically highest) recursion depth encountered since the
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // thread. Otherwise, returns a new instance of MessagePumpNSRunLoop. 248 // thread. Otherwise, returns a new instance of MessagePumpNSRunLoop.
231 static MessagePump* Create(); 249 static MessagePump* Create();
232 250
233 private: 251 private:
234 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); 252 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
235 }; 253 };
236 254
237 } // namespace base 255 } // namespace base
238 256
239 #endif // BASE_MESSAGE_PUMP_MAC_H_ 257 #endif // BASE_MESSAGE_PUMP_MAC_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698