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

Unified Diff: components/mus/ws/event_dispatcher.cc

Issue 1487333004: mus: Notify the client whether adding an accelerator was successful. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/event_dispatcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/event_dispatcher.cc
diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc
index c9f71deda563e6948ce4eb61b9a28e9ec3d38429..384f9ba81f95b1c2d41d364a79a8a2653dabbe13 100644
--- a/components/mus/ws/event_dispatcher.cc
+++ b/components/mus/ws/event_dispatcher.cc
@@ -109,7 +109,6 @@ class EventMatcher {
return true;
}
-#if !defined(NDEBUG)
bool Equals(const EventMatcher& matcher) const {
return fields_to_match_ == matcher.fields_to_match_ &&
event_type_ == matcher.event_type_ &&
@@ -118,7 +117,6 @@ class EventMatcher {
pointer_kind_ == matcher.pointer_kind_ &&
pointer_region_ == matcher.pointer_region_;
}
-#endif
private:
enum MatchFields {
@@ -153,16 +151,16 @@ EventDispatcher::~EventDispatcher() {
}
}
-void EventDispatcher::AddAccelerator(uint32_t id,
+bool EventDispatcher::AddAccelerator(uint32_t id,
mojom::EventMatcherPtr event_matcher) {
EventMatcher matcher(*event_matcher);
-#if !defined(NDEBUG)
+ // If an accelerator with the same id or matcher already exists, then abort.
for (const auto& pair : accelerators_) {
- DCHECK_NE(pair.first, id);
- DCHECK(!matcher.Equals(pair.second));
+ if (pair.first == id || matcher.Equals(pair.second))
+ return false;
}
-#endif
accelerators_.insert(Entry(id, matcher));
+ return true;
}
void EventDispatcher::RemoveAccelerator(uint32_t id) {
« no previous file with comments | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698