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

Side by Side Diff: extensions/common/event_filter.cc

Issue 2697093004: Remove unused param in EventFilter::CreateConditionSets. (Closed)
Patch Set: Created 3 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « extensions/common/event_filter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/ptr_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 for (EventMatcherMap::iterator it2 = it->second.begin(); 50 for (EventMatcherMap::iterator it2 = it->second.begin();
51 it2 != it->second.end(); it2++) { 51 it2 != it->second.end(); it2++) {
52 it2->second->DontRemoveConditionSetsInDestructor(); 52 it2->second->DontRemoveConditionSetsInDestructor();
53 } 53 }
54 } 54 }
55 } 55 }
56 56
57 EventFilter::MatcherID EventFilter::AddEventMatcher( 57 EventFilter::MatcherID EventFilter::AddEventMatcher(
58 const std::string& event_name, 58 const std::string& event_name,
59 std::unique_ptr<EventMatcher> matcher) { 59 std::unique_ptr<EventMatcher> matcher) {
60 MatcherID id = next_id_++;
61 URLMatcherConditionSet::Vector condition_sets; 60 URLMatcherConditionSet::Vector condition_sets;
62 if (!CreateConditionSets(id, matcher.get(), &condition_sets)) 61 if (!CreateConditionSets(matcher.get(), &condition_sets))
63 return -1; 62 return -1;
64 63
64 MatcherID id = next_id_++;
65 for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin(); 65 for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin();
66 it != condition_sets.end(); it++) { 66 it != condition_sets.end(); it++) {
67 condition_set_id_to_event_matcher_id_.insert( 67 condition_set_id_to_event_matcher_id_.insert(
68 std::make_pair((*it)->id(), id)); 68 std::make_pair((*it)->id(), id));
69 } 69 }
70 id_to_event_name_[id] = event_name; 70 id_to_event_name_[id] = event_name;
71 event_matchers_[event_name][id] = base::MakeUnique<EventMatcherEntry>( 71 event_matchers_[event_name][id] = base::MakeUnique<EventMatcherEntry>(
72 std::move(matcher), &url_matcher_, condition_sets); 72 std::move(matcher), &url_matcher_, condition_sets);
73 return id; 73 return id;
74 } 74 }
75 75
76 EventMatcher* EventFilter::GetEventMatcher(MatcherID id) { 76 EventMatcher* EventFilter::GetEventMatcher(MatcherID id) {
77 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());
78 const std::string& event_name = id_to_event_name_[id]; 78 const std::string& event_name = id_to_event_name_[id];
79 return event_matchers_[event_name][id]->event_matcher(); 79 return event_matchers_[event_name][id]->event_matcher();
80 } 80 }
81 81
82 const std::string& EventFilter::GetEventName(MatcherID id) { 82 const std::string& EventFilter::GetEventName(MatcherID id) {
83 DCHECK(id_to_event_name_.find(id) != id_to_event_name_.end()); 83 DCHECK(id_to_event_name_.find(id) != id_to_event_name_.end());
84 return id_to_event_name_[id]; 84 return id_to_event_name_[id];
85 } 85 }
86 86
87 bool EventFilter::CreateConditionSets( 87 bool EventFilter::CreateConditionSets(
88 MatcherID id,
lazyboy 2017/02/15 23:59:00 Note: from git log, this was unused since it was i
89 EventMatcher* matcher, 88 EventMatcher* matcher,
90 URLMatcherConditionSet::Vector* condition_sets) { 89 URLMatcherConditionSet::Vector* condition_sets) {
91 if (matcher->GetURLFilterCount() == 0) { 90 if (matcher->GetURLFilterCount() == 0) {
92 // If there are no URL filters then we want to match all events, so create a 91 // If there are no URL filters then we want to match all events, so create a
93 // URLFilter from an empty dictionary. 92 // URLFilter from an empty dictionary.
94 base::DictionaryValue empty_dict; 93 base::DictionaryValue empty_dict;
95 return AddDictionaryAsConditionSet(&empty_dict, condition_sets); 94 return AddDictionaryAsConditionSet(&empty_dict, condition_sets);
96 } 95 }
97 for (int i = 0; i < matcher->GetURLFilterCount(); i++) { 96 for (int i = 0; i < matcher->GetURLFilterCount(); i++) {
98 base::DictionaryValue* url_filter; 97 base::DictionaryValue* url_filter;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 178
180 int EventFilter::GetMatcherCountForEvent(const std::string& name) { 179 int EventFilter::GetMatcherCountForEvent(const std::string& name) {
181 EventMatcherMultiMap::const_iterator it = event_matchers_.find(name); 180 EventMatcherMultiMap::const_iterator it = event_matchers_.find(name);
182 if (it == event_matchers_.end()) 181 if (it == event_matchers_.end())
183 return 0; 182 return 0;
184 183
185 return it->second.size(); 184 return it->second.size();
186 } 185 }
187 186
188 } // namespace extensions 187 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/event_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698