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

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: 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 (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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 179
180 net::URLRequestJob* MaybeInterceptRedirect(
181 net::URLRequest* request,
182 net::NetworkDelegate* network_delegate,
183 const GURL& location) const override {
184 return NULL;
185 }
186
187 net::URLRequestJob* MaybeInterceptResponse(
188 net::URLRequest* request,
189 net::NetworkDelegate* network_delegate) const override {
190 return NULL;
191 }
192
180 int requests() const { return requests_; } 193 int requests() const { return requests_; }
181 int failures() const { return failures_; } 194 int failures() const { return failures_; }
182 195
183 private: 196 private:
184 // These are mutable because MaybeCreateJob is const but we want this state 197 // These are mutable because MaybeCreateJob is const but we want this state
185 // for testing. 198 // for testing.
186 mutable int requests_; 199 mutable int requests_;
187 mutable int failures_; 200 mutable int failures_;
188 int requests_to_fail_; 201 int requests_to_fail_;
189 202
(...skipping 26 matching lines...) Expand all
216 base::FilePath root_http; 229 base::FilePath root_http;
217 PathService::Get(chrome::DIR_TEST_DATA, &root_http); 230 PathService::Get(chrome::DIR_TEST_DATA, &root_http);
218 return new net::URLRequestMockHTTPJob( 231 return new net::URLRequestMockHTTPJob(
219 request, 232 request,
220 network_delegate, 233 network_delegate,
221 root_http.AppendASCII("mock-link-doctor.json"), 234 root_http.AppendASCII("mock-link-doctor.json"),
222 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 235 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
223 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 236 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
224 } 237 }
225 238
239 net::URLRequestJob* MaybeInterceptRedirect(
240 net::URLRequest* request,
241 net::NetworkDelegate* network_delegate,
242 const GURL& location) const override {
243 return NULL;
244 }
245
246 net::URLRequestJob* MaybeInterceptResponse(
247 net::URLRequest* request,
248 net::NetworkDelegate* network_delegate) const override {
249 return NULL;
250 }
251
226 void WaitForRequests(int requests_to_wait_for) { 252 void WaitForRequests(int requests_to_wait_for) {
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
228 DCHECK_EQ(-1, requests_to_wait_for_); 254 DCHECK_EQ(-1, requests_to_wait_for_);
229 DCHECK(!run_loop_); 255 DCHECK(!run_loop_);
230 256
231 if (requests_to_wait_for >= num_requests_) 257 if (requests_to_wait_for >= num_requests_)
232 return; 258 return;
233 259
234 requests_to_wait_for_ = requests_to_wait_for; 260 requests_to_wait_for_ = requests_to_wait_for;
235 run_loop_.reset(new base::RunLoop()); 261 run_loop_.reset(new base::RunLoop());
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 966
941 // net::URLRequestInterceptor: 967 // net::URLRequestInterceptor:
942 net::URLRequestJob* MaybeInterceptRequest( 968 net::URLRequestJob* MaybeInterceptRequest(
943 net::URLRequest* request, 969 net::URLRequest* request,
944 net::NetworkDelegate* network_delegate) const override { 970 net::NetworkDelegate* network_delegate) const override {
945 return new URLRequestFailedJob(request, 971 return new URLRequestFailedJob(request,
946 network_delegate, 972 network_delegate,
947 net::ERR_ADDRESS_UNREACHABLE); 973 net::ERR_ADDRESS_UNREACHABLE);
948 } 974 }
949 975
976 net::URLRequestJob* MaybeInterceptResponse(
977 net::URLRequest* request,
978 net::NetworkDelegate* network_delegate) const override {
979 return NULL;
980 }
981
982 net::URLRequestJob* MaybeInterceptRedirect(
983 net::URLRequest* request,
984 net::NetworkDelegate* network_delegate,
985 const GURL& location) const override {
986 return NULL;
987 }
988
950 private: 989 private:
951 DISALLOW_COPY_AND_ASSIGN(AddressUnreachableInterceptor); 990 DISALLOW_COPY_AND_ASSIGN(AddressUnreachableInterceptor);
952 }; 991 };
953 992
954 // A test fixture that returns ERR_ADDRESS_UNREACHABLE for all navigation 993 // 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 994 // 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 995 // a different error for the correction service and the original page to
957 // validate the right page is being displayed. 996 // validate the right page is being displayed.
958 class ErrorPageNavigationCorrectionsFailTest : public ErrorPageTest { 997 class ErrorPageNavigationCorrectionsFailTest : public ErrorPageTest {
959 public: 998 public:
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 browser(), 1137 browser(),
1099 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, 1138 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT,
1100 kHostname), 1139 kHostname),
1101 1); 1140 1);
1102 1141
1103 ToggleHelpBox(browser()); 1142 ToggleHelpBox(browser());
1104 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); 1143 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode));
1105 } 1144 }
1106 1145
1107 } // namespace 1146 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698