OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_api.h" | 7 #include "chrome/browser/net/predictor_api.h" |
8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
9 | 9 |
10 namespace chrome_browser_net { | 10 namespace chrome_browser_net { |
11 | 11 |
12 ConnectInterceptor::ConnectInterceptor() { | 12 ConnectInterceptor::ConnectInterceptor() { |
13 URLRequest::RegisterRequestInterceptor(this); | 13 URLRequest::RegisterRequestInterceptor(this); |
14 } | 14 } |
15 | 15 |
16 ConnectInterceptor::~ConnectInterceptor() { | 16 ConnectInterceptor::~ConnectInterceptor() { |
17 URLRequest::UnregisterRequestInterceptor(this); | 17 URLRequest::UnregisterRequestInterceptor(this); |
18 } | 18 } |
19 | 19 |
20 URLRequestJob* ConnectInterceptor::MaybeIntercept(URLRequest* request) { | 20 net::URLRequestJob* ConnectInterceptor::MaybeIntercept( |
| 21 net::URLRequest* request) { |
21 // Learn what URLs are likely to be needed during next startup. | 22 // Learn what URLs are likely to be needed during next startup. |
22 // Pass actual URL, rather than WithEmptyPath, as we often won't need to do | 23 // Pass actual URL, rather than WithEmptyPath, as we often won't need to do |
23 // the canonicalization. | 24 // the canonicalization. |
24 LearnAboutInitialNavigation(request->url()); | 25 LearnAboutInitialNavigation(request->url()); |
25 | 26 |
26 bool is_subresource = !(request->load_flags() & net::LOAD_MAIN_FRAME); | 27 bool is_subresource = !(request->load_flags() & net::LOAD_MAIN_FRAME); |
27 if (is_subresource && !request->referrer().empty()) { | 28 if (is_subresource && !request->referrer().empty()) { |
28 // Learn about our referring URL, for use in the future. | 29 // Learn about our referring URL, for use in the future. |
29 GURL referring_url(GURL(request->referrer()).GetWithEmptyPath()); | 30 GURL referring_url(GURL(request->referrer()).GetWithEmptyPath()); |
30 GURL request_url(request->url().GetWithEmptyPath()); | 31 GURL request_url(request->url().GetWithEmptyPath()); |
(...skipping 10 matching lines...) Expand all Loading... |
41 } | 42 } |
42 | 43 |
43 // Subresources for main frames usually get loaded when we detected the main | 44 // Subresources for main frames usually get loaded when we detected the main |
44 // frame - way back in RenderViewHost::Navigate. So only use subresource | 45 // frame - way back in RenderViewHost::Navigate. So only use subresource |
45 // prediction here for subframes. | 46 // prediction here for subframes. |
46 if (request->load_flags() & net::LOAD_SUB_FRAME) | 47 if (request->load_flags() & net::LOAD_SUB_FRAME) |
47 PredictFrameSubresources(request->url().GetWithEmptyPath()); | 48 PredictFrameSubresources(request->url().GetWithEmptyPath()); |
48 return NULL; | 49 return NULL; |
49 } | 50 } |
50 | 51 |
51 URLRequestJob* ConnectInterceptor::MaybeInterceptResponse(URLRequest* request) { | 52 net::URLRequestJob* ConnectInterceptor::MaybeInterceptResponse( |
| 53 net::URLRequest* request) { |
52 return NULL; | 54 return NULL; |
53 } | 55 } |
54 | 56 |
55 URLRequestJob* ConnectInterceptor::MaybeInterceptRedirect( | 57 net::URLRequestJob* ConnectInterceptor::MaybeInterceptRedirect( |
56 URLRequest* request, | 58 net::URLRequest* request, |
57 const GURL& location) { | 59 const GURL& location) { |
58 return NULL; | 60 return NULL; |
59 } | 61 } |
60 | 62 |
61 } // namespace chrome_browser_net | 63 } // namespace chrome_browser_net |
OLD | NEW |