| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 // Only for testing. Returns true if hostname has been successfully resolved | 362 // Only for testing. Returns true if hostname has been successfully resolved |
| 363 // (name found). | 363 // (name found). |
| 364 bool WasFound(const GURL& url) const { | 364 bool WasFound(const GURL& url) const { |
| 365 Results::const_iterator it(results_.find(url)); | 365 Results::const_iterator it(results_.find(url)); |
| 366 return (it != results_.end()) && | 366 return (it != results_.end()) && |
| 367 it->second.was_found(); | 367 it->second.was_found(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 // Only for testing. Return how long was the resolution | 370 // Only for testing. Return how long was the resolution |
| 371 // or UrlInfo::kNullDuration if it hasn't been resolved yet. | 371 // or UrlInfo::NullDuration() if it hasn't been resolved yet. |
| 372 base::TimeDelta GetResolutionDuration(const GURL& url) { | 372 base::TimeDelta GetResolutionDuration(const GURL& url) { |
| 373 if (results_.find(url) == results_.end()) | 373 if (results_.find(url) == results_.end()) |
| 374 return UrlInfo::kNullDuration; | 374 return UrlInfo::NullDuration(); |
| 375 return results_[url].resolve_duration(); | 375 return results_[url].resolve_duration(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 // Only for testing; | 378 // Only for testing; |
| 379 size_t peak_pending_lookups() const { return peak_pending_lookups_; } | 379 size_t peak_pending_lookups() const { return peak_pending_lookups_; } |
| 380 | 380 |
| 381 // ------------- Start IO thread methods. | 381 // ------------- Start IO thread methods. |
| 382 | 382 |
| 383 // Perform actual resolution or preconnection to subresources now. This is | 383 // Perform actual resolution or preconnection to subresources now. This is |
| 384 // an internal worker method that is reached via a post task from | 384 // an internal worker method that is reached via a post task from |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 PrefService* user_prefs, | 514 PrefService* user_prefs, |
| 515 PrefService* local_state, | 515 PrefService* local_state, |
| 516 IOThread* io_thread, | 516 IOThread* io_thread, |
| 517 net::URLRequestContextGetter* getter) OVERRIDE; | 517 net::URLRequestContextGetter* getter) OVERRIDE; |
| 518 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; | 518 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; |
| 519 }; | 519 }; |
| 520 | 520 |
| 521 } // namespace chrome_browser_net | 521 } // namespace chrome_browser_net |
| 522 | 522 |
| 523 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 523 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |