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

Unified Diff: ui/events/platform/scoped_event_dispatcher.h

Issue 203483004: events: Introduce PlatformEventDispatcher and PlatformEventSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/platform/platform_event_types.h ('k') | ui/events/platform/scoped_event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/platform/scoped_event_dispatcher.h
diff --git a/ui/events/platform/scoped_event_dispatcher.h b/ui/events/platform/scoped_event_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..a2f52945d91183d40ab07693cb6f3d7527f3e678
--- /dev/null
+++ b/ui/events/platform/scoped_event_dispatcher.h
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_
+#define UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_
+
+#include "base/auto_reset.h"
+#include "base/basictypes.h"
+#include "ui/events/events_export.h"
+
+namespace ui {
+
+class PlatformEventDispatcher;
+
+// A temporary PlatformEventDispatcher can be installed on a
+// PlatformEventSource that overrides all installed event dispatchers, and
+// always gets a chance to dispatch the event first. The PlatformEventSource
+// returns a ScopedEventDispatcher object in such cases. This
+// ScopedEventDispatcher object can be used to dispatch the event to any
+// previous overridden dispatcher. When this object is destroyed, it removes the
+// override-dispatcher, and restores the previous override-dispatcher.
+class EVENTS_EXPORT ScopedEventDispatcher {
+ public:
+ ScopedEventDispatcher(PlatformEventDispatcher** scoped_dispatcher,
+ PlatformEventDispatcher* new_dispatcher);
+ ~ScopedEventDispatcher();
+
+ operator PlatformEventDispatcher*() const { return original_; }
+
+ private:
+ PlatformEventDispatcher* original_;
+ base::AutoReset<PlatformEventDispatcher*> restore_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedEventDispatcher);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_
« no previous file with comments | « ui/events/platform/platform_event_types.h ('k') | ui/events/platform/scoped_event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698