| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/connect_interceptor.h" | 5 #include "chrome/browser/net/connect_interceptor.h" |
| 6 | 6 |
| 7 #include "chrome/browser/net/predictor.h" | 7 #include "chrome/browser/net/predictor.h" |
| 8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
| 9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 : timed_cache_(base::TimeDelta::FromSeconds( | 21 : timed_cache_(base::TimeDelta::FromSeconds( |
| 22 kMaxUnusedSocketLifetimeSecondsWithoutAGet)), | 22 kMaxUnusedSocketLifetimeSecondsWithoutAGet)), |
| 23 predictor_(predictor) { | 23 predictor_(predictor) { |
| 24 DCHECK(predictor); | 24 DCHECK(predictor); |
| 25 } | 25 } |
| 26 | 26 |
| 27 ConnectInterceptor::~ConnectInterceptor() { | 27 ConnectInterceptor::~ConnectInterceptor() { |
| 28 } | 28 } |
| 29 | 29 |
| 30 net::URLRequestJob* ConnectInterceptor::MaybeIntercept( | 30 net::URLRequestJob* ConnectInterceptor::MaybeIntercept( |
| 31 net::URLRequest* request) const { | 31 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| 32 GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url())); | 32 GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url())); |
| 33 if (request_scheme_host == GURL::EmptyGURL()) | 33 if (request_scheme_host == GURL::EmptyGURL()) |
| 34 return NULL; | 34 return NULL; |
| 35 | 35 |
| 36 // Learn what URLs are likely to be needed during next startup. | 36 // Learn what URLs are likely to be needed during next startup. |
| 37 predictor_->LearnAboutInitialNavigation(request_scheme_host); | 37 predictor_->LearnAboutInitialNavigation(request_scheme_host); |
| 38 | 38 |
| 39 bool redirected_host = false; | 39 bool redirected_host = false; |
| 40 if (request->referrer().empty()) { | 40 if (request->referrer().empty()) { |
| 41 if (request->url() != request->original_url()) { | 41 if (request->url() != request->original_url()) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 return mru_cache_.end() != mru_cache_.Peek(url); | 120 return mru_cache_.end() != mru_cache_.Peek(url); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) const { | 123 void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) const { |
| 124 DCHECK_EQ(url.GetWithEmptyPath(), url); | 124 DCHECK_EQ(url.GetWithEmptyPath(), url); |
| 125 mru_cache_.Put(url, base::TimeTicks::Now()); | 125 mru_cache_.Put(url, base::TimeTicks::Now()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace chrome_browser_net | 128 } // namespace chrome_browser_net |
| OLD | NEW |