| 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 "components/url_matcher/url_matcher_factory.h" | 10 #include "components/url_matcher/url_matcher_factory.h" |
| 11 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
| 12 | 12 |
| 13 using url_matcher::URLMatcher; | 13 using url_matcher::URLMatcher; |
| 14 using url_matcher::URLMatcherConditionSet; | 14 using url_matcher::URLMatcherConditionSet; |
| 15 using url_matcher::URLMatcherFactory; | 15 using url_matcher::URLMatcherFactory; |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 EventFilter::EventMatcherEntry::EventMatcherEntry( | 19 EventFilter::EventMatcherEntry::EventMatcherEntry( |
| 20 scoped_ptr<EventMatcher> event_matcher, | 20 std::unique_ptr<EventMatcher> event_matcher, |
| 21 URLMatcher* url_matcher, | 21 URLMatcher* url_matcher, |
| 22 const URLMatcherConditionSet::Vector& condition_sets) | 22 const URLMatcherConditionSet::Vector& condition_sets) |
| 23 : event_matcher_(std::move(event_matcher)), url_matcher_(url_matcher) { | 23 : event_matcher_(std::move(event_matcher)), url_matcher_(url_matcher) { |
| 24 for (URLMatcherConditionSet::Vector::const_iterator it = | 24 for (URLMatcherConditionSet::Vector::const_iterator it = |
| 25 condition_sets.begin(); it != condition_sets.end(); it++) | 25 condition_sets.begin(); it != condition_sets.end(); it++) |
| 26 condition_set_ids_.push_back((*it)->id()); | 26 condition_set_ids_.push_back((*it)->id()); |
| 27 url_matcher_->AddConditionSets(condition_sets); | 27 url_matcher_->AddConditionSets(condition_sets); |
| 28 } | 28 } |
| 29 | 29 |
| 30 EventFilter::EventMatcherEntry::~EventMatcherEntry() { | 30 EventFilter::EventMatcherEntry::~EventMatcherEntry() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 // being destroyed anyway there is no need to do that step here. | 46 // being destroyed anyway there is no need to do that step here. |
| 47 for (EventMatcherMultiMap::iterator it = event_matchers_.begin(); | 47 for (EventMatcherMultiMap::iterator it = event_matchers_.begin(); |
| 48 it != event_matchers_.end(); it++) { | 48 it != event_matchers_.end(); it++) { |
| 49 for (EventMatcherMap::iterator it2 = it->second.begin(); | 49 for (EventMatcherMap::iterator it2 = it->second.begin(); |
| 50 it2 != it->second.end(); it2++) { | 50 it2 != it->second.end(); it2++) { |
| 51 it2->second->DontRemoveConditionSetsInDestructor(); | 51 it2->second->DontRemoveConditionSetsInDestructor(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 EventFilter::MatcherID | 56 EventFilter::MatcherID EventFilter::AddEventMatcher( |
| 57 EventFilter::AddEventMatcher(const std::string& event_name, | 57 const std::string& event_name, |
| 58 scoped_ptr<EventMatcher> matcher) { | 58 std::unique_ptr<EventMatcher> matcher) { |
| 59 MatcherID id = next_id_++; | 59 MatcherID id = next_id_++; |
| 60 URLMatcherConditionSet::Vector condition_sets; | 60 URLMatcherConditionSet::Vector condition_sets; |
| 61 if (!CreateConditionSets(id, matcher.get(), &condition_sets)) | 61 if (!CreateConditionSets(id, matcher.get(), &condition_sets)) |
| 62 return -1; | 62 return -1; |
| 63 | 63 |
| 64 for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin(); | 64 for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin(); |
| 65 it != condition_sets.end(); it++) { | 65 it != condition_sets.end(); it++) { |
| 66 condition_set_id_to_event_matcher_id_.insert( | 66 condition_set_id_to_event_matcher_id_.insert( |
| 67 std::make_pair((*it)->id(), id)); | 67 std::make_pair((*it)->id(), id)); |
| 68 } | 68 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 int EventFilter::GetMatcherCountForEvent(const std::string& name) { | 179 int EventFilter::GetMatcherCountForEvent(const std::string& name) { |
| 180 EventMatcherMultiMap::const_iterator it = event_matchers_.find(name); | 180 EventMatcherMultiMap::const_iterator it = event_matchers_.find(name); |
| 181 if (it == event_matchers_.end()) | 181 if (it == event_matchers_.end()) |
| 182 return 0; | 182 return 0; |
| 183 | 183 |
| 184 return it->second.size(); | 184 return it->second.size(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace extensions | 187 } // namespace extensions |
| OLD | NEW |