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

Side by Side Diff: base/message_pump_mac.h

Issue 9997007: Objects that derive from RefCounted/RefCountedThreadSafe should not have public dtors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: virtual & DISALLOW Created 8 years, 8 months 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/message_pump_libevent.h ('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) 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 namespace base { 53 namespace base {
54 54
55 class TimeTicks; 55 class TimeTicks;
56 56
57 class MessagePumpCFRunLoopBase : public MessagePump { 57 class MessagePumpCFRunLoopBase : public MessagePump {
58 // Needs access to CreateAutoreleasePool. 58 // Needs access to CreateAutoreleasePool.
59 friend class MessagePumpScopedAutoreleasePool; 59 friend class MessagePumpScopedAutoreleasePool;
60 public: 60 public:
61 MessagePumpCFRunLoopBase(); 61 MessagePumpCFRunLoopBase();
62 virtual ~MessagePumpCFRunLoopBase();
63 62
64 // Subclasses should implement the work they need to do in MessagePump::Run 63 // Subclasses should implement the work they need to do in MessagePump::Run
65 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. 64 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly.
66 // This arrangement is used because MessagePumpCFRunLoopBase needs to set 65 // This arrangement is used because MessagePumpCFRunLoopBase needs to set
67 // up and tear down things before and after the "meat" of DoRun. 66 // up and tear down things before and after the "meat" of DoRun.
68 virtual void Run(Delegate* delegate) OVERRIDE; 67 virtual void Run(Delegate* delegate) OVERRIDE;
69 virtual void DoRun(Delegate* delegate) = 0; 68 virtual void DoRun(Delegate* delegate) = 0;
70 69
71 virtual void ScheduleWork() OVERRIDE; 70 virtual void ScheduleWork() OVERRIDE;
72 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE; 71 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
73 72
74 protected: 73 protected:
74 virtual ~MessagePumpCFRunLoopBase();
75
75 // Accessors for private data members to be used by subclasses. 76 // Accessors for private data members to be used by subclasses.
76 CFRunLoopRef run_loop() const { return run_loop_; } 77 CFRunLoopRef run_loop() const { return run_loop_; }
77 int nesting_level() const { return nesting_level_; } 78 int nesting_level() const { return nesting_level_; }
78 int run_nesting_level() const { return run_nesting_level_; } 79 int run_nesting_level() const { return run_nesting_level_; }
79 80
80 // Return an autorelease pool to wrap around any work being performed. 81 // Return an autorelease pool to wrap around any work being performed.
81 // In some cases, CreateAutoreleasePool may return nil intentionally to 82 // In some cases, CreateAutoreleasePool may return nil intentionally to
82 // preventing an autorelease pool from being created, allowing any 83 // preventing an autorelease pool from being created, allowing any
83 // objects autoreleased by work to fall into the current autorelease pool. 84 // objects autoreleased by work to fall into the current autorelease pool.
84 virtual NSAutoreleasePool* CreateAutoreleasePool(); 85 virtual NSAutoreleasePool* CreateAutoreleasePool();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase); 188 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase);
188 }; 189 };
189 190
190 class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase { 191 class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase {
191 public: 192 public:
192 MessagePumpCFRunLoop(); 193 MessagePumpCFRunLoop();
193 194
194 virtual void DoRun(Delegate* delegate) OVERRIDE; 195 virtual void DoRun(Delegate* delegate) OVERRIDE;
195 virtual void Quit() OVERRIDE; 196 virtual void Quit() OVERRIDE;
196 197
198 protected:
199 virtual ~MessagePumpCFRunLoop();
200
197 private: 201 private:
198 virtual void EnterExitRunLoop(CFRunLoopActivity activity) OVERRIDE; 202 virtual void EnterExitRunLoop(CFRunLoopActivity activity) OVERRIDE;
199 203
200 // True if Quit is called to stop the innermost MessagePump 204 // True if Quit is called to stop the innermost MessagePump
201 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_) 205 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_)
202 // is running inside the MessagePump's innermost Run call. 206 // is running inside the MessagePump's innermost Run call.
203 bool quit_pending_; 207 bool quit_pending_;
204 208
205 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop); 209 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop);
206 }; 210 };
207 211
208 class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase { 212 class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
209 public: 213 public:
210 BASE_EXPORT MessagePumpNSRunLoop(); 214 BASE_EXPORT MessagePumpNSRunLoop();
211 virtual ~MessagePumpNSRunLoop();
212 215
213 virtual void DoRun(Delegate* delegate) OVERRIDE; 216 virtual void DoRun(Delegate* delegate) OVERRIDE;
214 virtual void Quit() OVERRIDE; 217 virtual void Quit() OVERRIDE;
215 218
219 protected:
220 virtual ~MessagePumpNSRunLoop();
221
216 private: 222 private:
217 // A source that doesn't do anything but provide something signalable 223 // A source that doesn't do anything but provide something signalable
218 // attached to the run loop. This source will be signalled when Quit 224 // attached to the run loop. This source will be signalled when Quit
219 // is called, to cause the loop to wake up so that it can stop. 225 // is called, to cause the loop to wake up so that it can stop.
220 CFRunLoopSourceRef quit_source_; 226 CFRunLoopSourceRef quit_source_;
221 227
222 // False after Quit is called. 228 // False after Quit is called.
223 bool keep_running_; 229 bool keep_running_;
224 230
225 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop); 231 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop);
226 }; 232 };
227 233
228 class MessagePumpNSApplication : public MessagePumpCFRunLoopBase { 234 class MessagePumpNSApplication : public MessagePumpCFRunLoopBase {
229 public: 235 public:
230 MessagePumpNSApplication(); 236 MessagePumpNSApplication();
231 237
232 virtual void DoRun(Delegate* delegate) OVERRIDE; 238 virtual void DoRun(Delegate* delegate) OVERRIDE;
233 virtual void Quit() OVERRIDE; 239 virtual void Quit() OVERRIDE;
234 240
241 protected:
242 virtual ~MessagePumpNSApplication();
243
235 private: 244 private:
236 // False after Quit is called. 245 // False after Quit is called.
237 bool keep_running_; 246 bool keep_running_;
238 247
239 // True if DoRun is managing its own run loop as opposed to letting 248 // True if DoRun is managing its own run loop as opposed to letting
240 // -[NSApplication run] handle it. The outermost run loop in the application 249 // -[NSApplication run] handle it. The outermost run loop in the application
241 // is managed by -[NSApplication run], inner run loops are handled by a loop 250 // is managed by -[NSApplication run], inner run loops are handled by a loop
242 // in DoRun. 251 // in DoRun.
243 bool running_own_loop_; 252 bool running_own_loop_;
244 253
245 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication); 254 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication);
246 }; 255 };
247 256
248 class MessagePumpCrApplication : public MessagePumpNSApplication { 257 class MessagePumpCrApplication : public MessagePumpNSApplication {
249 public: 258 public:
250 MessagePumpCrApplication(); 259 MessagePumpCrApplication();
251 260
252 protected: 261 protected:
262 virtual ~MessagePumpCrApplication() {}
263
253 // Returns nil if NSApp is currently in the middle of calling 264 // Returns nil if NSApp is currently in the middle of calling
254 // -sendEvent. Requires NSApp implementing CrAppProtocol. 265 // -sendEvent. Requires NSApp implementing CrAppProtocol.
255 virtual NSAutoreleasePool* CreateAutoreleasePool() OVERRIDE; 266 virtual NSAutoreleasePool* CreateAutoreleasePool() OVERRIDE;
256 267
257 private: 268 private:
258 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication); 269 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
259 }; 270 };
260 271
261 class MessagePumpMac { 272 class MessagePumpMac {
262 public: 273 public:
(...skipping 18 matching lines...) Expand all
281 // Requires NSApp to implement CrAppProtocol. 292 // Requires NSApp to implement CrAppProtocol.
282 BASE_EXPORT static bool IsHandlingSendEvent(); 293 BASE_EXPORT static bool IsHandlingSendEvent();
283 294
284 private: 295 private:
285 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); 296 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
286 }; 297 };
287 298
288 } // namespace base 299 } // namespace base
289 300
290 #endif // BASE_MESSAGE_PUMP_MAC_H_ 301 #endif // BASE_MESSAGE_PUMP_MAC_H_
OLDNEW
« no previous file with comments | « base/message_pump_libevent.h ('k') | base/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698