| 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 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/mac/call_with_eh_frame.h" | 13 #include "base/mac/call_with_eh_frame.h" |
| 14 #include "base/mac/scoped_cftyperef.h" | 14 #include "base/mac/scoped_cftyperef.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/message_loop/timer_slack.h" | 16 #include "base/message_loop/timer_slack.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 | 20 |
| 21 #if !defined(OS_IOS) | 21 #if !defined(OS_IOS) |
| 22 #import <AppKit/AppKit.h> | 22 #import <AppKit/AppKit.h> |
| 23 #endif // !defined(OS_IOS) | 23 #endif // !defined(OS_IOS) |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const CFStringRef kAllModes[] = { |
| 30 kCFRunLoopCommonModes, |
| 31 kMessageLoopExclusiveRunLoopMode, |
| 32 CFSTR("com.apple.hitoolbox.windows.windowfadingmode"), |
| 33 |
| 34 // Other modes that aren't strictly necessary: |
| 35 //CFSTR("com.apple.hitoolbox.windows.transitionmode"), |
| 36 //CFSTR("com.apple.hitoolbox.windows.flushmode"), |
| 37 }; |
| 38 |
| 29 void CFRunLoopAddSourceToAllModes(CFRunLoopRef rl, CFRunLoopSourceRef source) { | 39 void CFRunLoopAddSourceToAllModes(CFRunLoopRef rl, CFRunLoopSourceRef source) { |
| 30 CFRunLoopAddSource(rl, source, kCFRunLoopCommonModes); | 40 for (const auto& mode : kAllModes) |
| 31 CFRunLoopAddSource(rl, source, kMessageLoopExclusiveRunLoopMode); | 41 CFRunLoopAddSource(rl, source, mode); |
| 32 } | 42 } |
| 33 | 43 |
| 34 void CFRunLoopRemoveSourceFromAllModes(CFRunLoopRef rl, | 44 void CFRunLoopRemoveSourceFromAllModes(CFRunLoopRef rl, |
| 35 CFRunLoopSourceRef source) { | 45 CFRunLoopSourceRef source) { |
| 36 CFRunLoopRemoveSource(rl, source, kCFRunLoopCommonModes); | 46 for (const auto& mode : kAllModes) |
| 37 CFRunLoopRemoveSource(rl, source, kMessageLoopExclusiveRunLoopMode); | 47 CFRunLoopRemoveSource(rl, source, mode); |
| 38 } | 48 } |
| 39 | 49 |
| 40 void CFRunLoopAddTimerToAllModes(CFRunLoopRef rl, CFRunLoopTimerRef timer) { | 50 void CFRunLoopAddTimerToAllModes(CFRunLoopRef rl, CFRunLoopTimerRef timer) { |
| 41 CFRunLoopAddTimer(rl, timer, kCFRunLoopCommonModes); | 51 for (const auto& mode : kAllModes) |
| 42 CFRunLoopAddTimer(rl, timer, kMessageLoopExclusiveRunLoopMode); | 52 CFRunLoopAddTimer(rl, timer, mode); |
| 43 } | 53 } |
| 44 | 54 |
| 45 void CFRunLoopRemoveTimerFromAllModes(CFRunLoopRef rl, | 55 void CFRunLoopRemoveTimerFromAllModes(CFRunLoopRef rl, |
| 46 CFRunLoopTimerRef timer) { | 56 CFRunLoopTimerRef timer) { |
| 47 CFRunLoopRemoveTimer(rl, timer, kCFRunLoopCommonModes); | 57 for (const auto& mode : kAllModes) |
| 48 CFRunLoopRemoveTimer(rl, timer, kMessageLoopExclusiveRunLoopMode); | 58 CFRunLoopRemoveTimer(rl, timer, mode); |
| 49 } | 59 } |
| 50 | 60 |
| 51 void CFRunLoopAddObserverToAllModes(CFRunLoopRef rl, | 61 void CFRunLoopAddObserverToAllModes(CFRunLoopRef rl, |
| 52 CFRunLoopObserverRef observer) { | 62 CFRunLoopObserverRef observer) { |
| 53 CFRunLoopAddObserver(rl, observer, kCFRunLoopCommonModes); | 63 for (const auto& mode : kAllModes) |
| 54 CFRunLoopAddObserver(rl, observer, kMessageLoopExclusiveRunLoopMode); | 64 CFRunLoopAddObserver(rl, observer, mode); |
| 55 } | 65 } |
| 56 | 66 |
| 57 void CFRunLoopRemoveObserverFromAllModes(CFRunLoopRef rl, | 67 void CFRunLoopRemoveObserverFromAllModes(CFRunLoopRef rl, |
| 58 CFRunLoopObserverRef observer) { | 68 CFRunLoopObserverRef observer) { |
| 59 CFRunLoopRemoveObserver(rl, observer, kCFRunLoopCommonModes); | 69 for (const auto& mode : kAllModes) |
| 60 CFRunLoopRemoveObserver(rl, observer, kMessageLoopExclusiveRunLoopMode); | 70 CFRunLoopRemoveObserver(rl, observer, mode); |
| 61 } | 71 } |
| 62 | 72 |
| 63 void NoOp(void* info) { | 73 void NoOp(void* info) { |
| 64 } | 74 } |
| 65 | 75 |
| 66 const CFTimeInterval kCFTimeIntervalMax = | 76 const CFTimeInterval kCFTimeIntervalMax = |
| 67 std::numeric_limits<CFTimeInterval>::max(); | 77 std::numeric_limits<CFTimeInterval>::max(); |
| 68 | 78 |
| 69 #if !defined(OS_IOS) | 79 #if !defined(OS_IOS) |
| 70 // Set to true if MessagePumpMac::Create() is called before NSApp is | 80 // Set to true if MessagePumpMac::Create() is called before NSApp is |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 [NSApplication sharedApplication]; | 794 [NSApplication sharedApplication]; |
| 785 g_not_using_cr_app = true; | 795 g_not_using_cr_app = true; |
| 786 return new MessagePumpNSApplication; | 796 return new MessagePumpNSApplication; |
| 787 #endif | 797 #endif |
| 788 } | 798 } |
| 789 | 799 |
| 790 return new MessagePumpNSRunLoop; | 800 return new MessagePumpNSRunLoop; |
| 791 } | 801 } |
| 792 | 802 |
| 793 } // namespace base | 803 } // namespace base |
| OLD | NEW |