summaryrefslogtreecommitdiffstats
path: root/base/message_pump_mac.h
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 11:02:57 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 11:02:57 +0000
commitfeb727e9f96d54ad1d079c5d638707f6f31c98c6 (patch)
treee5b95a21f44ee1968aa319141e914364f5f47f1f /base/message_pump_mac.h
parent5b317bc1cd0f78ed354ce009ef8ab870cfd54667 (diff)
downloadchromium_src-feb727e9f96d54ad1d079c5d638707f6f31c98c6.zip
chromium_src-feb727e9f96d54ad1d079c5d638707f6f31c98c6.tar.gz
chromium_src-feb727e9f96d54ad1d079c5d638707f6f31c98c6.tar.bz2
Adds MessageLoopUIApplication for use on iOS.
BUG=None TEST=None Review URL: https://chromiumcodereview.appspot.com/10689161 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146553 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_mac.h')
-rw-r--r--base/message_pump_mac.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/base/message_pump_mac.h b/base/message_pump_mac.h
index 78af709..2dd5ecf 100644
--- a/base/message_pump_mac.h
+++ b/base/message_pump_mac.h
@@ -37,6 +37,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
@@ -47,10 +50,12 @@ class NSAutoreleasePool;
// necessary.
- (BOOL)isHandlingSendEvent;
@end
+#endif // !defined(OS_IOS)
#endif // !defined(__OBJC__)
namespace base {
+class RunLoop;
class TimeTicks;
class MessagePumpCFRunLoopBase : public MessagePump {
@@ -77,6 +82,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
@@ -230,6 +239,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();
@@ -267,6 +301,7 @@ class MessagePumpCrApplication : public MessagePumpNSApplication {
private:
DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
};
+#endif // !defined(OS_IOS)
class MessagePumpMac {
public:
@@ -280,6 +315,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
@@ -290,6 +326,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);