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) { |