OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 TestDelegate::~TestDelegate() {} | 182 TestDelegate::~TestDelegate() {} |
183 | 183 |
184 void TestDelegate::OnReceivedRedirect(net::URLRequest* request, | 184 void TestDelegate::OnReceivedRedirect(net::URLRequest* request, |
185 const GURL& new_url, | 185 const GURL& new_url, |
186 bool* defer_redirect) { | 186 bool* defer_redirect) { |
187 received_redirect_count_++; | 187 received_redirect_count_++; |
188 if (quit_on_redirect_) { | 188 if (quit_on_redirect_) { |
189 *defer_redirect = true; | 189 *defer_redirect = true; |
190 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 190 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
191 } else if (cancel_in_rr_) { | 191 } else if (cancel_in_rr_) { |
192 request->Cancel(); | 192 request->Cancel(); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void TestDelegate::OnAuthRequired(net::URLRequest* request, | 196 void TestDelegate::OnAuthRequired(net::URLRequest* request, |
197 net::AuthChallengeInfo* auth_info) { | 197 net::AuthChallengeInfo* auth_info) { |
198 auth_required_ = true; | 198 auth_required_ = true; |
199 if (!credentials_.Empty()) { | 199 if (!credentials_.Empty()) { |
200 request->SetAuth(credentials_); | 200 request->SetAuth(credentials_); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 304 } |
305 } | 305 } |
306 if (!request->status().is_io_pending()) | 306 if (!request->status().is_io_pending()) |
307 OnResponseCompleted(request); | 307 OnResponseCompleted(request); |
308 else if (cancel_in_rd_pending_) | 308 else if (cancel_in_rd_pending_) |
309 request->Cancel(); | 309 request->Cancel(); |
310 } | 310 } |
311 | 311 |
312 void TestDelegate::OnResponseCompleted(net::URLRequest* request) { | 312 void TestDelegate::OnResponseCompleted(net::URLRequest* request) { |
313 if (quit_on_complete_) | 313 if (quit_on_complete_) |
314 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 314 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
315 } | 315 } |
316 | 316 |
317 TestNetworkDelegate::TestNetworkDelegate() | 317 TestNetworkDelegate::TestNetworkDelegate() |
318 : last_error_(0), | 318 : last_error_(0), |
319 error_count_(0), | 319 error_count_(0), |
320 created_requests_(0), | 320 created_requests_(0), |
321 destroyed_requests_(0), | 321 destroyed_requests_(0), |
322 completed_requests_(0) { | 322 completed_requests_(0) { |
323 } | 323 } |
324 | 324 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 event_order_[req_id] += "OnAuthRequired\n"; | 489 event_order_[req_id] += "OnAuthRequired\n"; |
490 EXPECT_TRUE(next_states_[req_id] & kStageAuthRequired) << | 490 EXPECT_TRUE(next_states_[req_id] & kStageAuthRequired) << |
491 event_order_[req_id]; | 491 event_order_[req_id]; |
492 next_states_[req_id] = kStageBeforeSendHeaders | | 492 next_states_[req_id] = kStageBeforeSendHeaders | |
493 kStageHeadersReceived | // Request canceled by delegate simulates empty | 493 kStageHeadersReceived | // Request canceled by delegate simulates empty |
494 // response. | 494 // response. |
495 kStageResponseStarted | // data: URLs do not trigger sending headers | 495 kStageResponseStarted | // data: URLs do not trigger sending headers |
496 kStageBeforeRedirect; // a delegate can trigger a redirection | 496 kStageBeforeRedirect; // a delegate can trigger a redirection |
497 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 497 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
498 } | 498 } |
OLD | NEW |