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