Chromium Code Reviews| Index: services/ui/ws/event_dispatcher.cc |
| diff --git a/services/ui/ws/event_dispatcher.cc b/services/ui/ws/event_dispatcher.cc |
| index 18d3dafec9e8931a6c7d07153eea00cb36ce9e12..4dbe448996862dce7d1be8a1f8a3d88d18308311 100644 |
| --- a/services/ui/ws/event_dispatcher.cc |
| +++ b/services/ui/ws/event_dispatcher.cc |
| @@ -252,10 +252,24 @@ void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { |
| bool EventDispatcher::AddAccelerator(uint32_t id, |
| mojom::EventMatcherPtr event_matcher) { |
| std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); |
| + |
| // If an accelerator with the same id or matcher already exists, then abort. |
| + bool is_duplicate = false; |
|
sky
2017/01/28 00:09:15
I think this would be easier to follow if you remo
thanhph1
2017/01/30 16:37:54
Done.
|
| + std::string error_message; |
| for (const auto& pair : accelerators_) { |
| - if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) |
| + if (pair.first == id) { |
| + error_message = "Duplicate accelerator id."; |
| + is_duplicate = true; |
| + } else if (accelerator->EqualEventMatcher(pair.second.get())) { |
| + error_message = "Duplicate accelerator matcher."; |
| + is_duplicate = true; |
| + } |
| + if (is_duplicate) { |
| + LOG(ERROR) << error_message << " accelerator id=" << accelerator->id() |
|
sky
2017/01/28 00:09:15
As this isn't fatal, use DVLOG(1) (which is what m
thanhph1
2017/01/30 16:37:54
Done.
|
| + << " type=" << event_matcher->type_matcher->type |
| + << " flags=" << event_matcher->flags_matcher->flags; |
| return false; |
| + } |
| } |
| accelerators_.insert(Entry(id, std::move(accelerator))); |
| return true; |