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

Side by Side Diff: base/message_pump_mac.h

Issue 8771028: [Mac] Remove content/ CrApplication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NSApp initialization comment. Created 9 years 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 | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop); 225 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop);
226 }; 226 };
227 227
228 class MessagePumpNSApplication : public MessagePumpCFRunLoopBase { 228 class MessagePumpNSApplication : public MessagePumpCFRunLoopBase {
229 public: 229 public:
230 MessagePumpNSApplication(); 230 MessagePumpNSApplication();
231 231
232 virtual void DoRun(Delegate* delegate) OVERRIDE; 232 virtual void DoRun(Delegate* delegate) OVERRIDE;
233 virtual void Quit() OVERRIDE; 233 virtual void Quit() OVERRIDE;
234 234
235 protected:
236 // Returns nil if NSApp is currently in the middle of calling -sendEvent.
237 virtual NSAutoreleasePool* CreateAutoreleasePool() OVERRIDE;
238
239 private: 235 private:
240 // False after Quit is called. 236 // False after Quit is called.
241 bool keep_running_; 237 bool keep_running_;
242 238
243 // True if DoRun is managing its own run loop as opposed to letting 239 // True if DoRun is managing its own run loop as opposed to letting
244 // -[NSApplication run] handle it. The outermost run loop in the application 240 // -[NSApplication run] handle it. The outermost run loop in the application
245 // is managed by -[NSApplication run], inner run loops are handled by a loop 241 // is managed by -[NSApplication run], inner run loops are handled by a loop
246 // in DoRun. 242 // in DoRun.
247 bool running_own_loop_; 243 bool running_own_loop_;
248 244
249 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication); 245 DISALLOW_COPY_AND_ASSIGN(MessagePumpNSApplication);
250 }; 246 };
251 247
248 class MessagePumpCrApplication : public MessagePumpNSApplication {
249 public:
250 MessagePumpCrApplication();
251
252 protected:
253 // Returns nil if NSApp is currently in the middle of calling
254 // -sendEvent. Requires NSApp implementing CrAppProtocol.
255 virtual NSAutoreleasePool* CreateAutoreleasePool() OVERRIDE;
256
257 private:
258 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
259 };
260
252 class MessagePumpMac { 261 class MessagePumpMac {
253 public: 262 public:
254 // Returns a new instance of MessagePumpNSApplication if called on the main 263 // If not on the main thread, returns a new instance of
255 // thread. Otherwise, returns a new instance of MessagePumpNSRunLoop. 264 // MessagePumpNSRunLoop.
265 //
266 // On the main thread, if NSApp exists and conforms to
267 // CrAppProtocol, creates an instances of MessagePumpCrApplication.
268 //
269 // Otherwise creates an instance of MessagePumpNSApplication using a
270 // default NSApplication.
256 static MessagePump* Create(); 271 static MessagePump* Create();
257 272
273 // If a pump is created before the required CrAppProtocol is
274 // created, the wrong MessagePump subclass could be used.
275 // UsingCrApp() returns false if the message pump was created before
276 // NSApp was initialized, or if NSApp does not implement
277 // CrAppProtocol. NSApp must be initialized before calling.
278 static bool UsingCrApp();
279
280 // Wrapper to query -[NSApp isHandlingSendEvent] from C++ code.
281 // Requires NSApp to implement CrAppProtocol.
282 static bool IsHandlingSendEvent();
Scott Hess - ex-Googler 2011/12/02 19:15:25 I'm slightly queasy about adding these static meth
283
258 private: 284 private:
259 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); 285 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
260 }; 286 };
261 287
262 } // namespace base 288 } // namespace base
263 289
264 #endif // BASE_MESSAGE_PUMP_MAC_H_ 290 #endif // BASE_MESSAGE_PUMP_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698