OLD | NEW |
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> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
27 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
29 #include "base/time/time.h" | 29 #include "base/time/time.h" |
30 #include "base/trace_event/trace_event.h" | 30 #include "base/trace_event/trace_event.h" |
31 #include "base/values.h" | 31 #include "base/values.h" |
32 #include "build/build_config.h" | 32 #include "build/build_config.h" |
33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
34 #include "chrome/browser/prefs/session_startup_pref.h" | 34 #include "chrome/browser/prefs/session_startup_pref.h" |
35 #include "chrome/browser/profiles/profile_io_data.h" | 35 #include "chrome/browser/profiles/profile_io_data.h" |
| 36 #include "chrome/common/chrome_features.h" |
36 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
37 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
38 #include "components/pref_registry/pref_registry_syncable.h" | 39 #include "components/pref_registry/pref_registry_syncable.h" |
39 #include "components/prefs/pref_service.h" | 40 #include "components/prefs/pref_service.h" |
40 #include "components/prefs/scoped_user_pref_update.h" | 41 #include "components/prefs/scoped_user_pref_update.h" |
41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/resource_hints.h" | 43 #include "content/public/browser/resource_hints.h" |
43 #include "net/base/address_list.h" | 44 #include "net/base/address_list.h" |
44 #include "net/base/completion_callback.h" | 45 #include "net/base/completion_callback.h" |
45 #include "net/base/host_port_pair.h" | 46 #include "net/base/host_port_pair.h" |
46 #include "net/base/net_errors.h" | 47 #include "net/base/net_errors.h" |
47 #include "net/http/transport_security_state.h" | 48 #include "net/http/transport_security_state.h" |
48 #include "net/log/net_log_with_source.h" | 49 #include "net/log/net_log_with_source.h" |
49 #include "net/proxy/proxy_info.h" | 50 #include "net/proxy/proxy_info.h" |
50 #include "net/proxy/proxy_service.h" | 51 #include "net/proxy/proxy_service.h" |
51 #include "net/ssl/ssl_config_service.h" | 52 #include "net/ssl/ssl_config_service.h" |
52 #include "net/url_request/url_request_context.h" | 53 #include "net/url_request/url_request_context.h" |
53 #include "net/url_request/url_request_context_getter.h" | 54 #include "net/url_request/url_request_context_getter.h" |
54 | 55 |
55 using base::TimeDelta; | 56 using base::TimeDelta; |
56 using content::BrowserThread; | 57 using content::BrowserThread; |
57 | 58 |
58 namespace chrome_browser_net { | 59 namespace chrome_browser_net { |
59 | 60 |
60 namespace { | 61 namespace { |
61 | 62 |
62 const base::Feature kNetworkPrediction{"NetworkPrediction", | |
63 base::FEATURE_ENABLED_BY_DEFAULT}; | |
64 | |
65 #if defined(OS_ANDROID) | 63 #if defined(OS_ANDROID) |
66 // Disabled on Android, as there are no "pinned tabs", meaning that a startup | 64 // Disabled on Android, as there are no "pinned tabs", meaning that a startup |
67 // is unlikely to request the same URL, and hence to resolve the same domains | 65 // is unlikely to request the same URL, and hence to resolve the same domains |
68 // as the previous one. | 66 // as the previous one. |
69 constexpr bool kInitialDnsPrefetchListEnabled = false; | 67 constexpr bool kInitialDnsPrefetchListEnabled = false; |
70 #else | 68 #else |
71 constexpr bool kInitialDnsPrefetchListEnabled = true; | 69 constexpr bool kInitialDnsPrefetchListEnabled = true; |
72 #endif // defined(OS_ANDROID) | 70 #endif // defined(OS_ANDROID) |
73 | 71 |
74 } // namespace | 72 } // namespace |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 162 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
165 } | 163 } |
166 | 164 |
167 Predictor::~Predictor() { | 165 Predictor::~Predictor() { |
168 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 166 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
169 DCHECK(shutdown_); | 167 DCHECK(shutdown_); |
170 } | 168 } |
171 | 169 |
172 // static | 170 // static |
173 Predictor* Predictor::CreatePredictor(bool simple_shutdown) { | 171 Predictor* Predictor::CreatePredictor(bool simple_shutdown) { |
174 bool predictor_enabled = base::FeatureList::IsEnabled(kNetworkPrediction); | 172 bool predictor_enabled = |
| 173 base::FeatureList::IsEnabled(features::kNetworkPrediction); |
175 if (simple_shutdown) | 174 if (simple_shutdown) |
176 return new SimplePredictor(predictor_enabled); | 175 return new SimplePredictor(predictor_enabled); |
177 return new Predictor(predictor_enabled); | 176 return new Predictor(predictor_enabled); |
178 } | 177 } |
179 | 178 |
180 void Predictor::RegisterProfilePrefs( | 179 void Predictor::RegisterProfilePrefs( |
181 user_prefs::PrefRegistrySyncable* registry) { | 180 user_prefs::PrefRegistrySyncable* registry) { |
182 registry->RegisterListPref(prefs::kDnsPrefetchingStartupList, | 181 registry->RegisterListPref(prefs::kDnsPrefetchingStartupList, |
183 PrefRegistry::LOSSY_PREF); | 182 PrefRegistry::LOSSY_PREF); |
184 registry->RegisterListPref(prefs::kDnsPrefetchingHostReferralList, | 183 registry->RegisterListPref(prefs::kDnsPrefetchingHostReferralList, |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 } | 1236 } |
1238 | 1237 |
1239 void SimplePredictor::ShutdownOnUIThread() { | 1238 void SimplePredictor::ShutdownOnUIThread() { |
1240 SetShutdown(true); | 1239 SetShutdown(true); |
1241 } | 1240 } |
1242 | 1241 |
1243 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } | 1242 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } |
1244 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } | 1243 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } |
1245 | 1244 |
1246 } // namespace chrome_browser_net | 1245 } // namespace chrome_browser_net |
OLD | NEW |