| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/net/prediction_options.h" | 9 #include "chrome/browser/net/prediction_options.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ~HangingRequestInterceptor() override {} | 111 ~HangingRequestInterceptor() override {} |
| 112 | 112 |
| 113 net::URLRequestJob* MaybeInterceptRequest( | 113 net::URLRequestJob* MaybeInterceptRequest( |
| 114 net::URLRequest* request, | 114 net::URLRequest* request, |
| 115 net::NetworkDelegate* network_delegate) const override { | 115 net::NetworkDelegate* network_delegate) const override { |
| 116 if (!callback_.is_null()) | 116 if (!callback_.is_null()) |
| 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_); | 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_); |
| 118 return new HangingURLRequestJob(request, network_delegate); | 118 return new HangingURLRequestJob(request, network_delegate); |
| 119 } | 119 } |
| 120 | 120 |
| 121 net::URLRequestJob* MaybeInterceptResponse( |
| 122 net::URLRequest* request, |
| 123 net::NetworkDelegate* network_delegate) const override { |
| 124 return NULL; |
| 125 } |
| 126 |
| 127 net::URLRequestJob* MaybeInterceptRedirect( |
| 128 net::URLRequest* request, |
| 129 net::NetworkDelegate* network_delegate, |
| 130 const GURL& location) const override { |
| 131 return NULL; |
| 132 } |
| 133 |
| 121 private: | 134 private: |
| 122 base::Closure callback_; | 135 base::Closure callback_; |
| 123 }; | 136 }; |
| 124 | 137 |
| 125 void CreateHangingRequestInterceptorOnIO(const GURL& url, | 138 void CreateHangingRequestInterceptorOnIO(const GURL& url, |
| 126 base::Closure callback) { | 139 base::Closure callback) { |
| 127 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 140 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 128 scoped_ptr<net::URLRequestInterceptor> never_respond_handler( | 141 scoped_ptr<net::URLRequestInterceptor> never_respond_handler( |
| 129 new HangingRequestInterceptor(callback)); | 142 new HangingRequestInterceptor(callback)); |
| 130 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( | 143 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 kHangingUrl, | 223 kHangingUrl, |
| 211 loop_.QuitClosure())); | 224 loop_.QuitClosure())); |
| 212 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 225 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 213 content::RenderFrameHost* rfh = | 226 content::RenderFrameHost* rfh = |
| 214 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(); | 227 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(); |
| 215 rfh->Send(new PrefetchMsg_Prefetch(rfh->GetRoutingID(), kHangingUrl)); | 228 rfh->Send(new PrefetchMsg_Prefetch(rfh->GetRoutingID(), kHangingUrl)); |
| 216 loop_.Run(); | 229 loop_.Run(); |
| 217 } | 230 } |
| 218 | 231 |
| 219 } // namespace | 232 } // namespace |
| OLD | NEW |