| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/message_pump_mac.h" | 5 #include "base/message_pump_mac.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 #include <float.h> | 9 #include <float.h> |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 void MessagePumpCFRunLoopBase::RunWorkSource(void* info) { | 177 void MessagePumpCFRunLoopBase::RunWorkSource(void* info) { |
| 178 MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info); | 178 MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info); |
| 179 self->RunWork(); | 179 self->RunWork(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // Called by MessagePumpCFRunLoopBase::RunWorkSource. | 182 // Called by MessagePumpCFRunLoopBase::RunWorkSource. |
| 183 bool MessagePumpCFRunLoopBase::RunWork() { | 183 bool MessagePumpCFRunLoopBase::RunWork() { |
| 184 if (!delegate_) { | 184 if (!delegate_) { |
| 185 // This point can be reached with a NULL delegate_ if Run is not on the | 185 // This point can be reached with a NULL delegate_ if Run is not on the |
| 186 // stack but foreign code is spinning the CFRunLoop. | 186 // stack but foreign code is spinning the CFRunLoop. |
| 187 |
| 188 // TODO(???): we get here while looping in our temporary 1st run |
| 189 // dialog. If we simply return false, we choke rather brutally |
| 190 // (we no longer do work ever again). For now, we simply |
| 191 // re-signal ourself so we come around again. The problem only |
| 192 // happens in a branded build if |
| 193 // ~/Library/Preferences/com.google.Chrome.plist does not exist. |
| 194 CFRunLoopSourceSignal(work_source_); |
| 195 |
| 187 return false; | 196 return false; |
| 188 } | 197 } |
| 189 | 198 |
| 190 // If we're on the main event loop, the NSApp runloop won't clean up the | 199 // If we're on the main event loop, the NSApp runloop won't clean up the |
| 191 // autorelease pool until there is a UI event, so use a local one for any | 200 // autorelease pool until there is a UI event, so use a local one for any |
| 192 // autoreleased objects to ensure they go away sooner. | 201 // autoreleased objects to ensure they go away sooner. |
| 193 ScopedNSAutoreleasePool autorelease_pool; | 202 ScopedNSAutoreleasePool autorelease_pool; |
| 194 | 203 |
| 195 // Call DoWork once, and if something was done, arrange to come back here | 204 // Call DoWork once, and if something was done, arrange to come back here |
| 196 // again as long as the loop is still running. | 205 // again as long as the loop is still running. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 // static | 506 // static |
| 498 MessagePump* MessagePumpMac::Create() { | 507 MessagePump* MessagePumpMac::Create() { |
| 499 if ([NSThread isMainThread]) { | 508 if ([NSThread isMainThread]) { |
| 500 return new MessagePumpNSApplication; | 509 return new MessagePumpNSApplication; |
| 501 } | 510 } |
| 502 | 511 |
| 503 return new MessagePumpNSRunLoop; | 512 return new MessagePumpNSRunLoop; |
| 504 } | 513 } |
| 505 | 514 |
| 506 } // namespace base | 515 } // namespace base |
| OLD | NEW |