| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/trace_event/trace_event.h" |
| 7 #include "chrome/browser/net/predictor.h" | 8 #include "chrome/browser/net/predictor.h" |
| 8 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
| 9 #include "content/public/common/resource_type.h" | 10 #include "content/public/common/resource_type.h" |
| 10 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
| 11 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 12 | 13 |
| 13 namespace chrome_browser_net { | 14 namespace chrome_browser_net { |
| 14 | 15 |
| 15 ConnectInterceptor::ConnectInterceptor(Predictor* predictor) | 16 ConnectInterceptor::ConnectInterceptor(Predictor* predictor) |
| 16 : timed_cache_(base::TimeDelta::FromSeconds( | 17 : timed_cache_(base::TimeDelta::FromSeconds( |
| 17 Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet)), | 18 Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet)), |
| 18 predictor_(predictor) { | 19 predictor_(predictor) { |
| 19 DCHECK(predictor); | 20 DCHECK(predictor); |
| 20 } | 21 } |
| 21 | 22 |
| 22 ConnectInterceptor::~ConnectInterceptor() { | 23 ConnectInterceptor::~ConnectInterceptor() { |
| 23 } | 24 } |
| 24 | 25 |
| 25 void ConnectInterceptor::WitnessURLRequest(net::URLRequest* request) { | 26 void ConnectInterceptor::WitnessURLRequest(net::URLRequest* request) { |
| 27 TRACE_EVENT0("toplevel", "ConnectInterceptor::WitnessURLRequest"); |
| 28 |
| 26 GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url())); | 29 GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url())); |
| 27 if (request_scheme_host == GURL::EmptyGURL()) | 30 if (request_scheme_host == GURL::EmptyGURL()) |
| 28 return; | 31 return; |
| 29 | 32 |
| 30 const content::ResourceRequestInfo* info = | 33 const content::ResourceRequestInfo* info = |
| 31 content::ResourceRequestInfo::ForRequest(request); | 34 content::ResourceRequestInfo::ForRequest(request); |
| 32 bool is_main_frame = false; | 35 bool is_main_frame = false; |
| 33 bool is_sub_frame = false; | 36 bool is_sub_frame = false; |
| 34 // TODO(mmenke): Should the predictor really be fed requests without a | 37 // TODO(mmenke): Should the predictor really be fed requests without a |
| 35 // ResourceRequestInfo? | 38 // ResourceRequestInfo? |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // main frame request - way back in RenderViewHost::Navigate. So only handle | 92 // main frame request - way back in RenderViewHost::Navigate. So only handle |
| 90 // predictions now for subresources or for redirected hosts. | 93 // predictions now for subresources or for redirected hosts. |
| 91 if (is_sub_frame || redirected_host) { | 94 if (is_sub_frame || redirected_host) { |
| 92 predictor_->PredictFrameSubresources(request_scheme_host, | 95 predictor_->PredictFrameSubresources(request_scheme_host, |
| 93 request->first_party_for_cookies()); | 96 request->first_party_for_cookies()); |
| 94 } | 97 } |
| 95 return; | 98 return; |
| 96 } | 99 } |
| 97 | 100 |
| 98 } // namespace chrome_browser_net | 101 } // namespace chrome_browser_net |
| OLD | NEW |