OLD | NEW |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 Profile* profile, | 53 Profile* profile, |
54 ResourcePrefetchPredictorConfig* config) { | 54 ResourcePrefetchPredictorConfig* config) { |
55 DCHECK(config); | 55 DCHECK(config); |
56 | 56 |
57 // Off the record - disabled. | 57 // Off the record - disabled. |
58 if (!profile || profile->IsOffTheRecord()) | 58 if (!profile || profile->IsOffTheRecord()) |
59 return false; | 59 return false; |
60 | 60 |
61 // Enabled by command line switch. The config has the default params already | 61 // Enabled by command line switch. The config has the default params already |
62 // set. The command line with just enable them with the default params. | 62 // set. The command line with just enable them with the default params. |
63 if (CommandLine::ForCurrentProcess()->HasSwitch( | 63 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
64 switches::kSpeculativeResourcePrefetching)) { | 64 switches::kSpeculativeResourcePrefetching)) { |
65 const std::string value = | 65 const std::string value = |
66 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
67 switches::kSpeculativeResourcePrefetching); | 67 switches::kSpeculativeResourcePrefetching); |
68 | 68 |
69 if (value == switches::kSpeculativeResourcePrefetchingDisabled) { | 69 if (value == switches::kSpeculativeResourcePrefetchingDisabled) { |
70 return false; | 70 return false; |
71 } else if (value == switches::kSpeculativeResourcePrefetchingLearning) { | 71 } else if (value == switches::kSpeculativeResourcePrefetchingLearning) { |
72 config->mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; | 72 config->mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; |
73 config->mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; | 73 config->mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; |
74 return true; | 74 return true; |
75 } else if (value == switches::kSpeculativeResourcePrefetchingEnabled) { | 75 } else if (value == switches::kSpeculativeResourcePrefetchingEnabled) { |
76 config->mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; | 76 config->mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 262 |
263 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { | 263 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { |
264 return max_resources_per_entry == 100; | 264 return max_resources_per_entry == 100; |
265 } | 265 } |
266 | 266 |
267 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { | 267 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { |
268 return max_urls_to_track == 200 && max_hosts_to_track == 100; | 268 return max_urls_to_track == 200 && max_hosts_to_track == 100; |
269 } | 269 } |
270 | 270 |
271 } // namespace predictors | 271 } // namespace predictors |
OLD | NEW |