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

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

Issue 614103004: replace 'virtual ... OVERRIDE' with '... override' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process base/ 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual ~MessagePumpCFRunLoopBase();
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual ~MessagePumpCFRunLoop();
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 virtual ~MessagePumpNSRunLoop();
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
256 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop); 256 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop);
257 }; 257 };
258 258
259 #if defined(OS_IOS) 259 #if defined(OS_IOS)
260 // This is a fake message pump. It attaches sources to the main thread's 260 // This is a fake message pump. It attaches sources to the main thread's
261 // CFRunLoop, so PostTask() will work, but it is unable to drive the loop 261 // CFRunLoop, so PostTask() will work, but it is unable to drive the loop
262 // directly, so calling Run() or Quit() are errors. 262 // directly, so calling Run() or Quit() are errors.
263 class MessagePumpUIApplication : public MessagePumpCFRunLoopBase { 263 class MessagePumpUIApplication : public MessagePumpCFRunLoopBase {
264 public: 264 public:
265 MessagePumpUIApplication(); 265 MessagePumpUIApplication();
266 virtual ~MessagePumpUIApplication(); 266 virtual ~MessagePumpUIApplication();
267 virtual void DoRun(Delegate* delegate) OVERRIDE; 267 void DoRun(Delegate* delegate) override;
268 virtual void Quit() OVERRIDE; 268 void Quit() override;
269 269
270 // This message pump can not spin the main message loop directly. Instead, 270 // This message pump can not spin the main message loop directly. Instead,
271 // call |Attach()| to set up a delegate. It is an error to call |Run()|. 271 // call |Attach()| to set up a delegate. It is an error to call |Run()|.
272 virtual void Attach(Delegate* delegate); 272 virtual void Attach(Delegate* delegate);
273 273
274 private: 274 private:
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 virtual ~MessagePumpNSApplication();
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 virtual ~MessagePumpCrApplication();
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

Powered by Google App Engine
This is Rietveld 408576698