OLD | NEW |
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 "net/url_request/url_request_test_util.h" | 5 #include "net/url_request/url_request_test_util.h" |
6 | 6 |
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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 return network_task_runner_; | 161 return network_task_runner_; |
162 } | 162 } |
163 | 163 |
164 TestDelegate::TestDelegate() | 164 TestDelegate::TestDelegate() |
165 : cancel_in_rr_(false), | 165 : cancel_in_rr_(false), |
166 cancel_in_rs_(false), | 166 cancel_in_rs_(false), |
167 cancel_in_rd_(false), | 167 cancel_in_rd_(false), |
168 cancel_in_rd_pending_(false), | 168 cancel_in_rd_pending_(false), |
169 quit_on_complete_(true), | 169 quit_on_complete_(true), |
170 quit_on_redirect_(false), | 170 quit_on_redirect_(false), |
| 171 quit_on_before_network_start_(false), |
171 allow_certificate_errors_(false), | 172 allow_certificate_errors_(false), |
172 response_started_count_(0), | 173 response_started_count_(0), |
173 received_bytes_count_(0), | 174 received_bytes_count_(0), |
174 received_redirect_count_(0), | 175 received_redirect_count_(0), |
| 176 received_before_network_start_count_(0), |
175 received_data_before_response_(false), | 177 received_data_before_response_(false), |
176 request_failed_(false), | 178 request_failed_(false), |
177 have_certificate_errors_(false), | 179 have_certificate_errors_(false), |
178 certificate_errors_are_fatal_(false), | 180 certificate_errors_are_fatal_(false), |
179 auth_required_(false), | 181 auth_required_(false), |
180 have_full_request_headers_(false), | 182 have_full_request_headers_(false), |
181 buf_(new IOBuffer(kBufferSize)) { | 183 buf_(new IOBuffer(kBufferSize)) { |
182 } | 184 } |
183 | 185 |
184 TestDelegate::~TestDelegate() {} | 186 TestDelegate::~TestDelegate() {} |
(...skipping 14 matching lines...) Expand all Loading... |
199 received_redirect_count_++; | 201 received_redirect_count_++; |
200 if (quit_on_redirect_) { | 202 if (quit_on_redirect_) { |
201 *defer_redirect = true; | 203 *defer_redirect = true; |
202 base::MessageLoop::current()->PostTask(FROM_HERE, | 204 base::MessageLoop::current()->PostTask(FROM_HERE, |
203 base::MessageLoop::QuitClosure()); | 205 base::MessageLoop::QuitClosure()); |
204 } else if (cancel_in_rr_) { | 206 } else if (cancel_in_rr_) { |
205 request->Cancel(); | 207 request->Cancel(); |
206 } | 208 } |
207 } | 209 } |
208 | 210 |
| 211 void TestDelegate::OnBeforeNetworkStart(URLRequest* request, bool* defer) { |
| 212 received_before_network_start_count_++; |
| 213 if (quit_on_before_network_start_) { |
| 214 *defer = true; |
| 215 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 216 base::MessageLoop::QuitClosure()); |
| 217 } |
| 218 } |
| 219 |
209 void TestDelegate::OnAuthRequired(URLRequest* request, | 220 void TestDelegate::OnAuthRequired(URLRequest* request, |
210 AuthChallengeInfo* auth_info) { | 221 AuthChallengeInfo* auth_info) { |
211 auth_required_ = true; | 222 auth_required_ = true; |
212 if (!credentials_.Empty()) { | 223 if (!credentials_.Empty()) { |
213 request->SetAuth(credentials_); | 224 request->SetAuth(credentials_); |
214 } else { | 225 } else { |
215 request->CancelAuth(); | 226 request->CancelAuth(); |
216 } | 227 } |
217 } | 228 } |
218 | 229 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 URLRequestJob* job = main_intercept_job_; | 614 URLRequestJob* job = main_intercept_job_; |
604 main_intercept_job_ = NULL; | 615 main_intercept_job_ = NULL; |
605 return job; | 616 return job; |
606 } | 617 } |
607 | 618 |
608 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) { | 619 void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) { |
609 main_intercept_job_ = job; | 620 main_intercept_job_ = job; |
610 } | 621 } |
611 | 622 |
612 } // namespace net | 623 } // namespace net |
OLD | NEW |