OLD | NEW |
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 #ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 5 #ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
6 #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 6 #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // dispatcher installed using |OverrideDispatcher()|, then that dispatcher | 63 // dispatcher installed using |OverrideDispatcher()|, then that dispatcher |
64 // receives the event first. |POST_DISPATCH_QUIT_LOOP| flag is set in the | 64 // receives the event first. |POST_DISPATCH_QUIT_LOOP| flag is set in the |
65 // returned value if the event-source should stop dispatching events at the | 65 // returned value if the event-source should stop dispatching events at the |
66 // current message-loop iteration. | 66 // current message-loop iteration. |
67 virtual uint32_t DispatchEvent(PlatformEvent platform_event); | 67 virtual uint32_t DispatchEvent(PlatformEvent platform_event); |
68 | 68 |
69 private: | 69 private: |
70 friend class ScopedEventDispatcher; | 70 friend class ScopedEventDispatcher; |
71 static PlatformEventSource* instance_; | 71 static PlatformEventSource* instance_; |
72 | 72 |
| 73 // Called to indicate that the source should stop dispatching the current |
| 74 // stream of events and wait until the next iteration of the message-loop to |
| 75 // dispatch the rest of the events. |
| 76 virtual void StopCurrentEventStream(); |
| 77 |
73 // This is invoked when the list of dispatchers changes (i.e. a new dispatcher | 78 // This is invoked when the list of dispatchers changes (i.e. a new dispatcher |
74 // is added, or a dispatcher is removed). | 79 // is added, or a dispatcher is removed). |
75 virtual void OnDispatcherListChanged(); | 80 virtual void OnDispatcherListChanged(); |
76 | 81 |
77 void OnOverriddenDispatcherRestored(); | 82 void OnOverriddenDispatcherRestored(); |
78 | 83 |
79 // Use an ObserverList<> instead of an std::vector<> to store the list of | 84 // Use an ObserverList<> instead of an std::vector<> to store the list of |
80 // dispatchers, so that adding/removing dispatchers during an event dispatch | 85 // dispatchers, so that adding/removing dispatchers during an event dispatch |
81 // is well-defined. | 86 // is well-defined. |
82 typedef ObserverList<PlatformEventDispatcher> PlatformEventDispatcherList; | 87 typedef ObserverList<PlatformEventDispatcher> PlatformEventDispatcherList; |
83 PlatformEventDispatcherList dispatchers_; | 88 PlatformEventDispatcherList dispatchers_; |
84 PlatformEventDispatcher* overridden_dispatcher_; | 89 PlatformEventDispatcher* overridden_dispatcher_; |
85 | 90 |
86 // Used to keep track of whether the current override-dispatcher has been | 91 // Used to keep track of whether the current override-dispatcher has been |
87 // reset and a previous override-dispatcher has been restored. | 92 // reset and a previous override-dispatcher has been restored. |
88 bool overridden_dispatcher_restored_; | 93 bool overridden_dispatcher_restored_; |
89 | 94 |
90 ObserverList<PlatformEventObserver> observers_; | 95 ObserverList<PlatformEventObserver> observers_; |
91 | 96 |
92 DISALLOW_COPY_AND_ASSIGN(PlatformEventSource); | 97 DISALLOW_COPY_AND_ASSIGN(PlatformEventSource); |
93 }; | 98 }; |
94 | 99 |
95 } // namespace ui | 100 } // namespace ui |
96 | 101 |
97 #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 102 #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
OLD | NEW |