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

Side by Side Diff: android_webview/browser/command_line_helper.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 9 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 | « no previous file | base/feature_list.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "android_webview/browser/command_line_helper.h" 5 #include "android_webview/browser/command_line_helper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_piece.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
14 15
15 using std::string; 16 using std::string;
16 using std::vector; 17 using std::vector;
17 18
18 namespace { 19 namespace {
19 20
20 // Adds |feature_name| to the list of features in |feature_list_name|, but only 21 // Adds |feature_name| to the list of features in |feature_list_name|, but only
21 // if the |feature_name| is absent from the list of features in both 22 // if the |feature_name| is absent from the list of features in both
22 // |feature_list_name| and |other_feature_list_name|. 23 // |feature_list_name| and |other_feature_list_name|.
23 void AddFeatureToList(base::CommandLine& command_line, 24 void AddFeatureToList(base::CommandLine& command_line,
24 const string& feature_name, 25 const string& feature_name,
25 const char* feature_list_name, 26 const char* feature_list_name,
26 const char* other_feature_list_name) { 27 const char* other_feature_list_name) {
27 const string features_list = 28 const string features_list =
28 command_line.GetSwitchValueASCII(feature_list_name); 29 command_line.GetSwitchValueASCII(feature_list_name);
29 const string other_features_list = 30 const string other_features_list =
30 command_line.GetSwitchValueASCII(other_feature_list_name); 31 command_line.GetSwitchValueASCII(other_feature_list_name);
31 32
32 if (features_list.empty() && other_features_list.empty()) { 33 if (features_list.empty() && other_features_list.empty()) {
33 command_line.AppendSwitchASCII(feature_list_name, feature_name); 34 command_line.AppendSwitchASCII(feature_list_name, feature_name);
34 return; 35 return;
35 } 36 }
36 37
37 vector<string> features = 38 vector<base::StringPiece> features =
38 base::FeatureList::SplitFeatureListString(features_list); 39 base::FeatureList::SplitFeatureListString(features_list);
39 vector<string> other_features = 40 vector<base::StringPiece> other_features =
40 base::FeatureList::SplitFeatureListString(other_features_list); 41 base::FeatureList::SplitFeatureListString(other_features_list);
41 42
42 if (!base::ContainsValue(features, feature_name) && 43 if (!base::ContainsValue(features, feature_name) &&
43 !base::ContainsValue(other_features, feature_name)) { 44 !base::ContainsValue(other_features, feature_name)) {
44 features.push_back(feature_name); 45 features.push_back(feature_name);
45 command_line.AppendSwitchASCII(feature_list_name, 46 command_line.AppendSwitchASCII(feature_list_name,
46 base::JoinString(features, ",")); 47 base::JoinString(features, ","));
47 } 48 }
48 } 49 }
49 50
50 } // namespace 51 } // namespace
51 52
52 // static 53 // static
53 void CommandLineHelper::AddEnabledFeature(base::CommandLine& command_line, 54 void CommandLineHelper::AddEnabledFeature(base::CommandLine& command_line,
54 const string& feature_name) { 55 const string& feature_name) {
55 AddFeatureToList(command_line, feature_name, switches::kEnableFeatures, 56 AddFeatureToList(command_line, feature_name, switches::kEnableFeatures,
56 switches::kDisableFeatures); 57 switches::kDisableFeatures);
57 } 58 }
58 59
59 // static 60 // static
60 void CommandLineHelper::AddDisabledFeature(base::CommandLine& command_line, 61 void CommandLineHelper::AddDisabledFeature(base::CommandLine& command_line,
61 const string& feature_name) { 62 const string& feature_name) {
62 AddFeatureToList(command_line, feature_name, switches::kDisableFeatures, 63 AddFeatureToList(command_line, feature_name, switches::kDisableFeatures,
63 switches::kEnableFeatures); 64 switches::kEnableFeatures);
64 } 65 }
OLDNEW
« no previous file with comments | « no previous file | base/feature_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698