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 // A Predictor object is instantiated once in the browser process, and manages | 5 // A Predictor object is instantiated once in the browser process, and manages |
6 // both preresolution of hostnames, as well as TCP/IP preconnection to expected | 6 // both preresolution of hostnames, as well as TCP/IP preconnection to expected |
7 // subresources. | 7 // subresources. |
8 // Most hostname lists are provided by the renderer processes, and include URLs | 8 // Most hostname lists are provided by the renderer processes, and include URLs |
9 // that *might* be used in the near future by the browsing user. One goal of | 9 // that *might* be used in the near future by the browsing user. One goal of |
10 // this class is to cause the underlying DNS structure to lookup a hostname | 10 // this class is to cause the underlying DNS structure to lookup a hostname |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // avoidance will kick in and all speculations in the queue will be discarded. | 108 // avoidance will kick in and all speculations in the queue will be discarded. |
109 static const int kMaxSpeculativeResolveQueueDelayMs; | 109 static const int kMaxSpeculativeResolveQueueDelayMs; |
110 | 110 |
111 // We don't bother learning to preconnect via a GET if the original URL | 111 // We don't bother learning to preconnect via a GET if the original URL |
112 // navigation was so long ago, that a preconnection would have been dropped | 112 // navigation was so long ago, that a preconnection would have been dropped |
113 // anyway. We believe most servers will drop the connection in 10 seconds, so | 113 // anyway. We believe most servers will drop the connection in 10 seconds, so |
114 // we currently estimate this time-till-drop at 10 seconds. | 114 // we currently estimate this time-till-drop at 10 seconds. |
115 // TODO(jar): We should do a persistent field trial to validate/optimize this. | 115 // TODO(jar): We should do a persistent field trial to validate/optimize this. |
116 static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet; | 116 static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet; |
117 | 117 |
| 118 // The default value of the credentials flag when preconnecting. |
| 119 static const bool kAllowCredentialsOnPreconnect; |
| 120 |
118 // |max_concurrent| specifies how many concurrent (parallel) prefetches will | 121 // |max_concurrent| specifies how many concurrent (parallel) prefetches will |
119 // be performed. Host lookups will be issued through |host_resolver|. | 122 // be performed. Host lookups will be issued through |host_resolver|. |
120 explicit Predictor(bool preconnect_enabled, bool predictor_enabled); | 123 explicit Predictor(bool preconnect_enabled, bool predictor_enabled); |
121 | 124 |
122 virtual ~Predictor(); | 125 virtual ~Predictor(); |
123 | 126 |
124 // This function is used to create a predictor. For testing, we can create | 127 // This function is used to create a predictor. For testing, we can create |
125 // a version which does a simpler shutdown. | 128 // a version which does a simpler shutdown. |
126 static Predictor* CreatePredictor(bool preconnect_enabled, | 129 static Predictor* CreatePredictor(bool preconnect_enabled, |
127 bool predictor_enabled, | 130 bool predictor_enabled, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 void SaveStateForNextStartupAndTrim(); | 239 void SaveStateForNextStartupAndTrim(); |
237 | 240 |
238 void SaveDnsPrefetchStateForNextStartupAndTrim( | 241 void SaveDnsPrefetchStateForNextStartupAndTrim( |
239 base::ListValue* startup_list, | 242 base::ListValue* startup_list, |
240 base::ListValue* referral_list, | 243 base::ListValue* referral_list, |
241 base::WaitableEvent* completion); | 244 base::WaitableEvent* completion); |
242 | 245 |
243 // May be called from either the IO or UI thread and will PostTask | 246 // May be called from either the IO or UI thread and will PostTask |
244 // to the IO thread if necessary. | 247 // to the IO thread if necessary. |
245 void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, | 248 void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, |
246 UrlInfo::ResolutionMotivation motivation, int count); | 249 UrlInfo::ResolutionMotivation motivation, int count, |
| 250 bool allow_credentials); |
247 | 251 |
248 void PreconnectUrlOnIOThread(const GURL& url, | 252 void PreconnectUrlOnIOThread(const GURL& url, |
249 const GURL& first_party_for_cookies, | 253 const GURL& first_party_for_cookies, |
250 UrlInfo::ResolutionMotivation motivation, | 254 UrlInfo::ResolutionMotivation motivation, |
251 int count); | 255 int count, |
| 256 bool allow_credentials); |
252 | 257 |
253 // ------------- End IO thread methods. | 258 // ------------- End IO thread methods. |
254 | 259 |
255 // The following methods may be called on either the IO or UI threads. | 260 // The following methods may be called on either the IO or UI threads. |
256 | 261 |
257 // Instigate pre-connection to any URLs, or pre-resolution of related host, | 262 // Instigate pre-connection to any URLs, or pre-resolution of related host, |
258 // that we predict will be needed after this navigation (typically | 263 // that we predict will be needed after this navigation (typically |
259 // more-embedded resources on a page). This method will actually post a task | 264 // more-embedded resources on a page). This method will actually post a task |
260 // to do the actual work, so as not to jump ahead of the frame navigation that | 265 // to do the actual work, so as not to jump ahead of the frame navigation that |
261 // instigated this activity. | 266 // instigated this activity. |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 614 |
610 private: | 615 private: |
611 // These member functions return True for unittests. | 616 // These member functions return True for unittests. |
612 bool CanPrefetchAndPrerender() const override; | 617 bool CanPrefetchAndPrerender() const override; |
613 bool CanPreresolveAndPreconnect() const override; | 618 bool CanPreresolveAndPreconnect() const override; |
614 }; | 619 }; |
615 | 620 |
616 } // namespace chrome_browser_net | 621 } // namespace chrome_browser_net |
617 | 622 |
618 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 623 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
OLD | NEW |