| 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.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // http://crbug.com/115705 is fixed. | 755 // http://crbug.com/115705 is fixed. |
| 756 if (job_->is_done()) | 756 if (job_->is_done()) |
| 757 return status_.error(); | 757 return status_.error(); |
| 758 | 758 |
| 759 if (dest_size == 0) { | 759 if (dest_size == 0) { |
| 760 // Caller is not too bright. I guess we've done what they asked. | 760 // Caller is not too bright. I guess we've done what they asked. |
| 761 return OK; | 761 return OK; |
| 762 } | 762 } |
| 763 | 763 |
| 764 int rv = job_->Read(dest, dest_size); | 764 int rv = job_->Read(dest, dest_size); |
| 765 if (rv == ERR_IO_PENDING) | 765 if (rv == ERR_IO_PENDING) { |
| 766 set_status(URLRequestStatus::FromError(ERR_IO_PENDING)); | 766 set_status(URLRequestStatus::FromError(ERR_IO_PENDING)); |
| 767 } else if (rv <= 0) { |
| 768 NotifyRequestCompleted(); |
| 769 } |
| 767 | 770 |
| 768 // If rv is not 0 or actual bytes read, the status cannot be success. | 771 // If rv is not 0 or actual bytes read, the status cannot be success. |
| 769 DCHECK(rv >= 0 || status_.status() != URLRequestStatus::SUCCESS); | 772 DCHECK(rv >= 0 || status_.status() != URLRequestStatus::SUCCESS); |
| 770 | |
| 771 if (rv == 0 && status_.is_success()) | |
| 772 NotifyRequestCompleted(); | |
| 773 return rv; | 773 return rv; |
| 774 } | 774 } |
| 775 | 775 |
| 776 // Deprecated. | 776 // Deprecated. |
| 777 bool URLRequest::Read(IOBuffer* dest, int dest_size, int* bytes_read) { | 777 bool URLRequest::Read(IOBuffer* dest, int dest_size, int* bytes_read) { |
| 778 int result = Read(dest, dest_size); | 778 int result = Read(dest, dest_size); |
| 779 if (result >= 0) { | 779 if (result >= 0) { |
| 780 *bytes_read = result; | 780 *bytes_read = result; |
| 781 return true; | 781 return true; |
| 782 } | 782 } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 out->clear(); | 1214 out->clear(); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 void URLRequest::set_status(URLRequestStatus status) { | 1217 void URLRequest::set_status(URLRequestStatus status) { |
| 1218 DCHECK(status_.is_io_pending() || status_.is_success() || | 1218 DCHECK(status_.is_io_pending() || status_.is_success() || |
| 1219 (!status.is_success() && !status.is_io_pending())); | 1219 (!status.is_success() && !status.is_io_pending())); |
| 1220 status_ = status; | 1220 status_ = status; |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 } // namespace net | 1223 } // namespace net |
| OLD | NEW |