| 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 "webkit/blob/blob_url_request_job.h" | 5 #include "webkit/blob/blob_url_request_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 byte_range_.first_byte_position() + 1; | 211 byte_range_.first_byte_position() + 1; |
| 212 DCHECK_GE(remaining_bytes_, 0); | 212 DCHECK_GE(remaining_bytes_, 0); |
| 213 | 213 |
| 214 // Do the seek at the beginning of the request. | 214 // Do the seek at the beginning of the request. |
| 215 if (byte_range_.first_byte_position()) | 215 if (byte_range_.first_byte_position()) |
| 216 Seek(byte_range_.first_byte_position()); | 216 Seek(byte_range_.first_byte_position()); |
| 217 | 217 |
| 218 NotifySuccess(); | 218 NotifySuccess(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void BlobURLRequestJob::DidGetFileItemLength(size_t index, int result) { | 221 void BlobURLRequestJob::DidGetFileItemLength(size_t index, int64 result) { |
| 222 // Do nothing if we have encountered an error. | 222 // Do nothing if we have encountered an error. |
| 223 if (error_) | 223 if (error_) |
| 224 return; | 224 return; |
| 225 | 225 |
| 226 if (result == net::ERR_UPLOAD_FILE_CHANGED) { | 226 if (result == net::ERR_UPLOAD_FILE_CHANGED) { |
| 227 NotifyFailure(net::ERR_FILE_NOT_FOUND); | 227 NotifyFailure(net::ERR_FILE_NOT_FOUND); |
| 228 return; | 228 return; |
| 229 } else if (result < 0) { | 229 } else if (result < 0) { |
| 230 NotifyFailure(result); | 230 NotifyFailure(result); |
| 231 return; | 231 return; |
| 232 } | 232 } |
| 233 | 233 |
| 234 DCHECK_LT(index, blob_data_->items().size()); | 234 DCHECK_LT(index, blob_data_->items().size()); |
| 235 const BlobData::Item& item = blob_data_->items().at(index); | 235 const BlobData::Item& item = blob_data_->items().at(index); |
| 236 DCHECK(item.type == BlobData::TYPE_FILE); | 236 DCHECK(item.type == BlobData::TYPE_FILE); |
| 237 | 237 |
| 238 // If item length is -1, we need to use the file size being resolved | 238 // If item length is -1, we need to use the file size being resolved |
| 239 // in the real time. | 239 // in the real time. |
| 240 int64 item_length = static_cast<int64>(item.length); | 240 int64 item_length = static_cast<int64>(item.length); |
| 241 if (item_length == -1) | 241 if (item_length == -1) |
| 242 item_length = result; | 242 item_length = result - item.offset; |
| 243 | 243 |
| 244 // Cache the size and add it to the total size. | 244 // Cache the size and add it to the total size. |
| 245 DCHECK_LT(index, item_length_list_.size()); | 245 DCHECK_LT(index, item_length_list_.size()); |
| 246 item_length_list_[index] = item_length; | 246 item_length_list_[index] = item_length; |
| 247 total_size_ += item_length; | 247 total_size_ += item_length; |
| 248 | 248 |
| 249 if (--pending_get_file_info_count_ == 0) | 249 if (--pending_get_file_info_count_ == 0) |
| 250 DidCountSize(net::OK); | 250 DidCountSize(net::OK); |
| 251 } | 251 } |
| 252 | 252 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 file_thread_proxy_, | 524 file_thread_proxy_, |
| 525 item.file_path, | 525 item.file_path, |
| 526 item.offset, | 526 item.offset, |
| 527 item.expected_modification_time); | 527 item.expected_modification_time); |
| 528 } | 528 } |
| 529 DCHECK(index_to_reader_[index]); | 529 DCHECK(index_to_reader_[index]); |
| 530 return index_to_reader_[index]; | 530 return index_to_reader_[index]; |
| 531 } | 531 } |
| 532 | 532 |
| 533 } // namespace webkit_blob | 533 } // namespace webkit_blob |
| OLD | NEW |