Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: ui/events/platform/platform_event_source.cc

Issue 274383002: events: Remove ability to terminate a nested message-loop from the event-source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/platform/platform_event_source.h" 5 #include "ui/events/platform/platform_event_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 observers_.AddObserver(observer); 58 observers_.AddObserver(observer);
59 } 59 }
60 60
61 void PlatformEventSource::RemovePlatformEventObserver( 61 void PlatformEventSource::RemovePlatformEventObserver(
62 PlatformEventObserver* observer) { 62 PlatformEventObserver* observer) {
63 observers_.RemoveObserver(observer); 63 observers_.RemoveObserver(observer);
64 } 64 }
65 65
66 uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) { 66 uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) {
67 uint32_t action = POST_DISPATCH_PERFORM_DEFAULT; 67 uint32_t action = POST_DISPATCH_PERFORM_DEFAULT;
68 bool should_quit = false;
69 68
70 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, 69 FOR_EACH_OBSERVER(PlatformEventObserver, observers_,
71 WillProcessEvent(platform_event)); 70 WillProcessEvent(platform_event));
72 // Give the overridden dispatcher a chance to dispatch the event first. 71 // Give the overridden dispatcher a chance to dispatch the event first.
73 if (overridden_dispatcher_) 72 if (overridden_dispatcher_)
74 action = overridden_dispatcher_->DispatchEvent(platform_event); 73 action = overridden_dispatcher_->DispatchEvent(platform_event);
75 should_quit = !!(action & POST_DISPATCH_QUIT_LOOP);
76 74
77 if ((action & POST_DISPATCH_PERFORM_DEFAULT) && 75 if ((action & POST_DISPATCH_PERFORM_DEFAULT) &&
78 dispatchers_.might_have_observers()) { 76 dispatchers_.might_have_observers()) {
79 ObserverList<PlatformEventDispatcher>::Iterator iter(dispatchers_); 77 ObserverList<PlatformEventDispatcher>::Iterator iter(dispatchers_);
80 while (PlatformEventDispatcher* dispatcher = iter.GetNext()) { 78 while (PlatformEventDispatcher* dispatcher = iter.GetNext()) {
81 if (dispatcher->CanDispatchEvent(platform_event)) 79 if (dispatcher->CanDispatchEvent(platform_event))
82 action = dispatcher->DispatchEvent(platform_event); 80 action = dispatcher->DispatchEvent(platform_event);
83 if (action & POST_DISPATCH_QUIT_LOOP)
84 should_quit = true;
85 if (action & POST_DISPATCH_STOP_PROPAGATION) 81 if (action & POST_DISPATCH_STOP_PROPAGATION)
86 break; 82 break;
87 } 83 }
88 } 84 }
89 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, 85 FOR_EACH_OBSERVER(PlatformEventObserver, observers_,
90 DidProcessEvent(platform_event)); 86 DidProcessEvent(platform_event));
91 87
92 // Terminate the message-loop if the dispatcher requested for it.
93 if (should_quit) {
94 base::MessageLoop::current()->QuitNow();
95 action |= POST_DISPATCH_QUIT_LOOP;
96 }
97
98 // If an overridden dispatcher has been destroyed, then the platform 88 // If an overridden dispatcher has been destroyed, then the platform
99 // event-source should halt dispatching the current stream of events, and wait 89 // event-source should halt dispatching the current stream of events, and wait
100 // until the next message-loop iteration for dispatching events. This lets any 90 // until the next message-loop iteration for dispatching events. This lets any
101 // nested message-loop to unwind correctly and any new dispatchers to receive 91 // nested message-loop to unwind correctly and any new dispatchers to receive
102 // the correct sequence of events. 92 // the correct sequence of events.
103 if (overridden_dispatcher_restored_) 93 if (overridden_dispatcher_restored_)
104 action |= POST_DISPATCH_QUIT_LOOP; 94 StopCurrentEventStream();
105 95
106 overridden_dispatcher_restored_ = false; 96 overridden_dispatcher_restored_ = false;
107 97
108 return action; 98 return action;
109 } 99 }
110 100
101 void PlatformEventSource::StopCurrentEventStream() {
102 }
103
111 void PlatformEventSource::OnDispatcherListChanged() { 104 void PlatformEventSource::OnDispatcherListChanged() {
112 } 105 }
113 106
114 void PlatformEventSource::OnOverriddenDispatcherRestored() { 107 void PlatformEventSource::OnOverriddenDispatcherRestored() {
115 CHECK(overridden_dispatcher_); 108 CHECK(overridden_dispatcher_);
116 overridden_dispatcher_restored_ = true; 109 overridden_dispatcher_restored_ = true;
117 } 110 }
118 111
119 } // namespace ui 112 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698