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

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: ^ and $. 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
« no previous file with comments | « base/message_loop.cc ('k') | base/message_pump_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_mac.h
diff --git a/base/message_pump_mac.h b/base/message_pump_mac.h
index 78af7095bd053afc54e7fd08088d067c994bc674..2dd5ecf568823b6f5b9ded88b6d8b0c2bb2248a0 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);
« no previous file with comments | « base/message_loop.cc ('k') | base/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698