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

Unified Diff: base/message_pump_mac.h

Issue 10689161: Adds MessageLoopUIApplication for use on iOS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: base/message_pump_mac.h
diff --git a/base/message_pump_mac.h b/base/message_pump_mac.h
index 3d1ac35914b35eca512b680e5cbb372a2a689bf5..839c1878b217f084cb767f15d5d27436f7a029e1 100644
--- a/base/message_pump_mac.h
+++ b/base/message_pump_mac.h
@@ -38,6 +38,9 @@
#if !defined(__OBJC__)
class NSAutoreleasePool;
#else // !defined(__OBJC__)
+#if defined(OS_IOS)
+#import <Foundation/Foundation.h>
+#else
#import <AppKit/AppKit.h>
// Clients must subclass NSApplication and implement this protocol if they use
@@ -48,10 +51,12 @@ class NSAutoreleasePool;
// necessary.
- (BOOL)isHandlingSendEvent;
@end
+#endif // !defined(OS_IOS)
#endif // !defined(__OBJC__)
namespace base {
+class RunLoop;
class TimeTicks;
class MessagePumpCFRunLoopBase : public MessagePump {
@@ -78,6 +83,10 @@ class MessagePumpCFRunLoopBase : public MessagePump {
int nesting_level() const { return nesting_level_; }
int run_nesting_level() const { return run_nesting_level_; }
+ // Sets this pump's delegate. Signals the appropriate sources if
+ // |delegateless_work_| is true. |delegate| can be NULL.
+ void SetDelegate(Delegate* delegate);
+
// Return an autorelease pool to wrap around any work being performed.
// In some cases, CreateAutoreleasePool may return nil intentionally to
// preventing an autorelease pool from being created, allowing any
@@ -231,6 +240,31 @@ class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
DISALLOW_COPY_AND_ASSIGN(MessagePumpNSRunLoop);
};
+#if defined(OS_IOS)
+// This is a fake message pump. It attaches sources to the main thread's
+// CFRunLoop, so PostTask() will work, but it is unable to drive the loop
+// directly, so calling Run() or Quit() are errors.
+class MessagePumpUIApplication : public MessagePumpCFRunLoopBase {
+ public:
+ MessagePumpUIApplication() { }
+ virtual void DoRun(Delegate* delegate) OVERRIDE;
+ virtual void Quit() OVERRIDE;
+
+ // This message pump can not spin the main message loop directly. Instead,
+ // call |Attach()| to set up a delegate. It is an error to call |Run()|.
+ virtual void Attach(Delegate* delegate);
+
+ protected:
+ virtual ~MessagePumpUIApplication();
+
+ private:
+ base::RunLoop* run_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpUIApplication);
+};
+
+#else
+
class MessagePumpNSApplication : public MessagePumpCFRunLoopBase {
public:
MessagePumpNSApplication();
@@ -268,6 +302,7 @@ class MessagePumpCrApplication : public MessagePumpNSApplication {
private:
DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
};
+#endif // !defined(OS_IOS)
class MessagePumpMac {
public:
@@ -281,6 +316,7 @@ class MessagePumpMac {
// default NSApplication.
static MessagePump* Create();
+#if !defined(OS_IOS)
// If a pump is created before the required CrAppProtocol is
// created, the wrong MessagePump subclass could be used.
// UsingCrApp() returns false if the message pump was created before
@@ -291,6 +327,7 @@ class MessagePumpMac {
// Wrapper to query -[NSApp isHandlingSendEvent] from C++ code.
// Requires NSApp to implement CrAppProtocol.
BASE_EXPORT static bool IsHandlingSendEvent();
+#endif // !defined(OS_IOS)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);

Powered by Google App Engine
This is Rietveld 408576698