| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util_proxy.h" | 10 #include "base/file_util_proxy.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "net/base/file_stream.h" | 16 #include "net/base/file_stream.h" |
| 17 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
| 18 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
| 22 #include "net/http/http_response_info.h" | 22 #include "net/http/http_response_info.h" |
| 23 #include "net/http/http_util.h" | 23 #include "net/http/http_util.h" |
| 24 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
| 25 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 25 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 26 #include "webkit/fileapi/file_system_context.h" |
| 26 #include "webkit/fileapi/file_system_operation.h" | 27 #include "webkit/fileapi/file_system_operation.h" |
| 27 #include "webkit/fileapi/file_system_util.h" | 28 #include "webkit/fileapi/file_system_util.h" |
| 28 | 29 |
| 29 using net::URLRequest; | 30 using net::URLRequest; |
| 30 using net::URLRequestJob; | 31 using net::URLRequestJob; |
| 31 using net::URLRequestStatus; | 32 using net::URLRequestStatus; |
| 32 | 33 |
| 33 namespace fileapi { | 34 namespace fileapi { |
| 34 | 35 |
| 35 static const int kFileFlags = base::PLATFORM_FILE_OPEN | | 36 static const int kFileFlags = base::PLATFORM_FILE_OPEN | |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 207 } |
| 207 | 208 |
| 208 int FileSystemURLRequestJob::GetResponseCode() const { | 209 int FileSystemURLRequestJob::GetResponseCode() const { |
| 209 if (response_info_.get()) | 210 if (response_info_.get()) |
| 210 return 200; | 211 return 200; |
| 211 return URLRequestJob::GetResponseCode(); | 212 return URLRequestJob::GetResponseCode(); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void FileSystemURLRequestJob::StartAsync() { | 215 void FileSystemURLRequestJob::StartAsync() { |
| 215 if (request_) { | 216 if (request_) { |
| 216 (new FileSystemOperation(new CallbackDispatcher(this), | 217 file_system_context_->CreateFileSystemOperation( |
| 217 file_thread_proxy_, | 218 request_->url(), |
| 218 file_system_context_) | 219 new CallbackDispatcher(this), |
| 219 )->GetMetadata(request_->url()); | 220 file_thread_proxy_)->GetMetadata(request_->url()); |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 void FileSystemURLRequestJob::DidGetMetadata( | 224 void FileSystemURLRequestJob::DidGetMetadata( |
| 224 const base::PlatformFileInfo& file_info, | 225 const base::PlatformFileInfo& file_info, |
| 225 const FilePath& platform_path) { | 226 const FilePath& platform_path) { |
| 226 // We may have been orphaned... | 227 // We may have been orphaned... |
| 227 if (!request_) | 228 if (!request_) |
| 228 return; | 229 return; |
| 229 | 230 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 307 } |
| 307 | 308 |
| 308 return false; | 309 return false; |
| 309 } | 310 } |
| 310 | 311 |
| 311 void FileSystemURLRequestJob::NotifyFailed(int rv) { | 312 void FileSystemURLRequestJob::NotifyFailed(int rv) { |
| 312 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 313 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 313 } | 314 } |
| 314 | 315 |
| 315 } // namespace fileapi | 316 } // namespace fileapi |
| OLD | NEW |