| 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" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util_proxy.h" | 12 #include "base/file_util_proxy.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
| 15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
| 16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "net/base/file_stream.h" | 20 #include "net/base/file_stream.h" |
| 21 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
| 22 #include "net/base/mime_util.h" | 22 #include "net/base/mime_util.h" |
| 23 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 24 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
| 25 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| 26 #include "net/http/http_response_info.h" | 26 #include "net/http/http_response_info.h" |
| 27 #include "net/http/http_util.h" | 27 #include "net/http/http_util.h" |
| 28 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 29 #include "webkit/blob/file_reader.h" | 29 #include "webkit/blob/file_stream_reader.h" |
| 30 #include "webkit/fileapi/file_system_context.h" | 30 #include "webkit/fileapi/file_system_context.h" |
| 31 #include "webkit/fileapi/file_system_operation.h" | 31 #include "webkit/fileapi/file_system_operation.h" |
| 32 #include "webkit/fileapi/file_system_util.h" | 32 #include "webkit/fileapi/file_system_util.h" |
| 33 | 33 |
| 34 using net::URLRequest; | 34 using net::URLRequest; |
| 35 using net::URLRequestJob; | 35 using net::URLRequestJob; |
| 36 using net::URLRequestStatus; | 36 using net::URLRequestStatus; |
| 37 | 37 |
| 38 namespace fileapi { | 38 namespace fileapi { |
| 39 | 39 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 NotifyHeadersComplete(); | 194 NotifyHeadersComplete(); |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 | 197 |
| 198 remaining_bytes_ = byte_range_.last_byte_position() - | 198 remaining_bytes_ = byte_range_.last_byte_position() - |
| 199 byte_range_.first_byte_position() + 1; | 199 byte_range_.first_byte_position() + 1; |
| 200 DCHECK_GE(remaining_bytes_, 0); | 200 DCHECK_GE(remaining_bytes_, 0); |
| 201 | 201 |
| 202 DCHECK(!reader_.get()); | 202 DCHECK(!reader_.get()); |
| 203 reader_.reset( | 203 reader_.reset( |
| 204 file_system_context_->CreateFileReader( | 204 file_system_context_->CreateFileStreamReader( |
| 205 request_->url(), | 205 request_->url(), |
| 206 byte_range_.first_byte_position())); | 206 byte_range_.first_byte_position())); |
| 207 | 207 |
| 208 set_expected_content_size(remaining_bytes_); | 208 set_expected_content_size(remaining_bytes_); |
| 209 response_info_.reset(new net::HttpResponseInfo()); | 209 response_info_.reset(new net::HttpResponseInfo()); |
| 210 response_info_->headers = CreateHttpResponseHeaders(); | 210 response_info_->headers = CreateHttpResponseHeaders(); |
| 211 NotifyHeadersComplete(); | 211 NotifyHeadersComplete(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void FileSystemURLRequestJob::DidRead(int result) { | 214 void FileSystemURLRequestJob::DidRead(int result) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 240 } | 240 } |
| 241 | 241 |
| 242 return false; | 242 return false; |
| 243 } | 243 } |
| 244 | 244 |
| 245 void FileSystemURLRequestJob::NotifyFailed(int rv) { | 245 void FileSystemURLRequestJob::NotifyFailed(int rv) { |
| 246 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 246 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace fileapi | 249 } // namespace fileapi |
| OLD | NEW |