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

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 2876153002: Support Using ScopedFeatureList in BrowserTest (Closed)
Patch Set: Ilya comment addressed Created 3 years, 6 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 (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 "chrome/browser/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
11 #include <sstream> 11 #include <sstream>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/containers/mru_cache.h" 17 #include "base/containers/mru_cache.h"
18 #include "base/feature_list.h"
19 #include "base/location.h" 18 #include "base/location.h"
20 #include "base/logging.h" 19 #include "base/logging.h"
21 #include "base/macros.h" 20 #include "base/macros.h"
22 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
23 #include "base/metrics/histogram_macros.h" 22 #include "base/metrics/histogram_macros.h"
24 #include "base/single_thread_task_runner.h" 23 #include "base/single_thread_task_runner.h"
25 #include "base/stl_util.h" 24 #include "base/stl_util.h"
26 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
27 #include "base/threading/thread_restrictions.h" 26 #include "base/threading/thread_restrictions.h"
28 #include "base/threading/thread_task_runner_handle.h" 27 #include "base/threading/thread_task_runner_handle.h"
(...skipping 17 matching lines...) Expand all
46 #include "net/log/net_log_with_source.h" 45 #include "net/log/net_log_with_source.h"
47 #include "net/proxy/proxy_info.h" 46 #include "net/proxy/proxy_info.h"
48 #include "net/proxy/proxy_service.h" 47 #include "net/proxy/proxy_service.h"
49 #include "net/ssl/ssl_config_service.h" 48 #include "net/ssl/ssl_config_service.h"
50 #include "net/url_request/url_request_context.h" 49 #include "net/url_request/url_request_context.h"
51 #include "net/url_request/url_request_context_getter.h" 50 #include "net/url_request/url_request_context_getter.h"
52 51
53 using base::TimeDelta; 52 using base::TimeDelta;
54 using content::BrowserThread; 53 using content::BrowserThread;
55 54
56 namespace chrome_browser_net { 55 namespace features {
57
58 namespace {
59 56
60 const base::Feature kNetworkPrediction{"NetworkPrediction", 57 const base::Feature kNetworkPrediction{"NetworkPrediction",
61 base::FEATURE_ENABLED_BY_DEFAULT}; 58 base::FEATURE_ENABLED_BY_DEFAULT};
62 59
63 } // namespace 60 } // namespace features
Ilya Sherman 2017/06/09 20:19:28 Why did you move this out of the chrome_browser_ne
61
62 namespace chrome_browser_net {
64 63
65 // static 64 // static
66 const int Predictor::kPredictorReferrerVersion = 2; 65 const int Predictor::kPredictorReferrerVersion = 2;
67 const double Predictor::kPreconnectWorthyExpectedValue = 0.8; 66 const double Predictor::kPreconnectWorthyExpectedValue = 0.8;
68 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1; 67 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1;
69 const double Predictor::kDiscardableExpectedValue = 0.05; 68 const double Predictor::kDiscardableExpectedValue = 0.05;
70 const size_t Predictor::kMaxSpeculativeParallelResolves = 3; 69 const size_t Predictor::kMaxSpeculativeParallelResolves = 3;
71 const int Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10; 70 const int Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10;
72 71
73 // This number was obtained by the Net.Predictor.MRUIndex histogram on Canary 72 // This number was obtained by the Net.Predictor.MRUIndex histogram on Canary
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 DCHECK_CURRENTLY_ON(BrowserThread::UI); 120 DCHECK_CURRENTLY_ON(BrowserThread::UI);
122 } 121 }
123 122
124 Predictor::~Predictor() { 123 Predictor::~Predictor() {
125 DCHECK_CURRENTLY_ON(BrowserThread::IO); 124 DCHECK_CURRENTLY_ON(BrowserThread::IO);
126 DCHECK(shutdown_); 125 DCHECK(shutdown_);
127 } 126 }
128 127
129 // static 128 // static
130 Predictor* Predictor::CreatePredictor(bool simple_shutdown) { 129 Predictor* Predictor::CreatePredictor(bool simple_shutdown) {
131 bool predictor_enabled = base::FeatureList::IsEnabled(kNetworkPrediction); 130 bool predictor_enabled =
131 base::FeatureList::IsEnabled(features::kNetworkPrediction);
132 if (simple_shutdown) 132 if (simple_shutdown)
133 return new SimplePredictor(predictor_enabled); 133 return new SimplePredictor(predictor_enabled);
134 return new Predictor(predictor_enabled); 134 return new Predictor(predictor_enabled);
135 } 135 }
136 136
137 void Predictor::RegisterProfilePrefs( 137 void Predictor::RegisterProfilePrefs(
138 user_prefs::PrefRegistrySyncable* registry) { 138 user_prefs::PrefRegistrySyncable* registry) {
139 registry->RegisterListPref(prefs::kDnsPrefetchingStartupList, 139 registry->RegisterListPref(prefs::kDnsPrefetchingStartupList,
140 PrefRegistry::LOSSY_PREF); 140 PrefRegistry::LOSSY_PREF);
141 registry->RegisterListPref(prefs::kDnsPrefetchingHostReferralList, 141 registry->RegisterListPref(prefs::kDnsPrefetchingHostReferralList,
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1197 }
1198 1198
1199 void SimplePredictor::ShutdownOnUIThread() { 1199 void SimplePredictor::ShutdownOnUIThread() {
1200 SetShutdown(true); 1200 SetShutdown(true);
1201 } 1201 }
1202 1202
1203 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } 1203 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; }
1204 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } 1204 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; }
1205 1205
1206 } // namespace chrome_browser_net 1206 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698