| 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/fileapi/file_system_url_request_job.h" | 5 #include "webkit/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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (response_info_.get()) | 151 if (response_info_.get()) |
| 152 return 200; | 152 return 200; |
| 153 return URLRequestJob::GetResponseCode(); | 153 return URLRequestJob::GetResponseCode(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void FileSystemURLRequestJob::StartAsync() { | 156 void FileSystemURLRequestJob::StartAsync() { |
| 157 if (!request_) | 157 if (!request_) |
| 158 return; | 158 return; |
| 159 DCHECK(!reader_.get()); | 159 DCHECK(!reader_.get()); |
| 160 FileSystemOperationInterface* operation = | 160 FileSystemOperationInterface* operation = |
| 161 file_system_context_->CreateFileSystemOperation( | 161 file_system_context_->CreateFileSystemOperation(request_->url()); |
| 162 request_->url(), | |
| 163 file_thread_proxy_); | |
| 164 if (!operation) { | 162 if (!operation) { |
| 165 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 163 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
| 166 net::ERR_INVALID_URL)); | 164 net::ERR_INVALID_URL)); |
| 167 return; | 165 return; |
| 168 } | 166 } |
| 169 operation->GetMetadata( | 167 operation->GetMetadata( |
| 170 request_->url(), | 168 request_->url(), |
| 171 base::Bind(&FileSystemURLRequestJob::DidGetMetadata, | 169 base::Bind(&FileSystemURLRequestJob::DidGetMetadata, |
| 172 weak_factory_.GetWeakPtr())); | 170 weak_factory_.GetWeakPtr())); |
| 173 } | 171 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 199 } | 197 } |
| 200 | 198 |
| 201 remaining_bytes_ = byte_range_.last_byte_position() - | 199 remaining_bytes_ = byte_range_.last_byte_position() - |
| 202 byte_range_.first_byte_position() + 1; | 200 byte_range_.first_byte_position() + 1; |
| 203 DCHECK_GE(remaining_bytes_, 0); | 201 DCHECK_GE(remaining_bytes_, 0); |
| 204 | 202 |
| 205 DCHECK(!reader_.get()); | 203 DCHECK(!reader_.get()); |
| 206 reader_.reset( | 204 reader_.reset( |
| 207 file_system_context_->CreateFileReader( | 205 file_system_context_->CreateFileReader( |
| 208 request_->url(), | 206 request_->url(), |
| 209 byte_range_.first_byte_position(), | 207 byte_range_.first_byte_position())); |
| 210 file_thread_proxy_)); | |
| 211 | 208 |
| 212 set_expected_content_size(remaining_bytes_); | 209 set_expected_content_size(remaining_bytes_); |
| 213 response_info_.reset(new net::HttpResponseInfo()); | 210 response_info_.reset(new net::HttpResponseInfo()); |
| 214 response_info_->headers = CreateHttpResponseHeaders(); | 211 response_info_->headers = CreateHttpResponseHeaders(); |
| 215 NotifyHeadersComplete(); | 212 NotifyHeadersComplete(); |
| 216 } | 213 } |
| 217 | 214 |
| 218 void FileSystemURLRequestJob::DidRead(int result) { | 215 void FileSystemURLRequestJob::DidRead(int result) { |
| 219 if (result > 0) | 216 if (result > 0) |
| 220 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status | 217 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status |
| (...skipping 23 matching lines...) Expand all Loading... |
| 244 } | 241 } |
| 245 | 242 |
| 246 return false; | 243 return false; |
| 247 } | 244 } |
| 248 | 245 |
| 249 void FileSystemURLRequestJob::NotifyFailed(int rv) { | 246 void FileSystemURLRequestJob::NotifyFailed(int rv) { |
| 250 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 247 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 251 } | 248 } |
| 252 | 249 |
| 253 } // namespace fileapi | 250 } // namespace fileapi |
| OLD | NEW |