Chromium Code Reviews| Index: base/message_loop/message_pump_mac.mm |
| diff --git a/base/message_loop/message_pump_mac.mm b/base/message_loop/message_pump_mac.mm |
| index 82d9f1e818b18c07af4b3ec2ac5e785de43af61d..144449fe2cd88d6b6eeb40878bb8c32aed5a600a 100644 |
| --- a/base/message_loop/message_pump_mac.mm |
| +++ b/base/message_loop/message_pump_mac.mm |
| @@ -25,38 +25,54 @@ namespace base { |
| namespace { |
| +// AppKit RunLoop modes observed to potentially run tasks posted to Chrome's |
| +// main thread task runner. Some are internal to AppKit but must be observed to |
| +// keep Chrome's UI responsive. Others that may be interesting, but are not |
| +// watched: |
| +// - com.apple.hitoolbox.windows.transitionmode |
| +// - com.apple.hitoolbox.windows.flushmode |
| +const CFStringRef kAllModes[] = { |
| + kCFRunLoopCommonModes, kMessageLoopExclusiveRunLoopMode, |
|
Mark Mentovai
2017/05/10 14:00:18
I guess I’m not supposed to complain if clang-form
Robert Sesek
2017/05/10 14:02:49
I complain all the time about this because clang-f
tapted
2017/05/11 00:24:06
I added a comment,
// Mode that only sees Chrome
Robert Sesek
2017/05/11 16:12:36
I was wondering the same thing. The Exclusive mode
|
| + |
| + // Process work when NSMenus are fading out. |
| + CFSTR("com.apple.hitoolbox.windows.windowfadingmode"), |
| + |
| + // Process work when AppKit is highlighting an item on the main menubar. |
| + CFSTR("NSUnhighlightMenuRunLoopMode"), |
| +}; |
| + |
| void CFRunLoopAddSourceToAllModes(CFRunLoopRef rl, CFRunLoopSourceRef source) { |
|
Robert Sesek
2017/05/10 13:37:27
One last thought: it would be nice if we could lim
tapted
2017/05/11 00:24:05
We could pass a std::vector of scoped_cftyperef<CF
Robert Sesek
2017/05/11 16:12:36
I don't think it's critical since the mode should
|
| - CFRunLoopAddSource(rl, source, kCFRunLoopCommonModes); |
| - CFRunLoopAddSource(rl, source, kMessageLoopExclusiveRunLoopMode); |
| + for (const CFStringRef& mode : kAllModes) |
| + CFRunLoopAddSource(rl, source, mode); |
| } |
| void CFRunLoopRemoveSourceFromAllModes(CFRunLoopRef rl, |
| CFRunLoopSourceRef source) { |
| - CFRunLoopRemoveSource(rl, source, kCFRunLoopCommonModes); |
| - CFRunLoopRemoveSource(rl, source, kMessageLoopExclusiveRunLoopMode); |
| + for (const CFStringRef& mode : kAllModes) |
| + CFRunLoopRemoveSource(rl, source, mode); |
| } |
| void CFRunLoopAddTimerToAllModes(CFRunLoopRef rl, CFRunLoopTimerRef timer) { |
| - CFRunLoopAddTimer(rl, timer, kCFRunLoopCommonModes); |
| - CFRunLoopAddTimer(rl, timer, kMessageLoopExclusiveRunLoopMode); |
| + for (const CFStringRef& mode : kAllModes) |
| + CFRunLoopAddTimer(rl, timer, mode); |
| } |
| void CFRunLoopRemoveTimerFromAllModes(CFRunLoopRef rl, |
| CFRunLoopTimerRef timer) { |
| - CFRunLoopRemoveTimer(rl, timer, kCFRunLoopCommonModes); |
| - CFRunLoopRemoveTimer(rl, timer, kMessageLoopExclusiveRunLoopMode); |
| + for (const CFStringRef& mode : kAllModes) |
| + CFRunLoopRemoveTimer(rl, timer, mode); |
| } |
| void CFRunLoopAddObserverToAllModes(CFRunLoopRef rl, |
| CFRunLoopObserverRef observer) { |
| - CFRunLoopAddObserver(rl, observer, kCFRunLoopCommonModes); |
| - CFRunLoopAddObserver(rl, observer, kMessageLoopExclusiveRunLoopMode); |
| + for (const CFStringRef& mode : kAllModes) |
| + CFRunLoopAddObserver(rl, observer, mode); |
| } |
| void CFRunLoopRemoveObserverFromAllModes(CFRunLoopRef rl, |
| CFRunLoopObserverRef observer) { |
| - CFRunLoopRemoveObserver(rl, observer, kCFRunLoopCommonModes); |
| - CFRunLoopRemoveObserver(rl, observer, kMessageLoopExclusiveRunLoopMode); |
| + for (const CFStringRef& mode : kAllModes) |
| + CFRunLoopRemoveObserver(rl, observer, mode); |
| } |
| void NoOp(void* info) { |