| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "extensions/common/event_filter.h" | 5 #include "extensions/common/event_filter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "components/url_matcher/url_matcher_factory.h" | 11 #include "components/url_matcher/url_matcher_factory.h" |
| 11 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
| 12 | 13 |
| 13 using url_matcher::URLMatcher; | 14 using url_matcher::URLMatcher; |
| 14 using url_matcher::URLMatcherConditionSet; | 15 using url_matcher::URLMatcherConditionSet; |
| 15 using url_matcher::URLMatcherFactory; | 16 using url_matcher::URLMatcherFactory; |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 | 19 |
| 19 EventFilter::EventMatcherEntry::EventMatcherEntry( | 20 EventFilter::EventMatcherEntry::EventMatcherEntry( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 URLMatcherConditionSet::Vector condition_sets; | 61 URLMatcherConditionSet::Vector condition_sets; |
| 61 if (!CreateConditionSets(id, matcher.get(), &condition_sets)) | 62 if (!CreateConditionSets(id, matcher.get(), &condition_sets)) |
| 62 return -1; | 63 return -1; |
| 63 | 64 |
| 64 for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin(); | 65 for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin(); |
| 65 it != condition_sets.end(); it++) { | 66 it != condition_sets.end(); it++) { |
| 66 condition_set_id_to_event_matcher_id_.insert( | 67 condition_set_id_to_event_matcher_id_.insert( |
| 67 std::make_pair((*it)->id(), id)); | 68 std::make_pair((*it)->id(), id)); |
| 68 } | 69 } |
| 69 id_to_event_name_[id] = event_name; | 70 id_to_event_name_[id] = event_name; |
| 70 event_matchers_[event_name][id] = linked_ptr<EventMatcherEntry>( | 71 event_matchers_[event_name][id] = base::MakeUnique<EventMatcherEntry>( |
| 71 new EventMatcherEntry(std::move(matcher), &url_matcher_, condition_sets)); | 72 std::move(matcher), &url_matcher_, condition_sets); |
| 72 return id; | 73 return id; |
| 73 } | 74 } |
| 74 | 75 |
| 75 EventMatcher* EventFilter::GetEventMatcher(MatcherID id) { | 76 EventMatcher* EventFilter::GetEventMatcher(MatcherID id) { |
| 76 DCHECK(id_to_event_name_.find(id) != id_to_event_name_.end()); | 77 DCHECK(id_to_event_name_.find(id) != id_to_event_name_.end()); |
| 77 const std::string& event_name = id_to_event_name_[id]; | 78 const std::string& event_name = id_to_event_name_[id]; |
| 78 return event_matchers_[event_name][id]->event_matcher(); | 79 return event_matchers_[event_name][id]->event_matcher(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 const std::string& EventFilter::GetEventName(MatcherID id) { | 82 const std::string& EventFilter::GetEventName(MatcherID id) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 179 |
| 179 int EventFilter::GetMatcherCountForEvent(const std::string& name) { | 180 int EventFilter::GetMatcherCountForEvent(const std::string& name) { |
| 180 EventMatcherMultiMap::const_iterator it = event_matchers_.find(name); | 181 EventMatcherMultiMap::const_iterator it = event_matchers_.find(name); |
| 181 if (it == event_matchers_.end()) | 182 if (it == event_matchers_.end()) |
| 182 return 0; | 183 return 0; |
| 183 | 184 |
| 184 return it->second.size(); | 185 return it->second.size(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace extensions | 188 } // namespace extensions |
| OLD | NEW |