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

Side by Side Diff: extensions/common/features/feature_provider.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/features/feature_provider.h" 5 #include "extensions/common/features/feature_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return iter->second.get(); 133 return iter->second.get();
134 else 134 else
135 return nullptr; 135 return nullptr;
136 } 136 }
137 137
138 Feature* FeatureProvider::GetParent(Feature* feature) const { 138 Feature* FeatureProvider::GetParent(Feature* feature) const {
139 CHECK(feature); 139 CHECK(feature);
140 if (feature->no_parent()) 140 if (feature->no_parent())
141 return nullptr; 141 return nullptr;
142 142
143 std::vector<std::string> split = base::SplitString( 143 std::vector<base::StringPiece> split = base::SplitStringPiece(
144 feature->name(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 144 feature->name(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
145 if (split.size() < 2) 145 if (split.size() < 2)
146 return nullptr; 146 return nullptr;
147 split.pop_back(); 147 split.pop_back();
148 return GetFeature(base::JoinString(split, ".")); 148 return GetFeature(base::JoinString(split, "."));
149 } 149 }
150 150
151 // Children of a given API are named starting with parent.name()+".", which 151 // Children of a given API are named starting with parent.name()+".", which
152 // means they'll be contiguous in the features_ std::map. 152 // means they'll be contiguous in the features_ std::map.
153 std::vector<Feature*> FeatureProvider::GetChildren( 153 std::vector<Feature*> FeatureProvider::GetChildren(
(...skipping 22 matching lines...) Expand all
176 void FeatureProvider::AddFeature(base::StringPiece name, 176 void FeatureProvider::AddFeature(base::StringPiece name,
177 std::unique_ptr<Feature> feature) { 177 std::unique_ptr<Feature> feature) {
178 features_[name.as_string()] = std::move(feature); 178 features_[name.as_string()] = std::move(feature);
179 } 179 }
180 180
181 void FeatureProvider::AddFeature(base::StringPiece name, Feature* feature) { 181 void FeatureProvider::AddFeature(base::StringPiece name, Feature* feature) {
182 features_[name.as_string()] = std::unique_ptr<Feature>(feature); 182 features_[name.as_string()] = std::unique_ptr<Feature>(feature);
183 } 183 }
184 184
185 } // namespace extensions 185 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/csp_validator.cc ('k') | extensions/common/permissions/socket_permission_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698