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 "storage/browser/fileapi/file_system_url_request_job.h" | 5 #include "storage/browser/fileapi/file_system_url_request_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 base::Bind(&FileSystemURLRequestJob::StartAsync, | 74 base::Bind(&FileSystemURLRequestJob::StartAsync, |
75 weak_factory_.GetWeakPtr())); | 75 weak_factory_.GetWeakPtr())); |
76 } | 76 } |
77 | 77 |
78 void FileSystemURLRequestJob::Kill() { | 78 void FileSystemURLRequestJob::Kill() { |
79 reader_.reset(); | 79 reader_.reset(); |
80 URLRequestJob::Kill(); | 80 URLRequestJob::Kill(); |
81 weak_factory_.InvalidateWeakPtrs(); | 81 weak_factory_.InvalidateWeakPtrs(); |
82 } | 82 } |
83 | 83 |
84 bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, | 84 bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, |
85 int *bytes_read) { | 85 int dest_size, |
| 86 int* bytes_read) { |
86 DCHECK_NE(dest_size, 0); | 87 DCHECK_NE(dest_size, 0); |
87 DCHECK(bytes_read); | 88 DCHECK(bytes_read); |
88 DCHECK_GE(remaining_bytes_, 0); | 89 DCHECK_GE(remaining_bytes_, 0); |
89 | 90 |
90 if (reader_.get() == NULL) | 91 if (reader_.get() == NULL) |
91 return false; | 92 return false; |
92 | 93 |
93 if (remaining_bytes_ < dest_size) | 94 if (remaining_bytes_ < dest_size) |
94 dest_size = static_cast<int>(remaining_bytes_); | 95 dest_size = static_cast<int>(remaining_bytes_); |
95 | 96 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 NotifyHeadersComplete(); | 211 NotifyHeadersComplete(); |
211 return; | 212 return; |
212 } | 213 } |
213 | 214 |
214 remaining_bytes_ = byte_range_.last_byte_position() - | 215 remaining_bytes_ = byte_range_.last_byte_position() - |
215 byte_range_.first_byte_position() + 1; | 216 byte_range_.first_byte_position() + 1; |
216 DCHECK_GE(remaining_bytes_, 0); | 217 DCHECK_GE(remaining_bytes_, 0); |
217 | 218 |
218 DCHECK(!reader_.get()); | 219 DCHECK(!reader_.get()); |
219 reader_ = file_system_context_->CreateFileStreamReader( | 220 reader_ = file_system_context_->CreateFileStreamReader( |
220 url_, byte_range_.first_byte_position(), base::Time()); | 221 url_, byte_range_.first_byte_position(), remaining_bytes_, base::Time()); |
221 | 222 |
222 set_expected_content_size(remaining_bytes_); | 223 set_expected_content_size(remaining_bytes_); |
223 response_info_.reset(new net::HttpResponseInfo()); | 224 response_info_.reset(new net::HttpResponseInfo()); |
224 response_info_->headers = CreateHttpResponseHeaders(); | 225 response_info_->headers = CreateHttpResponseHeaders(); |
225 NotifyHeadersComplete(); | 226 NotifyHeadersComplete(); |
226 } | 227 } |
227 | 228 |
228 void FileSystemURLRequestJob::DidRead(int result) { | 229 void FileSystemURLRequestJob::DidRead(int result) { |
229 if (result > 0) | 230 if (result > 0) |
230 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status | 231 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status |
(...skipping 23 matching lines...) Expand all Loading... |
254 } | 255 } |
255 | 256 |
256 return false; | 257 return false; |
257 } | 258 } |
258 | 259 |
259 void FileSystemURLRequestJob::NotifyFailed(int rv) { | 260 void FileSystemURLRequestJob::NotifyFailed(int rv) { |
260 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 261 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
261 } | 262 } |
262 | 263 |
263 } // namespace storage | 264 } // namespace storage |
OLD | NEW |