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

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

Issue 1908953003: Convert //extensions/{common,shell} from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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') | extensions/common/event_filter_unittest.cc » ('j') | 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 "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
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
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
OLDNEW
« no previous file with comments | « extensions/common/event_filter.h ('k') | extensions/common/event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698