OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_loop/message_pump_mac.h" | 5 #import "base/message_loop/message_pump_mac.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <stack> | 10 #include <stack> |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 | 690 |
691 self->EnterExitRunLoop(activity); | 691 self->EnterExitRunLoop(activity); |
692 } | 692 } |
693 | 693 |
694 // Called by MessagePumpCFRunLoopBase::EnterExitRunLoop. The default | 694 // Called by MessagePumpCFRunLoopBase::EnterExitRunLoop. The default |
695 // implementation is a no-op. | 695 // implementation is a no-op. |
696 void MessagePumpCFRunLoopBase::EnterExitRunLoop(CFRunLoopActivity activity) { | 696 void MessagePumpCFRunLoopBase::EnterExitRunLoop(CFRunLoopActivity activity) { |
697 } | 697 } |
698 | 698 |
699 // Base version returns a standard NSAutoreleasePool. | 699 // Base version returns a standard NSAutoreleasePool. |
700 NSAutoreleasePool* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { | 700 AutoreleasePoolType* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { |
701 return [[NSAutoreleasePool alloc] init]; | 701 return [[NSAutoreleasePool alloc] init]; |
702 } | 702 } |
703 | 703 |
704 MessagePumpCFRunLoop::MessagePumpCFRunLoop() | 704 MessagePumpCFRunLoop::MessagePumpCFRunLoop() |
705 : quit_pending_(false) { | 705 : quit_pending_(false) { |
706 } | 706 } |
707 | 707 |
708 MessagePumpCFRunLoop::~MessagePumpCFRunLoop() {} | 708 MessagePumpCFRunLoop::~MessagePumpCFRunLoop() {} |
709 | 709 |
710 // Called by MessagePumpCFRunLoopBase::DoRun. If other CFRunLoopRun loops were | 710 // Called by MessagePumpCFRunLoopBase::DoRun. If other CFRunLoopRun loops were |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 // window in frame #5. When the stack is unwound to frame #5, the window would | 902 // window in frame #5. When the stack is unwound to frame #5, the window would |
903 // no longer exists and crashes may occur. Apple gets around this by never | 903 // no longer exists and crashes may occur. Apple gets around this by never |
904 // releasing the pool it creates in frame #4, and letting frame #7 clean it up | 904 // releasing the pool it creates in frame #4, and letting frame #7 clean it up |
905 // when it cleans up the pool that wraps frame #7. When an autorelease pool is | 905 // when it cleans up the pool that wraps frame #7. When an autorelease pool is |
906 // released it releases all other pools that were created after it on the | 906 // released it releases all other pools that were created after it on the |
907 // autorelease pool stack. | 907 // autorelease pool stack. |
908 // | 908 // |
909 // CrApplication is responsible for setting handlingSendEvent to true just | 909 // CrApplication is responsible for setting handlingSendEvent to true just |
910 // before it sends the event through the event handling mechanism, and | 910 // before it sends the event through the event handling mechanism, and |
911 // returning it to its previous value once the event has been sent. | 911 // returning it to its previous value once the event has been sent. |
912 NSAutoreleasePool* MessagePumpCrApplication::CreateAutoreleasePool() { | 912 AutoreleasePoolType* MessagePumpCrApplication::CreateAutoreleasePool() { |
913 if (MessagePumpMac::IsHandlingSendEvent()) | 913 if (MessagePumpMac::IsHandlingSendEvent()) |
914 return nil; | 914 return nil; |
915 return MessagePumpNSApplication::CreateAutoreleasePool(); | 915 return MessagePumpNSApplication::CreateAutoreleasePool(); |
916 } | 916 } |
917 | 917 |
918 // static | 918 // static |
919 bool MessagePumpMac::UsingCrApp() { | 919 bool MessagePumpMac::UsingCrApp() { |
920 DCHECK([NSThread isMainThread]); | 920 DCHECK([NSThread isMainThread]); |
921 | 921 |
922 // If NSApp is still not initialized, then the subclass used cannot | 922 // If NSApp is still not initialized, then the subclass used cannot |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 [NSApplication sharedApplication]; | 954 [NSApplication sharedApplication]; |
955 g_not_using_cr_app = true; | 955 g_not_using_cr_app = true; |
956 return new MessagePumpNSApplication; | 956 return new MessagePumpNSApplication; |
957 #endif | 957 #endif |
958 } | 958 } |
959 | 959 |
960 return new MessagePumpNSRunLoop; | 960 return new MessagePumpNSRunLoop; |
961 } | 961 } |
962 | 962 |
963 } // namespace base | 963 } // namespace base |
OLD | NEW |