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

Side by Side Diff: chrome/browser/errorpage_browsertest.cc

Issue 686343002: Add MaybeInterceptRedirect/Response to URLRequestInterceptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return new URLRequestFailedJob(request, 169 return new URLRequestFailedJob(request,
170 network_delegate, 170 network_delegate,
171 net::ERR_CONNECTION_RESET); 171 net::ERR_CONNECTION_RESET);
172 } else { 172 } else {
173 return new URLRequestTestJob(request, network_delegate, 173 return new URLRequestTestJob(request, network_delegate,
174 URLRequestTestJob::test_headers(), 174 URLRequestTestJob::test_headers(),
175 URLRequestTestJob::test_data_1(), 175 URLRequestTestJob::test_data_1(),
176 true); 176 true);
177 } 177 }
178 } 178 }
179 net::URLRequestJob* MaybeInterceptResponse(
180 net::URLRequest* request,
181 net::NetworkDelegate* network_delegate) const override {
182 return NULL;
183 }
184
185 net::URLRequestJob* MaybeInterceptRedirect(
186 net::URLRequest* request,
187 net::NetworkDelegate* network_delegate,
188 const GURL& location) const override {
189 return NULL;
190 }
179 191
180 int requests() const { return requests_; } 192 int requests() const { return requests_; }
181 int failures() const { return failures_; } 193 int failures() const { return failures_; }
182 194
183 private: 195 private:
184 // These are mutable because MaybeCreateJob is const but we want this state 196 // These are mutable because MaybeCreateJob is const but we want this state
185 // for testing. 197 // for testing.
186 mutable int requests_; 198 mutable int requests_;
187 mutable int failures_; 199 mutable int failures_;
188 int requests_to_fail_; 200 int requests_to_fail_;
(...skipping 27 matching lines...) Expand all
216 base::FilePath root_http; 228 base::FilePath root_http;
217 PathService::Get(chrome::DIR_TEST_DATA, &root_http); 229 PathService::Get(chrome::DIR_TEST_DATA, &root_http);
218 return new net::URLRequestMockHTTPJob( 230 return new net::URLRequestMockHTTPJob(
219 request, 231 request,
220 network_delegate, 232 network_delegate,
221 root_http.AppendASCII("mock-link-doctor.json"), 233 root_http.AppendASCII("mock-link-doctor.json"),
222 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 234 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
223 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 235 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
224 } 236 }
225 237
238 net::URLRequestJob* MaybeInterceptResponse(
239 net::URLRequest* request,
240 net::NetworkDelegate* network_delegate) const override {
241 return NULL;
242 }
243
244 net::URLRequestJob* MaybeInterceptRedirect(
245 net::URLRequest* request,
246 net::NetworkDelegate* network_delegate,
247 const GURL& location) const override {
248 return NULL;
249 }
250
226 void WaitForRequests(int requests_to_wait_for) { 251 void WaitForRequests(int requests_to_wait_for) {
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
228 DCHECK_EQ(-1, requests_to_wait_for_); 253 DCHECK_EQ(-1, requests_to_wait_for_);
229 DCHECK(!run_loop_); 254 DCHECK(!run_loop_);
230 255
231 if (requests_to_wait_for >= num_requests_) 256 if (requests_to_wait_for >= num_requests_)
232 return; 257 return;
233 258
234 requests_to_wait_for_ = requests_to_wait_for; 259 requests_to_wait_for_ = requests_to_wait_for;
235 run_loop_.reset(new base::RunLoop()); 260 run_loop_.reset(new base::RunLoop());
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 965
941 // net::URLRequestInterceptor: 966 // net::URLRequestInterceptor:
942 net::URLRequestJob* MaybeInterceptRequest( 967 net::URLRequestJob* MaybeInterceptRequest(
943 net::URLRequest* request, 968 net::URLRequest* request,
944 net::NetworkDelegate* network_delegate) const override { 969 net::NetworkDelegate* network_delegate) const override {
945 return new URLRequestFailedJob(request, 970 return new URLRequestFailedJob(request,
946 network_delegate, 971 network_delegate,
947 net::ERR_ADDRESS_UNREACHABLE); 972 net::ERR_ADDRESS_UNREACHABLE);
948 } 973 }
949 974
975 net::URLRequestJob* MaybeInterceptResponse(
976 net::URLRequest* request,
977 net::NetworkDelegate* network_delegate) const override {
978 return NULL;
979 }
980
981 net::URLRequestJob* MaybeInterceptRedirect(
982 net::URLRequest* request,
983 net::NetworkDelegate* network_delegate,
984 const GURL& location) const override {
985 return NULL;
986 }
987
950 private: 988 private:
951 DISALLOW_COPY_AND_ASSIGN(AddressUnreachableInterceptor); 989 DISALLOW_COPY_AND_ASSIGN(AddressUnreachableInterceptor);
952 }; 990 };
953 991
954 // A test fixture that returns ERR_ADDRESS_UNREACHABLE for all navigation 992 // A test fixture that returns ERR_ADDRESS_UNREACHABLE for all navigation
955 // correction requests. ERR_NAME_NOT_RESOLVED is more typical, but need to use 993 // correction requests. ERR_NAME_NOT_RESOLVED is more typical, but need to use
956 // a different error for the correction service and the original page to 994 // a different error for the correction service and the original page to
957 // validate the right page is being displayed. 995 // validate the right page is being displayed.
958 class ErrorPageNavigationCorrectionsFailTest : public ErrorPageTest { 996 class ErrorPageNavigationCorrectionsFailTest : public ErrorPageTest {
959 public: 997 public:
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 browser(), 1136 browser(),
1099 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, 1137 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT,
1100 kHostname), 1138 kHostname),
1101 1); 1139 1);
1102 1140
1103 ToggleHelpBox(browser()); 1141 ToggleHelpBox(browser());
1104 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); 1142 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode));
1105 } 1143 }
1106 1144
1107 } // namespace 1145 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698