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 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Mode that only sees Chrome work sources. | 37 // Mode that only sees Chrome work sources. |
38 kMessageLoopExclusiveRunLoopMode, | 38 kMessageLoopExclusiveRunLoopMode, |
39 | 39 |
40 // Process work when NSMenus are fading out. | 40 // Process work when NSMenus are fading out. |
41 CFSTR("com.apple.hitoolbox.windows.windowfadingmode"), | 41 CFSTR("com.apple.hitoolbox.windows.windowfadingmode"), |
42 | 42 |
43 // Process work when AppKit is highlighting an item on the main menubar. | 43 // Process work when AppKit is highlighting an item on the main menubar. |
44 CFSTR("NSUnhighlightMenuRunLoopMode"), | 44 CFSTR("NSUnhighlightMenuRunLoopMode"), |
45 }; | 45 }; |
46 | 46 |
47 void CFRunLoopAddSourceToAllModes(CFRunLoopRef rl, CFRunLoopSourceRef source) { | 47 // Mask that determines which modes in |kAllModes| to use. |
48 for (const CFStringRef& mode : kAllModes) | 48 enum { kCommonModeMask = 0x1, kAllModesMask = ~0 }; |
49 CFRunLoopAddSource(rl, source, mode); | |
50 } | |
51 | |
52 void CFRunLoopRemoveSourceFromAllModes(CFRunLoopRef rl, | |
53 CFRunLoopSourceRef source) { | |
54 for (const CFStringRef& mode : kAllModes) | |
55 CFRunLoopRemoveSource(rl, source, mode); | |
56 } | |
57 | |
58 void CFRunLoopAddTimerToAllModes(CFRunLoopRef rl, CFRunLoopTimerRef timer) { | |
59 for (const CFStringRef& mode : kAllModes) | |
60 CFRunLoopAddTimer(rl, timer, mode); | |
61 } | |
62 | |
63 void CFRunLoopRemoveTimerFromAllModes(CFRunLoopRef rl, | |
64 CFRunLoopTimerRef timer) { | |
65 for (const CFStringRef& mode : kAllModes) | |
66 CFRunLoopRemoveTimer(rl, timer, mode); | |
67 } | |
68 | |
69 void CFRunLoopAddObserverToAllModes(CFRunLoopRef rl, | |
70 CFRunLoopObserverRef observer) { | |
71 for (const CFStringRef& mode : kAllModes) | |
72 CFRunLoopAddObserver(rl, observer, mode); | |
73 } | |
74 | |
75 void CFRunLoopRemoveObserverFromAllModes(CFRunLoopRef rl, | |
76 CFRunLoopObserverRef observer) { | |
77 for (const CFStringRef& mode : kAllModes) | |
78 CFRunLoopRemoveObserver(rl, observer, mode); | |
79 } | |
80 | 49 |
81 void NoOp(void* info) { | 50 void NoOp(void* info) { |
82 } | 51 } |
83 | 52 |
84 const CFTimeInterval kCFTimeIntervalMax = | 53 const CFTimeInterval kCFTimeIntervalMax = |
85 std::numeric_limits<CFTimeInterval>::max(); | 54 std::numeric_limits<CFTimeInterval>::max(); |
86 | 55 |
87 #if !defined(OS_IOS) | 56 #if !defined(OS_IOS) |
88 // Set to true if MessagePumpMac::Create() is called before NSApp is | 57 // Set to true if MessagePumpMac::Create() is called before NSApp is |
89 // initialized. Only accessed from the main thread. | 58 // initialized. Only accessed from the main thread. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 bool valid) { | 158 bool valid) { |
190 #if !defined(OS_IOS) | 159 #if !defined(OS_IOS) |
191 static bool can_invalidate_timers = CanInvalidateCFRunLoopTimers(); | 160 static bool can_invalidate_timers = CanInvalidateCFRunLoopTimers(); |
192 if (can_invalidate_timers) { | 161 if (can_invalidate_timers) { |
193 __ChromeCFRunLoopTimerSetValid(timer, valid); | 162 __ChromeCFRunLoopTimerSetValid(timer, valid); |
194 } | 163 } |
195 #endif // !defined(OS_IOS) | 164 #endif // !defined(OS_IOS) |
196 } | 165 } |
197 | 166 |
198 // Must be called on the run loop thread. | 167 // Must be called on the run loop thread. |
199 MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase() | 168 MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase(int mode_mask) |
200 : delegate_(NULL), | 169 : mode_mask_(mode_mask), |
| 170 delegate_(NULL), |
201 delayed_work_fire_time_(kCFTimeIntervalMax), | 171 delayed_work_fire_time_(kCFTimeIntervalMax), |
202 timer_slack_(base::TIMER_SLACK_NONE), | 172 timer_slack_(base::TIMER_SLACK_NONE), |
203 nesting_level_(0), | 173 nesting_level_(0), |
204 run_nesting_level_(0), | 174 run_nesting_level_(0), |
205 deepest_nesting_level_(0), | 175 deepest_nesting_level_(0), |
206 delegateless_work_(false), | 176 delegateless_work_(false), |
207 delegateless_idle_work_(false) { | 177 delegateless_idle_work_(false) { |
208 run_loop_ = CFRunLoopGetCurrent(); | 178 run_loop_ = CFRunLoopGetCurrent(); |
209 CFRetain(run_loop_); | 179 CFRetain(run_loop_); |
210 | 180 |
211 // Set a repeating timer with a preposterous firing time and interval. The | 181 // Set a repeating timer with a preposterous firing time and interval. The |
212 // timer will effectively never fire as-is. The firing time will be adjusted | 182 // timer will effectively never fire as-is. The firing time will be adjusted |
213 // as needed when ScheduleDelayedWork is called. | 183 // as needed when ScheduleDelayedWork is called. |
214 CFRunLoopTimerContext timer_context = CFRunLoopTimerContext(); | 184 CFRunLoopTimerContext timer_context = CFRunLoopTimerContext(); |
215 timer_context.info = this; | 185 timer_context.info = this; |
216 delayed_work_timer_ = CFRunLoopTimerCreate(NULL, // allocator | 186 delayed_work_timer_ = CFRunLoopTimerCreate(NULL, // allocator |
217 kCFTimeIntervalMax, // fire time | 187 kCFTimeIntervalMax, // fire time |
218 kCFTimeIntervalMax, // interval | 188 kCFTimeIntervalMax, // interval |
219 0, // flags | 189 0, // flags |
220 0, // priority | 190 0, // priority |
221 RunDelayedWorkTimer, | 191 RunDelayedWorkTimer, |
222 &timer_context); | 192 &timer_context); |
223 CFRunLoopAddTimerToAllModes(run_loop_, delayed_work_timer_); | 193 InvokeForAllModes(&CFRunLoopAddTimer, delayed_work_timer_); |
224 | 194 |
225 CFRunLoopSourceContext source_context = CFRunLoopSourceContext(); | 195 CFRunLoopSourceContext source_context = CFRunLoopSourceContext(); |
226 source_context.info = this; | 196 source_context.info = this; |
227 source_context.perform = RunWorkSource; | 197 source_context.perform = RunWorkSource; |
228 work_source_ = CFRunLoopSourceCreate(NULL, // allocator | 198 work_source_ = CFRunLoopSourceCreate(NULL, // allocator |
229 1, // priority | 199 1, // priority |
230 &source_context); | 200 &source_context); |
231 CFRunLoopAddSourceToAllModes(run_loop_, work_source_); | 201 InvokeForAllModes(&CFRunLoopAddSource, work_source_); |
232 | 202 |
233 source_context.perform = RunIdleWorkSource; | 203 source_context.perform = RunIdleWorkSource; |
234 idle_work_source_ = CFRunLoopSourceCreate(NULL, // allocator | 204 idle_work_source_ = CFRunLoopSourceCreate(NULL, // allocator |
235 2, // priority | 205 2, // priority |
236 &source_context); | 206 &source_context); |
237 CFRunLoopAddSourceToAllModes(run_loop_, idle_work_source_); | 207 InvokeForAllModes(&CFRunLoopAddSource, idle_work_source_); |
238 | 208 |
239 source_context.perform = RunNestingDeferredWorkSource; | 209 source_context.perform = RunNestingDeferredWorkSource; |
240 nesting_deferred_work_source_ = CFRunLoopSourceCreate(NULL, // allocator | 210 nesting_deferred_work_source_ = CFRunLoopSourceCreate(NULL, // allocator |
241 0, // priority | 211 0, // priority |
242 &source_context); | 212 &source_context); |
243 CFRunLoopAddSourceToAllModes(run_loop_, nesting_deferred_work_source_); | 213 InvokeForAllModes(&CFRunLoopAddSource, nesting_deferred_work_source_); |
244 | 214 |
245 CFRunLoopObserverContext observer_context = CFRunLoopObserverContext(); | 215 CFRunLoopObserverContext observer_context = CFRunLoopObserverContext(); |
246 observer_context.info = this; | 216 observer_context.info = this; |
247 pre_wait_observer_ = CFRunLoopObserverCreate(NULL, // allocator | 217 pre_wait_observer_ = CFRunLoopObserverCreate(NULL, // allocator |
248 kCFRunLoopBeforeWaiting, | 218 kCFRunLoopBeforeWaiting, |
249 true, // repeat | 219 true, // repeat |
250 0, // priority | 220 0, // priority |
251 PreWaitObserver, | 221 PreWaitObserver, |
252 &observer_context); | 222 &observer_context); |
253 CFRunLoopAddObserverToAllModes(run_loop_, pre_wait_observer_); | 223 InvokeForAllModes(&CFRunLoopAddObserver, pre_wait_observer_); |
254 | 224 |
255 pre_source_observer_ = CFRunLoopObserverCreate(NULL, // allocator | 225 pre_source_observer_ = CFRunLoopObserverCreate(NULL, // allocator |
256 kCFRunLoopBeforeSources, | 226 kCFRunLoopBeforeSources, |
257 true, // repeat | 227 true, // repeat |
258 0, // priority | 228 0, // priority |
259 PreSourceObserver, | 229 PreSourceObserver, |
260 &observer_context); | 230 &observer_context); |
261 CFRunLoopAddObserverToAllModes(run_loop_, pre_source_observer_); | 231 InvokeForAllModes(&CFRunLoopAddObserver, pre_source_observer_); |
262 | 232 |
263 enter_exit_observer_ = CFRunLoopObserverCreate(NULL, // allocator | 233 enter_exit_observer_ = CFRunLoopObserverCreate(NULL, // allocator |
264 kCFRunLoopEntry | | 234 kCFRunLoopEntry | |
265 kCFRunLoopExit, | 235 kCFRunLoopExit, |
266 true, // repeat | 236 true, // repeat |
267 0, // priority | 237 0, // priority |
268 EnterExitObserver, | 238 EnterExitObserver, |
269 &observer_context); | 239 &observer_context); |
270 CFRunLoopAddObserverToAllModes(run_loop_, enter_exit_observer_); | 240 InvokeForAllModes(&CFRunLoopAddObserver, enter_exit_observer_); |
271 } | 241 } |
272 | 242 |
273 // Ideally called on the run loop thread. If other run loops were running | 243 // Ideally called on the run loop thread. If other run loops were running |
274 // lower on the run loop thread's stack when this object was created, the | 244 // lower on the run loop thread's stack when this object was created, the |
275 // same number of run loops must be running when this object is destroyed. | 245 // same number of run loops must be running when this object is destroyed. |
276 MessagePumpCFRunLoopBase::~MessagePumpCFRunLoopBase() { | 246 MessagePumpCFRunLoopBase::~MessagePumpCFRunLoopBase() { |
277 CFRunLoopRemoveObserverFromAllModes(run_loop_, enter_exit_observer_); | 247 for (const CFRunLoopObserverRef& observer : |
278 CFRelease(enter_exit_observer_); | 248 {enter_exit_observer_, pre_source_observer_, pre_wait_observer_}) { |
279 | 249 InvokeForAllModes(&CFRunLoopRemoveObserver, observer); |
280 CFRunLoopRemoveObserverFromAllModes(run_loop_, pre_source_observer_); | 250 CFRelease(observer); |
281 CFRelease(pre_source_observer_); | 251 } |
282 | 252 for (const CFRunLoopSourceRef& source : |
283 CFRunLoopRemoveObserverFromAllModes(run_loop_, pre_wait_observer_); | 253 {nesting_deferred_work_source_, idle_work_source_, work_source_}) { |
284 CFRelease(pre_wait_observer_); | 254 InvokeForAllModes(&CFRunLoopRemoveSource, source); |
285 | 255 CFRelease(source); |
286 CFRunLoopRemoveSourceFromAllModes(run_loop_, nesting_deferred_work_source_); | 256 } |
287 CFRelease(nesting_deferred_work_source_); | 257 InvokeForAllModes(&CFRunLoopRemoveTimer, delayed_work_timer_); |
288 | |
289 CFRunLoopRemoveSourceFromAllModes(run_loop_, idle_work_source_); | |
290 CFRelease(idle_work_source_); | |
291 | |
292 CFRunLoopRemoveSourceFromAllModes(run_loop_, work_source_); | |
293 CFRelease(work_source_); | |
294 | |
295 CFRunLoopRemoveTimerFromAllModes(run_loop_, delayed_work_timer_); | |
296 CFRelease(delayed_work_timer_); | 258 CFRelease(delayed_work_timer_); |
297 | |
298 CFRelease(run_loop_); | 259 CFRelease(run_loop_); |
299 } | 260 } |
300 | 261 |
301 // Must be called on the run loop thread. | 262 // Must be called on the run loop thread. |
302 void MessagePumpCFRunLoopBase::Run(Delegate* delegate) { | 263 void MessagePumpCFRunLoopBase::Run(Delegate* delegate) { |
303 // nesting_level_ will be incremented in EnterExitRunLoop, so set | 264 // nesting_level_ will be incremented in EnterExitRunLoop, so set |
304 // run_nesting_level_ accordingly. | 265 // run_nesting_level_ accordingly. |
305 int last_run_nesting_level = run_nesting_level_; | 266 int last_run_nesting_level = run_nesting_level_; |
306 run_nesting_level_ = nesting_level_ + 1; | 267 run_nesting_level_ = nesting_level_ + 1; |
307 | 268 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 CFRunLoopTimerSetTolerance(delayed_work_timer_, delta.InSecondsF() * 0.5); | 321 CFRunLoopTimerSetTolerance(delayed_work_timer_, delta.InSecondsF() * 0.5); |
361 } else { | 322 } else { |
362 CFRunLoopTimerSetTolerance(delayed_work_timer_, 0); | 323 CFRunLoopTimerSetTolerance(delayed_work_timer_, 0); |
363 } | 324 } |
364 } | 325 } |
365 | 326 |
366 void MessagePumpCFRunLoopBase::SetTimerSlack(TimerSlack timer_slack) { | 327 void MessagePumpCFRunLoopBase::SetTimerSlack(TimerSlack timer_slack) { |
367 timer_slack_ = timer_slack; | 328 timer_slack_ = timer_slack; |
368 } | 329 } |
369 | 330 |
| 331 template <typename Argument> |
| 332 void MessagePumpCFRunLoopBase::InvokeForAllModes(void method(CFRunLoopRef, |
| 333 Argument, |
| 334 CFStringRef), |
| 335 Argument argument) { |
| 336 for (size_t i = 0; i < arraysize(kAllModes); ++i) { |
| 337 if (mode_mask_ & (0x1 << i)) |
| 338 method(run_loop_, argument, kAllModes[i]); |
| 339 } |
| 340 } |
| 341 |
370 // Called from the run loop. | 342 // Called from the run loop. |
371 // static | 343 // static |
372 void MessagePumpCFRunLoopBase::RunDelayedWorkTimer(CFRunLoopTimerRef timer, | 344 void MessagePumpCFRunLoopBase::RunDelayedWorkTimer(CFRunLoopTimerRef timer, |
373 void* info) { | 345 void* info) { |
374 MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info); | 346 MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info); |
375 | 347 |
376 // The timer won't fire again until it's reset. | 348 // The timer won't fire again until it's reset. |
377 self->delayed_work_fire_time_ = kCFTimeIntervalMax; | 349 self->delayed_work_fire_time_ = kCFTimeIntervalMax; |
378 | 350 |
379 // The message pump's timer needs to fire at changing and unpredictable | 351 // The message pump's timer needs to fire at changing and unpredictable |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 // implementation is a no-op. | 610 // implementation is a no-op. |
639 void MessagePumpCFRunLoopBase::EnterExitRunLoop(CFRunLoopActivity activity) { | 611 void MessagePumpCFRunLoopBase::EnterExitRunLoop(CFRunLoopActivity activity) { |
640 } | 612 } |
641 | 613 |
642 // Base version returns a standard NSAutoreleasePool. | 614 // Base version returns a standard NSAutoreleasePool. |
643 AutoreleasePoolType* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { | 615 AutoreleasePoolType* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { |
644 return [[NSAutoreleasePool alloc] init]; | 616 return [[NSAutoreleasePool alloc] init]; |
645 } | 617 } |
646 | 618 |
647 MessagePumpCFRunLoop::MessagePumpCFRunLoop() | 619 MessagePumpCFRunLoop::MessagePumpCFRunLoop() |
648 : quit_pending_(false) { | 620 : MessagePumpCFRunLoopBase(kCommonModeMask), quit_pending_(false) {} |
649 } | |
650 | 621 |
651 MessagePumpCFRunLoop::~MessagePumpCFRunLoop() {} | 622 MessagePumpCFRunLoop::~MessagePumpCFRunLoop() {} |
652 | 623 |
653 // Called by MessagePumpCFRunLoopBase::DoRun. If other CFRunLoopRun loops were | 624 // Called by MessagePumpCFRunLoopBase::DoRun. If other CFRunLoopRun loops were |
654 // running lower on the run loop thread's stack when this object was created, | 625 // running lower on the run loop thread's stack when this object was created, |
655 // the same number of CFRunLoopRun loops must be running for the outermost call | 626 // the same number of CFRunLoopRun loops must be running for the outermost call |
656 // to Run. Run/DoRun are reentrant after that point. | 627 // to Run. Run/DoRun are reentrant after that point. |
657 void MessagePumpCFRunLoop::DoRun(Delegate* delegate) { | 628 void MessagePumpCFRunLoop::DoRun(Delegate* delegate) { |
658 // This is completely identical to calling CFRunLoopRun(), except autorelease | 629 // This is completely identical to calling CFRunLoopRun(), except autorelease |
659 // pool management is introduced. | 630 // pool management is introduced. |
(...skipping 30 matching lines...) Expand all Loading... |
690 // Quit was called while loops other than those managed by this object | 661 // Quit was called while loops other than those managed by this object |
691 // were running further inside a run loop managed by this object. Now | 662 // were running further inside a run loop managed by this object. Now |
692 // that all unmanaged inner run loops are gone, stop the loop running | 663 // that all unmanaged inner run loops are gone, stop the loop running |
693 // just inside Run. | 664 // just inside Run. |
694 CFRunLoopStop(run_loop()); | 665 CFRunLoopStop(run_loop()); |
695 quit_pending_ = false; | 666 quit_pending_ = false; |
696 } | 667 } |
697 } | 668 } |
698 | 669 |
699 MessagePumpNSRunLoop::MessagePumpNSRunLoop() | 670 MessagePumpNSRunLoop::MessagePumpNSRunLoop() |
700 : keep_running_(true) { | 671 : MessagePumpCFRunLoopBase(kCommonModeMask), keep_running_(true) { |
701 CFRunLoopSourceContext source_context = CFRunLoopSourceContext(); | 672 CFRunLoopSourceContext source_context = CFRunLoopSourceContext(); |
702 source_context.perform = NoOp; | 673 source_context.perform = NoOp; |
703 quit_source_ = CFRunLoopSourceCreate(NULL, // allocator | 674 quit_source_ = CFRunLoopSourceCreate(NULL, // allocator |
704 0, // priority | 675 0, // priority |
705 &source_context); | 676 &source_context); |
706 CFRunLoopAddSourceToAllModes(run_loop(), quit_source_); | 677 InvokeForAllModes(&CFRunLoopAddSource, quit_source_); |
707 } | 678 } |
708 | 679 |
709 MessagePumpNSRunLoop::~MessagePumpNSRunLoop() { | 680 MessagePumpNSRunLoop::~MessagePumpNSRunLoop() { |
710 CFRunLoopRemoveSourceFromAllModes(run_loop(), quit_source_); | 681 InvokeForAllModes(&CFRunLoopRemoveSource, quit_source_); |
711 CFRelease(quit_source_); | 682 CFRelease(quit_source_); |
712 } | 683 } |
713 | 684 |
714 void MessagePumpNSRunLoop::DoRun(Delegate* delegate) { | 685 void MessagePumpNSRunLoop::DoRun(Delegate* delegate) { |
715 while (keep_running_) { | 686 while (keep_running_) { |
716 // NSRunLoop manages autorelease pools itself. | 687 // NSRunLoop manages autorelease pools itself. |
717 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode | 688 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode |
718 beforeDate:[NSDate distantFuture]]; | 689 beforeDate:[NSDate distantFuture]]; |
719 } | 690 } |
720 | 691 |
721 keep_running_ = true; | 692 keep_running_ = true; |
722 } | 693 } |
723 | 694 |
724 void MessagePumpNSRunLoop::Quit() { | 695 void MessagePumpNSRunLoop::Quit() { |
725 keep_running_ = false; | 696 keep_running_ = false; |
726 CFRunLoopSourceSignal(quit_source_); | 697 CFRunLoopSourceSignal(quit_source_); |
727 CFRunLoopWakeUp(run_loop()); | 698 CFRunLoopWakeUp(run_loop()); |
728 } | 699 } |
729 | 700 |
730 #if defined(OS_IOS) | 701 #if defined(OS_IOS) |
731 MessagePumpUIApplication::MessagePumpUIApplication() | 702 MessagePumpUIApplication::MessagePumpUIApplication() |
732 : run_loop_(NULL) { | 703 : MessagePumpCFRunLoopBase(kCommonModeMask), run_loop_(NULL) {} |
733 } | |
734 | 704 |
735 MessagePumpUIApplication::~MessagePumpUIApplication() {} | 705 MessagePumpUIApplication::~MessagePumpUIApplication() {} |
736 | 706 |
737 void MessagePumpUIApplication::DoRun(Delegate* delegate) { | 707 void MessagePumpUIApplication::DoRun(Delegate* delegate) { |
738 NOTREACHED(); | 708 NOTREACHED(); |
739 } | 709 } |
740 | 710 |
741 void MessagePumpUIApplication::Quit() { | 711 void MessagePumpUIApplication::Quit() { |
742 NOTREACHED(); | 712 NOTREACHED(); |
743 } | 713 } |
744 | 714 |
745 void MessagePumpUIApplication::Attach(Delegate* delegate) { | 715 void MessagePumpUIApplication::Attach(Delegate* delegate) { |
746 DCHECK(!run_loop_); | 716 DCHECK(!run_loop_); |
747 run_loop_ = new RunLoop(); | 717 run_loop_ = new RunLoop(); |
748 CHECK(run_loop_->BeforeRun()); | 718 CHECK(run_loop_->BeforeRun()); |
749 SetDelegate(delegate); | 719 SetDelegate(delegate); |
750 } | 720 } |
751 | 721 |
752 #else | 722 #else |
753 | 723 |
754 MessagePumpNSApplication::MessagePumpNSApplication() | 724 MessagePumpNSApplication::MessagePumpNSApplication() |
755 : keep_running_(true), | 725 : MessagePumpCFRunLoopBase(kAllModesMask), |
756 running_own_loop_(false) { | 726 keep_running_(true), |
757 } | 727 running_own_loop_(false) {} |
758 | 728 |
759 MessagePumpNSApplication::~MessagePumpNSApplication() {} | 729 MessagePumpNSApplication::~MessagePumpNSApplication() {} |
760 | 730 |
761 void MessagePumpNSApplication::DoRun(Delegate* delegate) { | 731 void MessagePumpNSApplication::DoRun(Delegate* delegate) { |
762 bool last_running_own_loop_ = running_own_loop_; | 732 bool last_running_own_loop_ = running_own_loop_; |
763 | 733 |
764 // NSApp must be initialized by calling: | 734 // NSApp must be initialized by calling: |
765 // [{some class which implements CrAppProtocol} sharedApplication] | 735 // [{some class which implements CrAppProtocol} sharedApplication] |
766 // Most likely candidates are CrApplication or BrowserCrApplication. | 736 // Most likely candidates are CrApplication or BrowserCrApplication. |
767 // These can be initialized from C++ code by calling | 737 // These can be initialized from C++ code by calling |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 [NSApplication sharedApplication]; | 863 [NSApplication sharedApplication]; |
894 g_not_using_cr_app = true; | 864 g_not_using_cr_app = true; |
895 return new MessagePumpNSApplication; | 865 return new MessagePumpNSApplication; |
896 #endif | 866 #endif |
897 } | 867 } |
898 | 868 |
899 return new MessagePumpNSRunLoop; | 869 return new MessagePumpNSRunLoop; |
900 } | 870 } |
901 | 871 |
902 } // namespace base | 872 } // namespace base |
OLD | NEW |