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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_common.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « chrome/browser/net/safe_search_util.cc ('k') | chrome/browser/prefs/command_line_pref_store.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/predictors/resource_prefetch_common.h" 5 #include "chrome/browser/predictors/resource_prefetch_common.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 16 matching lines...) Expand all
27 const char kSpeculativePrefetchingTrialName[] = 27 const char kSpeculativePrefetchingTrialName[] =
28 "SpeculativeResourcePrefetching"; 28 "SpeculativeResourcePrefetching";
29 29
30 /* 30 /*
31 * SpeculativeResourcePrefetching is a field trial, and its value must have the 31 * SpeculativeResourcePrefetching is a field trial, and its value must have the
32 * following format: key1=value1:key2=value2:key3=value3 32 * following format: key1=value1:key2=value2:key3=value3
33 * e.g. "Prefetching=Enabled:Predictor=Url:Confidence=High" 33 * e.g. "Prefetching=Enabled:Predictor=Url:Confidence=High"
34 * The function below extracts the value corresponding to a key provided from 34 * The function below extracts the value corresponding to a key provided from
35 * the SpeculativeResourcePrefetching field trial. 35 * the SpeculativeResourcePrefetching field trial.
36 */ 36 */
37 string GetFiledTrialSpecValue(string key) { 37 std::string GetFiledTrialSpecValue(string key) {
38 vector<string> elements; 38 std::string trial_name =
39 base::SplitString( 39 FieldTrialList::FindFullName(kSpeculativePrefetchingTrialName);
40 FieldTrialList::FindFullName(kSpeculativePrefetchingTrialName), 40 for (const base::StringPiece& element : base::SplitStringPiece(
41 ':', 41 trial_name, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
42 &elements); 42 std::vector<base::StringPiece> key_value = base::SplitStringPiece(
43 for (int i = 0; i < static_cast<int>(elements.size()); i++) { 43 element, "=", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
44 vector<string> key_value;
45 base::SplitString(elements[i], '=', &key_value);
46 if (key_value.size() == 2 && key_value[0] == key) 44 if (key_value.size() == 2 && key_value[0] == key)
47 return key_value[1]; 45 return key_value[1].as_string();
48 } 46 }
49 return string(); 47 return string();
50 } 48 }
51 49
52 bool IsSpeculativeResourcePrefetchingEnabled( 50 bool IsSpeculativeResourcePrefetchingEnabled(
53 Profile* profile, 51 Profile* profile,
54 ResourcePrefetchPredictorConfig* config) { 52 ResourcePrefetchPredictorConfig* config) {
55 DCHECK(config); 53 DCHECK(config);
56 54
57 // Off the record - disabled. 55 // Off the record - disabled.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 260
263 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { 261 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const {
264 return max_resources_per_entry == 100; 262 return max_resources_per_entry == 100;
265 } 263 }
266 264
267 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { 265 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const {
268 return max_urls_to_track == 200 && max_hosts_to_track == 100; 266 return max_urls_to_track == 200 && max_hosts_to_track == 100;
269 } 267 }
270 268
271 } // namespace predictors 269 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/net/safe_search_util.cc ('k') | chrome/browser/prefs/command_line_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698