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

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

Issue 279163005: Change the GPU process to use a CFRunLoop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 7 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
« no previous file with comments | « no previous file | content/gpu/gpu_main.cc » ('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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // must wait until a delegate is available to process it. This can happen 212 // must wait until a delegate is available to process it. This can happen
213 // when a MessagePumpCFRunLoopBase is instantiated and work arrives without 213 // when a MessagePumpCFRunLoopBase is instantiated and work arrives without
214 // any call to Run on the stack. The Run method will check for delegateless 214 // any call to Run on the stack. The Run method will check for delegateless
215 // work on entry and redispatch it as needed once a delegate is available. 215 // work on entry and redispatch it as needed once a delegate is available.
216 bool delegateless_work_; 216 bool delegateless_work_;
217 bool delegateless_idle_work_; 217 bool delegateless_idle_work_;
218 218
219 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase); 219 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase);
220 }; 220 };
221 221
222 class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase { 222 class BASE_EXPORT MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase {
223 public: 223 public:
224 MessagePumpCFRunLoop(); 224 MessagePumpCFRunLoop();
225 virtual ~MessagePumpCFRunLoop(); 225 virtual ~MessagePumpCFRunLoop();
226 226
227 virtual void DoRun(Delegate* delegate) OVERRIDE; 227 virtual void DoRun(Delegate* delegate) OVERRIDE;
228 virtual void Quit() OVERRIDE; 228 virtual void Quit() OVERRIDE;
229 229
230 private: 230 private:
231 virtual void EnterExitRunLoop(CFRunLoopActivity activity) OVERRIDE; 231 virtual void EnterExitRunLoop(CFRunLoopActivity activity) OVERRIDE;
232 232
233 // True if Quit is called to stop the innermost MessagePump 233 // True if Quit is called to stop the innermost MessagePump
234 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_) 234 // (innermost_quittable_) but some other CFRunLoopRun loop (nesting_level_)
235 // is running inside the MessagePump's innermost Run call. 235 // is running inside the MessagePump's innermost Run call.
236 bool quit_pending_; 236 bool quit_pending_;
237 237
238 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop); 238 DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop);
239 }; 239 };
240 240
241 class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase { 241 class BASE_EXPORT MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
242 public: 242 public:
243 BASE_EXPORT MessagePumpNSRunLoop(); 243 MessagePumpNSRunLoop();
244 virtual ~MessagePumpNSRunLoop(); 244 virtual ~MessagePumpNSRunLoop();
245 245
246 virtual void DoRun(Delegate* delegate) OVERRIDE; 246 virtual void DoRun(Delegate* delegate) OVERRIDE;
247 virtual void Quit() OVERRIDE; 247 virtual void Quit() OVERRIDE;
248 248
249 private: 249 private:
250 // A source that doesn't do anything but provide something signalable 250 // A source that doesn't do anything but provide something signalable
251 // attached to the run loop. This source will be signalled when Quit 251 // attached to the run loop. This source will be signalled when Quit
252 // is called, to cause the loop to wake up so that it can stop. 252 // is called, to cause the loop to wake up so that it can stop.
253 CFRunLoopSourceRef quit_source_; 253 CFRunLoopSourceRef quit_source_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 protected: 310 protected:
311 // Returns nil if NSApp is currently in the middle of calling 311 // Returns nil if NSApp is currently in the middle of calling
312 // -sendEvent. Requires NSApp implementing CrAppProtocol. 312 // -sendEvent. Requires NSApp implementing CrAppProtocol.
313 virtual AutoreleasePoolType* CreateAutoreleasePool() OVERRIDE; 313 virtual AutoreleasePoolType* CreateAutoreleasePool() OVERRIDE;
314 314
315 private: 315 private:
316 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication); 316 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
317 }; 317 };
318 #endif // !defined(OS_IOS) 318 #endif // !defined(OS_IOS)
319 319
320 class MessagePumpMac { 320 class BASE_EXPORT MessagePumpMac {
321 public: 321 public:
322 // If not on the main thread, returns a new instance of 322 // If not on the main thread, returns a new instance of
323 // MessagePumpNSRunLoop. 323 // MessagePumpNSRunLoop.
324 // 324 //
325 // On the main thread, if NSApp exists and conforms to 325 // On the main thread, if NSApp exists and conforms to
326 // CrAppProtocol, creates an instances of MessagePumpCrApplication. 326 // CrAppProtocol, creates an instances of MessagePumpCrApplication.
327 // 327 //
328 // Otherwise creates an instance of MessagePumpNSApplication using a 328 // Otherwise creates an instance of MessagePumpNSApplication using a
329 // default NSApplication. 329 // default NSApplication.
330 static MessagePump* Create(); 330 static MessagePump* Create();
331 331
332 #if !defined(OS_IOS) 332 #if !defined(OS_IOS)
333 // If a pump is created before the required CrAppProtocol is 333 // If a pump is created before the required CrAppProtocol is
334 // created, the wrong MessagePump subclass could be used. 334 // created, the wrong MessagePump subclass could be used.
335 // UsingCrApp() returns false if the message pump was created before 335 // UsingCrApp() returns false if the message pump was created before
336 // NSApp was initialized, or if NSApp does not implement 336 // NSApp was initialized, or if NSApp does not implement
337 // CrAppProtocol. NSApp must be initialized before calling. 337 // CrAppProtocol. NSApp must be initialized before calling.
338 BASE_EXPORT static bool UsingCrApp(); 338 static bool UsingCrApp();
339 339
340 // Wrapper to query -[NSApp isHandlingSendEvent] from C++ code. 340 // Wrapper to query -[NSApp isHandlingSendEvent] from C++ code.
341 // Requires NSApp to implement CrAppProtocol. 341 // Requires NSApp to implement CrAppProtocol.
342 BASE_EXPORT static bool IsHandlingSendEvent(); 342 static bool IsHandlingSendEvent();
343 #endif // !defined(OS_IOS) 343 #endif // !defined(OS_IOS)
344 344
345 private: 345 private:
346 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); 346 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
347 }; 347 };
348 348
349 } // namespace base 349 } // namespace base
350 350
351 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ 351 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | content/gpu/gpu_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698