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 <IOKit/IOMessage.h> | 9 #include <IOKit/IOMessage.h> |
10 #include <IOKit/pwr_mgt/IOPMLib.h> | 10 #include <IOKit/pwr_mgt/IOPMLib.h> |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 665 } |
666 | 666 |
667 MessagePumpNSApplication::MessagePumpNSApplication() | 667 MessagePumpNSApplication::MessagePumpNSApplication() |
668 : keep_running_(true), | 668 : keep_running_(true), |
669 running_own_loop_(false) { | 669 running_own_loop_(false) { |
670 } | 670 } |
671 | 671 |
672 void MessagePumpNSApplication::DoRun(Delegate* delegate) { | 672 void MessagePumpNSApplication::DoRun(Delegate* delegate) { |
673 bool last_running_own_loop_ = running_own_loop_; | 673 bool last_running_own_loop_ = running_own_loop_; |
674 | 674 |
| 675 // NSApp must be initialized by calling: |
| 676 // [{some class which implements CrAppProtocol} sharedApplication] |
| 677 // Most likely candidates are CrApplication or BrowserCrApplication. |
| 678 // These can be initialized from C++ code by calling |
| 679 // RegisterCrApp() or RegisterBrowserCrApp(). |
| 680 CHECK(NSApp); |
| 681 |
675 if (![NSApp isRunning]) { | 682 if (![NSApp isRunning]) { |
676 running_own_loop_ = false; | 683 running_own_loop_ = false; |
677 // NSApplication manages autorelease pools itself when run this way. | 684 // NSApplication manages autorelease pools itself when run this way. |
678 [NSApp run]; | 685 [NSApp run]; |
679 } else { | 686 } else { |
680 running_own_loop_ = true; | 687 running_own_loop_ = true; |
681 NSDate* distant_future = [NSDate distantFuture]; | 688 NSDate* distant_future = [NSDate distantFuture]; |
682 while (keep_running_) { | 689 while (keep_running_) { |
683 MessagePumpScopedAutoreleasePool autorelease_pool(this); | 690 MessagePumpScopedAutoreleasePool autorelease_pool(this); |
684 NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask | 691 NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // static | 765 // static |
759 MessagePump* MessagePumpMac::Create() { | 766 MessagePump* MessagePumpMac::Create() { |
760 if ([NSThread isMainThread]) { | 767 if ([NSThread isMainThread]) { |
761 return new MessagePumpNSApplication; | 768 return new MessagePumpNSApplication; |
762 } | 769 } |
763 | 770 |
764 return new MessagePumpNSRunLoop; | 771 return new MessagePumpNSRunLoop; |
765 } | 772 } |
766 | 773 |
767 } // namespace base | 774 } // namespace base |
OLD | NEW |