summaryrefslogtreecommitdiffstats
path: root/base/message_pump_mac.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 19:57:38 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 19:57:38 +0000
commitc83275bc64275a557a97b1cfda469c1227c6c503 (patch)
treed9278b77667fdeb1cf099eb1cf4c24cce16e6dca /base/message_pump_mac.mm
parent2c02986320e4de786b306499b6f2c64751f54d04 (diff)
downloadchromium_src-c83275bc64275a557a97b1cfda469c1227c6c503.zip
chromium_src-c83275bc64275a557a97b1cfda469c1227c6c503.tar.gz
chromium_src-c83275bc64275a557a97b1cfda469c1227c6c503.tar.bz2
When work shows up and no delegate is available to dispatch it to, arrange to
dispatch to the delegate when one becomes available. BUG=16732 TEST=rm ~/Library/Preferences/com.google.Chrome.plist, launch official-branding Google Chrome, dismiss first-run dialog. The application should be usable. Review URL: http://codereview.chromium.org/149687 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_mac.mm')
-rw-r--r--base/message_pump_mac.mm41
1 files changed, 28 insertions, 13 deletions
diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm
index 3f94dc1..c9a0ea6 100644
--- a/base/message_pump_mac.mm
+++ b/base/message_pump_mac.mm
@@ -23,7 +23,10 @@ namespace base {
// Must be called on the run loop thread.
MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase()
: nesting_level_(0),
- delegate_(NULL)
+ delegate_(NULL),
+ delegateless_work_(false),
+ delegateless_delayed_work_(false),
+ delegateless_idle_work_(false)
{
run_loop_ = CFRunLoopGetCurrent();
CFRetain(run_loop_);
@@ -125,6 +128,21 @@ void MessagePumpCFRunLoopBase::Run(Delegate* delegate) {
Delegate* last_delegate = delegate_;
delegate_ = delegate;
+ // If any work showed up but could not be dispatched for want of a delegate,
+ // set it up for dispatch again now that a delegate is available.
+ if (delegateless_work_) {
+ CFRunLoopSourceSignal(work_source_);
+ delegateless_work_ = false;
+ }
+ if (delegateless_delayed_work_) {
+ CFRunLoopSourceSignal(delayed_work_source_);
+ delegateless_delayed_work_ = false;
+ }
+ if (delegateless_idle_work_) {
+ CFRunLoopSourceSignal(idle_work_source_);
+ delegateless_idle_work_ = false;
+ }
+
DoRun(delegate);
delegate_ = last_delegate;
@@ -183,16 +201,9 @@ void MessagePumpCFRunLoopBase::RunWorkSource(void* info) {
bool MessagePumpCFRunLoopBase::RunWork() {
if (!delegate_) {
// This point can be reached with a NULL delegate_ if Run is not on the
- // stack but foreign code is spinning the CFRunLoop.
-
- // TODO(???): we get here while looping in our temporary 1st run
- // dialog. If we simply return false, we choke rather brutally
- // (we no longer do work ever again). For now, we simply
- // re-signal ourself so we come around again. The problem only
- // happens in a branded build if
- // ~/Library/Preferences/com.google.Chrome.plist does not exist.
- CFRunLoopSourceSignal(work_source_);
-
+ // stack but foreign code is spinning the CFRunLoop. Arrange to come back
+ // here when a delegate is available.
+ delegateless_work_ = true;
return false;
}
@@ -222,7 +233,9 @@ void MessagePumpCFRunLoopBase::RunDelayedWorkSource(void* info) {
bool MessagePumpCFRunLoopBase::RunDelayedWork() {
if (!delegate_) {
// This point can be reached with a NULL delegate_ if Run is not on the
- // stack but foreign code is spinning the CFRunLoop.
+ // stack but foreign code is spinning the CFRunLoop. Arrange to come back
+ // here when a delegate is available.
+ delegateless_delayed_work_ = true;
return false;
}
@@ -262,7 +275,9 @@ void MessagePumpCFRunLoopBase::RunIdleWorkSource(void* info) {
bool MessagePumpCFRunLoopBase::RunIdleWork() {
if (!delegate_) {
// This point can be reached with a NULL delegate_ if Run is not on the
- // stack but foreign code is spinning the CFRunLoop.
+ // stack but foreign code is spinning the CFRunLoop. Arrange to come back
+ // here when a delegate is available.
+ delegateless_idle_work_ = true;
return false;
}