summaryrefslogtreecommitdiffstats
path: root/base/message_pump_mac.mm
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.mm
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.mm')
-rw-r--r--base/message_pump_mac.mm87
1 files changed, 62 insertions, 25 deletions
diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm
index 6f0b1b2..3878eb8 100644
--- a/base/message_pump_mac.mm
+++ b/base/message_pump_mac.mm
@@ -4,14 +4,18 @@
#import "base/message_pump_mac.h"
-#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#include <limits>
#include "base/logging.h"
+#include "base/run_loop.h"
#include "base/time.h"
+#if !defined(OS_IOS)
+#import <AppKit/AppKit.h>
+#endif // !defined(OS_IOS)
+
namespace {
void NoOp(void* info) {
@@ -160,6 +164,16 @@ void MessagePumpCFRunLoopBase::Run(Delegate* delegate) {
run_nesting_level_ = nesting_level_ + 1;
Delegate* last_delegate = delegate_;
+ SetDelegate(delegate);
+
+ DoRun(delegate);
+
+ // Restore the previous state of the object.
+ SetDelegate(last_delegate);
+ run_nesting_level_ = last_run_nesting_level;
+}
+
+void MessagePumpCFRunLoopBase::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
if (delegate) {
@@ -175,12 +189,6 @@ void MessagePumpCFRunLoopBase::Run(Delegate* delegate) {
delegateless_idle_work_ = false;
}
}
-
- DoRun(delegate);
-
- // Restore the previous state of the object.
- delegate_ = last_delegate;
- run_nesting_level_ = last_run_nesting_level;
}
// May be called on any thread.
@@ -519,6 +527,30 @@ void MessagePumpNSRunLoop::Quit() {
CFRunLoopWakeUp(run_loop());
}
+#if defined(OS_IOS)
+MessagePumpUIApplication::MessagePumpUIApplication()
+ : run_loop_(NULL) {
+}
+
+MessagePumpUIApplication::~MessagePumpUIApplication() {}
+
+void MessagePumpUIApplication::DoRun(Delegate* delegate) {
+ NOTREACHED();
+}
+
+void MessagePumpUIApplication::Quit() {
+ NOTREACHED();
+}
+
+void MessagePumpUIApplication::Attach(Delegate* delegate) {
+ DCHECK(!run_loop_);
+ run_loop_ = new base::RunLoop();
+ CHECK(run_loop_->BeforeRun());
+ SetDelegate(delegate);
+}
+
+#else
+
MessagePumpNSApplication::MessagePumpNSApplication()
: keep_running_(true),
running_own_loop_(false) {
@@ -620,24 +652,6 @@ NSAutoreleasePool* MessagePumpCrApplication::CreateAutoreleasePool() {
}
// static
-MessagePump* MessagePumpMac::Create() {
- if ([NSThread isMainThread]) {
- if ([NSApp conformsToProtocol:@protocol(CrAppProtocol)])
- return new MessagePumpCrApplication;
-
- // The main-thread MessagePump implementations REQUIRE an NSApp.
- // Executables which have specific requirements for their
- // NSApplication subclass should initialize appropriately before
- // creating an event loop.
- [NSApplication sharedApplication];
- not_using_crapp = true;
- return new MessagePumpNSApplication;
- }
-
- return new MessagePumpNSRunLoop;
-}
-
-// static
bool MessagePumpMac::UsingCrApp() {
DCHECK([NSThread isMainThread]);
@@ -658,5 +672,28 @@ bool MessagePumpMac::IsHandlingSendEvent() {
NSObject<CrAppProtocol>* app = static_cast<NSObject<CrAppProtocol>*>(NSApp);
return [app isHandlingSendEvent];
}
+#endif // !defined(OS_IOS)
+
+// static
+MessagePump* MessagePumpMac::Create() {
+ if ([NSThread isMainThread]) {
+#if defined(OS_IOS)
+ return new MessagePumpUIApplication;
+#else
+ if ([NSApp conformsToProtocol:@protocol(CrAppProtocol)])
+ return new MessagePumpCrApplication;
+
+ // The main-thread MessagePump implementations REQUIRE an NSApp.
+ // Executables which have specific requirements for their
+ // NSApplication subclass should initialize appropriately before
+ // creating an event loop.
+ [NSApplication sharedApplication];
+ not_using_crapp = true;
+ return new MessagePumpNSApplication;
+#endif
+ }
+
+ return new MessagePumpNSRunLoop;
+}
} // namespace base