| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 // Do the reading. | 302 // Do the reading. |
| 303 const BlobData::Item& item = blob_data_->items().at(current_item_index_); | 303 const BlobData::Item& item = blob_data_->items().at(current_item_index_); |
| 304 switch (item.type) { | 304 switch (item.type) { |
| 305 case BlobData::TYPE_DATA: | 305 case BlobData::TYPE_DATA: |
| 306 return ReadBytesItem(item, bytes_to_read); | 306 return ReadBytesItem(item, bytes_to_read); |
| 307 case BlobData::TYPE_FILE: | 307 case BlobData::TYPE_FILE: |
| 308 return ReadFileItem(GetFileStreamReader(current_item_index_), | 308 return ReadFileItem(GetFileStreamReader(current_item_index_), |
| 309 bytes_to_read); | 309 bytes_to_read); |
| 310 case BlobData::TYPE_FILE_FILESYSTEM: |
| 311 // TODO(kinuko): Support TYPE_FILE_FILESYSTEM case. |
| 312 // http://crbug.com/141835 |
| 310 default: | 313 default: |
| 311 DCHECK(false); | 314 DCHECK(false); |
| 312 return false; | 315 return false; |
| 313 } | 316 } |
| 314 } | 317 } |
| 315 | 318 |
| 316 void BlobURLRequestJob::AdvanceItem() { | 319 void BlobURLRequestJob::AdvanceItem() { |
| 317 // Close the file if the current item is a file. | 320 // Close the file if the current item is a file. |
| 318 DeleteCurrentFileReader(); | 321 DeleteCurrentFileReader(); |
| 319 | 322 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 headers_set_ = true; | 525 headers_set_ = true; |
| 523 | 526 |
| 524 NotifyHeadersComplete(); | 527 NotifyHeadersComplete(); |
| 525 } | 528 } |
| 526 | 529 |
| 527 LocalFileStreamReader* BlobURLRequestJob::GetFileStreamReader(size_t index) { | 530 LocalFileStreamReader* BlobURLRequestJob::GetFileStreamReader(size_t index) { |
| 528 DCHECK_LT(index, blob_data_->items().size()); | 531 DCHECK_LT(index, blob_data_->items().size()); |
| 529 const BlobData::Item& item = blob_data_->items().at(index); | 532 const BlobData::Item& item = blob_data_->items().at(index); |
| 530 if (item.type != BlobData::TYPE_FILE) | 533 if (item.type != BlobData::TYPE_FILE) |
| 531 return NULL; | 534 return NULL; |
| 535 // TODO(kinuko): Create appropriate FileStreamReader for TYPE_FILE_FILESYSTEM. |
| 536 // http://crbug.com/141835 |
| 532 if (index_to_reader_.find(index) == index_to_reader_.end()) { | 537 if (index_to_reader_.find(index) == index_to_reader_.end()) { |
| 533 index_to_reader_[index] = new LocalFileStreamReader( | 538 index_to_reader_[index] = new LocalFileStreamReader( |
| 534 file_thread_proxy_, | 539 file_thread_proxy_, |
| 535 item.file_path, | 540 item.file_path, |
| 536 item.offset, | 541 item.offset, |
| 537 item.expected_modification_time); | 542 item.expected_modification_time); |
| 538 } | 543 } |
| 539 DCHECK(index_to_reader_[index]); | 544 DCHECK(index_to_reader_[index]); |
| 540 return index_to_reader_[index]; | 545 return index_to_reader_[index]; |
| 541 } | 546 } |
| 542 | 547 |
| 543 } // namespace webkit_blob | 548 } // namespace webkit_blob |
| OLD | NEW |