| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "base/message_pump_mac.h" | 5 #import "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 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 453 |
| 454 // Base version returns a standard NSAutoreleasePool. | 454 // Base version returns a standard NSAutoreleasePool. |
| 455 NSAutoreleasePool* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { | 455 NSAutoreleasePool* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { |
| 456 return [[NSAutoreleasePool alloc] init]; | 456 return [[NSAutoreleasePool alloc] init]; |
| 457 } | 457 } |
| 458 | 458 |
| 459 MessagePumpCFRunLoop::MessagePumpCFRunLoop() | 459 MessagePumpCFRunLoop::MessagePumpCFRunLoop() |
| 460 : quit_pending_(false) { | 460 : quit_pending_(false) { |
| 461 } | 461 } |
| 462 | 462 |
| 463 MessagePumpCFRunLoop::~MessagePumpCFRunLoop() {} |
| 464 |
| 463 // Called by MessagePumpCFRunLoopBase::DoRun. If other CFRunLoopRun loops were | 465 // Called by MessagePumpCFRunLoopBase::DoRun. If other CFRunLoopRun loops were |
| 464 // running lower on the run loop thread's stack when this object was created, | 466 // running lower on the run loop thread's stack when this object was created, |
| 465 // the same number of CFRunLoopRun loops must be running for the outermost call | 467 // the same number of CFRunLoopRun loops must be running for the outermost call |
| 466 // to Run. Run/DoRun are reentrant after that point. | 468 // to Run. Run/DoRun are reentrant after that point. |
| 467 void MessagePumpCFRunLoop::DoRun(Delegate* delegate) { | 469 void MessagePumpCFRunLoop::DoRun(Delegate* delegate) { |
| 468 // This is completely identical to calling CFRunLoopRun(), except autorelease | 470 // This is completely identical to calling CFRunLoopRun(), except autorelease |
| 469 // pool management is introduced. | 471 // pool management is introduced. |
| 470 int result; | 472 int result; |
| 471 do { | 473 do { |
| 472 MessagePumpScopedAutoreleasePool autorelease_pool(this); | 474 MessagePumpScopedAutoreleasePool autorelease_pool(this); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 keep_running_ = false; | 537 keep_running_ = false; |
| 536 CFRunLoopSourceSignal(quit_source_); | 538 CFRunLoopSourceSignal(quit_source_); |
| 537 CFRunLoopWakeUp(run_loop()); | 539 CFRunLoopWakeUp(run_loop()); |
| 538 } | 540 } |
| 539 | 541 |
| 540 MessagePumpNSApplication::MessagePumpNSApplication() | 542 MessagePumpNSApplication::MessagePumpNSApplication() |
| 541 : keep_running_(true), | 543 : keep_running_(true), |
| 542 running_own_loop_(false) { | 544 running_own_loop_(false) { |
| 543 } | 545 } |
| 544 | 546 |
| 547 MessagePumpNSApplication::~MessagePumpNSApplication() {} |
| 548 |
| 545 void MessagePumpNSApplication::DoRun(Delegate* delegate) { | 549 void MessagePumpNSApplication::DoRun(Delegate* delegate) { |
| 546 bool last_running_own_loop_ = running_own_loop_; | 550 bool last_running_own_loop_ = running_own_loop_; |
| 547 | 551 |
| 548 // NSApp must be initialized by calling: | 552 // NSApp must be initialized by calling: |
| 549 // [{some class which implements CrAppProtocol} sharedApplication] | 553 // [{some class which implements CrAppProtocol} sharedApplication] |
| 550 // Most likely candidates are CrApplication or BrowserCrApplication. | 554 // Most likely candidates are CrApplication or BrowserCrApplication. |
| 551 // These can be initialized from C++ code by calling | 555 // These can be initialized from C++ code by calling |
| 552 // RegisterCrApp() or RegisterBrowserCrApp(). | 556 // RegisterCrApp() or RegisterBrowserCrApp(). |
| 553 CHECK(NSApp); | 557 CHECK(NSApp); |
| 554 | 558 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 673 } |
| 670 | 674 |
| 671 // static | 675 // static |
| 672 bool MessagePumpMac::IsHandlingSendEvent() { | 676 bool MessagePumpMac::IsHandlingSendEvent() { |
| 673 DCHECK([NSApp conformsToProtocol:@protocol(CrAppProtocol)]); | 677 DCHECK([NSApp conformsToProtocol:@protocol(CrAppProtocol)]); |
| 674 NSObject<CrAppProtocol>* app = static_cast<NSObject<CrAppProtocol>*>(NSApp); | 678 NSObject<CrAppProtocol>* app = static_cast<NSObject<CrAppProtocol>*>(NSApp); |
| 675 return [app isHandlingSendEvent]; | 679 return [app isHandlingSendEvent]; |
| 676 } | 680 } |
| 677 | 681 |
| 678 } // namespace base | 682 } // namespace base |
| OLD | NEW |