Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1348)

Side by Side Diff: chrome/browser/prefetch/prefetch_browsertest.cc

Issue 686343002: Add MaybeInterceptRedirect/Response to URLRequestInterceptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests, removed DRP Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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* MaybeInterceptRedirect(
122 net::URLRequest* request,
123 net::NetworkDelegate* network_delegate,
124 const GURL& location) const override {
125 return NULL;
126 }
127
128 net::URLRequestJob* MaybeInterceptResponse(
129 net::URLRequest* request,
130 net::NetworkDelegate* network_delegate) 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698