| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 remaining_bytes_(0), | 57 remaining_bytes_(0), |
| 58 pending_get_file_info_count_(0), | 58 pending_get_file_info_count_(0), |
| 59 current_item_index_(0), | 59 current_item_index_(0), |
| 60 current_item_offset_(0), | 60 current_item_offset_(0), |
| 61 error_(false), | 61 error_(false), |
| 62 headers_set_(false), | 62 headers_set_(false), |
| 63 byte_range_set_(false) { | 63 byte_range_set_(false) { |
| 64 DCHECK(file_thread_proxy_); | 64 DCHECK(file_thread_proxy_); |
| 65 } | 65 } |
| 66 | 66 |
| 67 BlobURLRequestJob::~BlobURLRequestJob() { | |
| 68 STLDeleteValues(&index_to_reader_); | |
| 69 } | |
| 70 | |
| 71 void BlobURLRequestJob::Start() { | 67 void BlobURLRequestJob::Start() { |
| 72 // Continue asynchronously. | 68 // Continue asynchronously. |
| 73 MessageLoop::current()->PostTask( | 69 MessageLoop::current()->PostTask( |
| 74 FROM_HERE, | 70 FROM_HERE, |
| 75 base::Bind(&BlobURLRequestJob::DidStart, weak_factory_.GetWeakPtr())); | 71 base::Bind(&BlobURLRequestJob::DidStart, weak_factory_.GetWeakPtr())); |
| 76 } | 72 } |
| 77 | 73 |
| 78 void BlobURLRequestJob::Kill() { | 74 void BlobURLRequestJob::Kill() { |
| 79 DeleteCurrentFileReader(); | 75 DeleteCurrentFileReader(); |
| 80 | 76 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } else { | 140 } else { |
| 145 // We don't support multiple range requests in one single URL request, | 141 // We don't support multiple range requests in one single URL request, |
| 146 // because we need to do multipart encoding here. | 142 // because we need to do multipart encoding here. |
| 147 // TODO(jianli): Support multipart byte range requests. | 143 // TODO(jianli): Support multipart byte range requests. |
| 148 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); | 144 NotifyFailure(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE); |
| 149 } | 145 } |
| 150 } | 146 } |
| 151 } | 147 } |
| 152 } | 148 } |
| 153 | 149 |
| 150 BlobURLRequestJob::~BlobURLRequestJob() { |
| 151 STLDeleteValues(&index_to_reader_); |
| 152 } |
| 153 |
| 154 void BlobURLRequestJob::DidStart() { | 154 void BlobURLRequestJob::DidStart() { |
| 155 // We only support GET request per the spec. | 155 // We only support GET request per the spec. |
| 156 if (request()->method() != "GET") { | 156 if (request()->method() != "GET") { |
| 157 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED); | 157 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED); |
| 158 return; | 158 return; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // If the blob data is not present, bail out. | 161 // If the blob data is not present, bail out. |
| 162 if (!blob_data_) { | 162 if (!blob_data_) { |
| 163 NotifyFailure(net::ERR_FILE_NOT_FOUND); | 163 NotifyFailure(net::ERR_FILE_NOT_FOUND); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 file_thread_proxy_, | 530 file_thread_proxy_, |
| 531 item.file_path, | 531 item.file_path, |
| 532 item.offset, | 532 item.offset, |
| 533 item.expected_modification_time); | 533 item.expected_modification_time); |
| 534 } | 534 } |
| 535 DCHECK(index_to_reader_[index]); | 535 DCHECK(index_to_reader_[index]); |
| 536 return index_to_reader_[index]; | 536 return index_to_reader_[index]; |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace webkit_blob | 539 } // namespace webkit_blob |
| OLD | NEW |