| 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_simple_job.h" | 5 #include "net/url_request/url_request_simple_job.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 int URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size) { | 67 int URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size) { |
| 68 buf_size = std::min(static_cast<int64_t>(buf_size), | 68 buf_size = std::min(static_cast<int64_t>(buf_size), |
| 69 byte_range_.last_byte_position() - next_data_offset_ + 1); | 69 byte_range_.last_byte_position() - next_data_offset_ + 1); |
| 70 if (buf_size == 0) | 70 if (buf_size == 0) |
| 71 return 0; | 71 return 0; |
| 72 | 72 |
| 73 // Do memory copy asynchronously on a thread that is not the network thread. | 73 // Do memory copy asynchronously on a thread that is not the network thread. |
| 74 // See crbug.com/422489. | 74 // See crbug.com/422489. |
| 75 base::PostTaskWithTraitsAndReply( | 75 base::PostTaskWithTraitsAndReply( |
| 76 FROM_HERE, base::TaskTraits().WithShutdownBehavior( | 76 FROM_HERE, {base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
| 77 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | |
| 78 base::Bind(&CopyData, make_scoped_refptr(buf), buf_size, data_, | 77 base::Bind(&CopyData, make_scoped_refptr(buf), buf_size, data_, |
| 79 next_data_offset_), | 78 next_data_offset_), |
| 80 base::Bind(&URLRequestSimpleJob::ReadRawDataComplete, | 79 base::Bind(&URLRequestSimpleJob::ReadRawDataComplete, |
| 81 weak_factory_.GetWeakPtr(), buf_size)); | 80 weak_factory_.GetWeakPtr(), buf_size)); |
| 82 next_data_offset_ += buf_size; | 81 next_data_offset_ += buf_size; |
| 83 return ERR_IO_PENDING; | 82 return ERR_IO_PENDING; |
| 84 } | 83 } |
| 85 | 84 |
| 86 int URLRequestSimpleJob::GetData(std::string* mime_type, | 85 int URLRequestSimpleJob::GetData(std::string* mime_type, |
| 87 std::string* charset, | 86 std::string* charset, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 next_data_offset_ = byte_range_.first_byte_position(); | 135 next_data_offset_ = byte_range_.first_byte_position(); |
| 137 set_expected_content_size(byte_range_.last_byte_position() - | 136 set_expected_content_size(byte_range_.last_byte_position() - |
| 138 next_data_offset_ + 1); | 137 next_data_offset_ + 1); |
| 139 NotifyHeadersComplete(); | 138 NotifyHeadersComplete(); |
| 140 } else { | 139 } else { |
| 141 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 140 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 | 143 |
| 145 } // namespace net | 144 } // namespace net |
| OLD | NEW |