OLD | NEW |
1 // Copyright (c) 2010 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 #ifndef NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include <sstream> | 11 #include <sstream> |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 virtual void OnResponseStarted(net::URLRequest* request) { | 232 virtual void OnResponseStarted(net::URLRequest* request) { |
233 // It doesn't make sense for the request to have IO pending at this point. | 233 // It doesn't make sense for the request to have IO pending at this point. |
234 DCHECK(!request->status().is_io_pending()); | 234 DCHECK(!request->status().is_io_pending()); |
235 | 235 |
236 response_started_count_++; | 236 response_started_count_++; |
237 if (cancel_in_rs_) { | 237 if (cancel_in_rs_) { |
238 request->Cancel(); | 238 request->Cancel(); |
239 OnResponseCompleted(request); | 239 OnResponseCompleted(request); |
240 } else if (!request->status().is_success()) { | 240 } else if (!request->status().is_success()) { |
241 DCHECK(request->status().status() == URLRequestStatus::FAILED || | 241 DCHECK(request->status().status() == net::URLRequestStatus::FAILED || |
242 request->status().status() == URLRequestStatus::CANCELED); | 242 request->status().status() == net::URLRequestStatus::CANCELED); |
243 request_failed_ = true; | 243 request_failed_ = true; |
244 OnResponseCompleted(request); | 244 OnResponseCompleted(request); |
245 } else { | 245 } else { |
246 // Initiate the first read. | 246 // Initiate the first read. |
247 int bytes_read = 0; | 247 int bytes_read = 0; |
248 if (request->Read(buf_, kBufferSize, &bytes_read)) | 248 if (request->Read(buf_, kBufferSize, &bytes_read)) |
249 OnReadCompleted(request, bytes_read); | 249 OnReadCompleted(request, bytes_read); |
250 else if (!request->status().is_io_pending()) | 250 else if (!request->status().is_io_pending()) |
251 OnResponseCompleted(request); | 251 OnResponseCompleted(request); |
252 } | 252 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 bool received_data_before_response_; | 396 bool received_data_before_response_; |
397 bool request_failed_; | 397 bool request_failed_; |
398 bool have_certificate_errors_; | 398 bool have_certificate_errors_; |
399 std::string data_received_; | 399 std::string data_received_; |
400 | 400 |
401 // our read buffer | 401 // our read buffer |
402 scoped_refptr<net::IOBuffer> buf_; | 402 scoped_refptr<net::IOBuffer> buf_; |
403 }; | 403 }; |
404 | 404 |
405 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 405 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ |
OLD | NEW |