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

Side by Side Diff: base/message_loop/message_pump_mac.h

Issue 668783004: Standardize usage of virtual/override/final in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatted Created 6 years, 2 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 class AutoreleasePoolType; 75 class AutoreleasePoolType;
76 #else // !defined(__OBJC__) || __has_feature(objc_arc) 76 #else // !defined(__OBJC__) || __has_feature(objc_arc)
77 typedef NSAutoreleasePool AutoreleasePoolType; 77 typedef NSAutoreleasePool AutoreleasePoolType;
78 #endif // !defined(__OBJC__) || __has_feature(objc_arc) 78 #endif // !defined(__OBJC__) || __has_feature(objc_arc)
79 79
80 class MessagePumpCFRunLoopBase : public MessagePump { 80 class MessagePumpCFRunLoopBase : public MessagePump {
81 // Needs access to CreateAutoreleasePool. 81 // Needs access to CreateAutoreleasePool.
82 friend class MessagePumpScopedAutoreleasePool; 82 friend class MessagePumpScopedAutoreleasePool;
83 public: 83 public:
84 MessagePumpCFRunLoopBase(); 84 MessagePumpCFRunLoopBase();
85 virtual ~MessagePumpCFRunLoopBase(); 85 ~MessagePumpCFRunLoopBase() override;
86 86
87 // Subclasses should implement the work they need to do in MessagePump::Run 87 // Subclasses should implement the work they need to do in MessagePump::Run
88 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. 88 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly.
89 // This arrangement is used because MessagePumpCFRunLoopBase needs to set 89 // This arrangement is used because MessagePumpCFRunLoopBase needs to set
90 // up and tear down things before and after the "meat" of DoRun. 90 // up and tear down things before and after the "meat" of DoRun.
91 virtual void Run(Delegate* delegate) override; 91 void Run(Delegate* delegate) override;
92 virtual void DoRun(Delegate* delegate) = 0; 92 virtual void DoRun(Delegate* delegate) = 0;
93 93
94 virtual void ScheduleWork() override; 94 void ScheduleWork() override;
95 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override; 95 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override;
96 virtual void SetTimerSlack(TimerSlack timer_slack) override; 96 void SetTimerSlack(TimerSlack timer_slack) override;
97 97
98 protected: 98 protected:
99 // Accessors for private data members to be used by subclasses. 99 // Accessors for private data members to be used by subclasses.
100 CFRunLoopRef run_loop() const { return run_loop_; } 100 CFRunLoopRef run_loop() const { return run_loop_; }
101 int nesting_level() const { return nesting_level_; } 101 int nesting_level() const { return nesting_level_; }
102 int run_nesting_level() const { return run_nesting_level_; } 102 int run_nesting_level() const { return run_nesting_level_; }
103 103
104 // Sets this pump's delegate. Signals the appropriate sources if 104 // Sets this pump's delegate. Signals the appropriate sources if
105 // |delegateless_work_| is true. |delegate| can be NULL. 105 // |delegateless_work_| is true. |delegate| can be NULL.
106 void SetDelegate(Delegate* delegate); 106 void SetDelegate(Delegate* delegate);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // work on entry and redispatch it as needed once a delegate is available. 213 // work on entry and redispatch it as needed once a delegate is available.
214 bool delegateless_work_; 214 bool delegateless_work_;
215 bool delegateless_idle_work_; 215 bool delegateless_idle_work_;
216 216
217 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase); 217 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase);
218 }; 218 };
219 219
220 class BASE_EXPORT MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase { 220 class BASE_EXPORT MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase {
221 public: 221 public:
222 MessagePumpCFRunLoop(); 222 MessagePumpCFRunLoop();
223 virtual ~MessagePumpCFRunLoop(); 223 ~MessagePumpCFRunLoop() override;
224 224
225 virtual void DoRun(Delegate* delegate) override; 225 void DoRun(Delegate* delegate) override;
226 virtual void Quit() override; 226 void Quit() override;
227 227
228 private: 228 private:
229 virtual void EnterExitRunLoop(CFRunLoopActivity activity) override; 229 void EnterExitRunLoop(CFRunLoopActivity activity) override;
230 230
231 // True if Quit is called to stop the innermost MessagePump 231 // True if Quit is called to stop the innermost MessagePump
232 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_) 232 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_)
233 // is running inside the MessagePump's innermost Run call. 233 // is running inside the MessagePump's innermost Run call.
234 bool quit_pending_; 234 bool quit_pending_;
235 235
236 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop); 236 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop);
237 }; 237 };
238 238
239 class BASE_EXPORT MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase { 239 class BASE_EXPORT MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
240 public: 240 public:
241 MessagePumpNSRunLoop(); 241 MessagePumpNSRunLoop();
242 virtual ~MessagePumpNSRunLoop(); 242 ~MessagePumpNSRunLoop() override;
243 243
244 virtual void DoRun(Delegate* delegate) override; 244 void DoRun(Delegate* delegate) override;
245 virtual void Quit() override; 245 void Quit() override;
246 246
247 private: 247 private:
248 // A source that doesn't do anything but provide something signalable 248 // A source that doesn't do anything but provide something signalable
249 // attached to the run loop. This source will be signalled when Quit 249 // attached to the run loop. This source will be signalled when Quit
250 // is called, to cause the loop to wake up so that it can stop. 250 // is called, to cause the loop to wake up so that it can stop.
251 CFRunLoopSourceRef quit_source_; 251 CFRunLoopSourceRef quit_source_;
252 252
253 // False after Quit is called. 253 // False after Quit is called.
254 bool keep_running_; 254 bool keep_running_;
255 255
(...skipping 19 matching lines...) Expand all
275 RunLoop* run_loop_; 275 RunLoop* run_loop_;
276 276
277 DISALLOW_COPY_AND_ASSIGN(MessagePumpUIApplication); 277 DISALLOW_COPY_AND_ASSIGN(MessagePumpUIApplication);
278 }; 278 };
279 279
280 #else 280 #else
281 281
282 class MessagePumpNSApplication : public MessagePumpCFRunLoopBase { 282 class MessagePumpNSApplication : public MessagePumpCFRunLoopBase {
283 public: 283 public:
284 MessagePumpNSApplication(); 284 MessagePumpNSApplication();
285 virtual ~MessagePumpNSApplication(); 285 ~MessagePumpNSApplication() override;
286 286
287 virtual void DoRun(Delegate* delegate) override; 287 void DoRun(Delegate* delegate) override;
288 virtual void Quit() override; 288 void Quit() override;
289 289
290 private: 290 private:
291 // False after Quit is called. 291 // False after Quit is called.
292 bool keep_running_; 292 bool keep_running_;
293 293
294 // True if DoRun is managing its own run loop as opposed to letting 294 // True if DoRun is managing its own run loop as opposed to letting
295 // -[NSApplication run] handle it. The outermost run loop in the application 295 // -[NSApplication run] handle it. The outermost run loop in the application
296 // is managed by -[NSApplication run], inner run loops are handled by a loop 296 // is managed by -[NSApplication run], inner run loops are handled by a loop
297 // in DoRun. 297 // in DoRun.
298 bool running_own_loop_; 298 bool running_own_loop_;
299 299
300 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication); 300 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication);
301 }; 301 };
302 302
303 class MessagePumpCrApplication : public MessagePumpNSApplication { 303 class MessagePumpCrApplication : public MessagePumpNSApplication {
304 public: 304 public:
305 MessagePumpCrApplication(); 305 MessagePumpCrApplication();
306 virtual ~MessagePumpCrApplication(); 306 ~MessagePumpCrApplication() override;
307 307
308 protected: 308 protected:
309 // Returns nil if NSApp is currently in the middle of calling 309 // Returns nil if NSApp is currently in the middle of calling
310 // -sendEvent. Requires NSApp implementing CrAppProtocol. 310 // -sendEvent. Requires NSApp implementing CrAppProtocol.
311 virtual AutoreleasePoolType* CreateAutoreleasePool() override; 311 AutoreleasePoolType* CreateAutoreleasePool() override;
312 312
313 private: 313 private:
314 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication); 314 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
315 }; 315 };
316 #endif // !defined(OS_IOS) 316 #endif // !defined(OS_IOS)
317 317
318 class BASE_EXPORT MessagePumpMac { 318 class BASE_EXPORT MessagePumpMac {
319 public: 319 public:
320 // If not on the main thread, returns a new instance of 320 // If not on the main thread, returns a new instance of
321 // MessagePumpNSRunLoop. 321 // MessagePumpNSRunLoop.
(...skipping 22 matching lines...) Expand all
344 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); 344 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
345 }; 345 };
346 346
347 // Tasks posted to the message loop are posted under this mode, as well 347 // Tasks posted to the message loop are posted under this mode, as well
348 // as kCFRunLoopCommonModes. 348 // as kCFRunLoopCommonModes.
349 extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode; 349 extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode;
350 350
351 } // namespace base 351 } // namespace base
352 352
353 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ 353 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_libevent_unittest.cc ('k') | base/message_loop/message_pump_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698