| 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 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/scoped_callback_factory.h" | 12 #include "base/memory/scoped_callback_factory.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.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/task.h" | 16 #include "base/task.h" |
| 17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 18 #include "net/http/http_byte_range.h" | 18 #include "net/http/http_byte_range.h" |
| 19 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
| 20 #include "webkit/fileapi/file_system_url_request_job_base.h" |
| 20 | 21 |
| 21 class GURL; | 22 class GURL; |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 class FileStream; | 25 class FileStream; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace fileapi { | 28 namespace fileapi { |
| 28 class FileSystemPathManager; | 29 class FileSystemContext; |
| 29 | 30 |
| 30 // A request job that handles reading filesystem: URLs | 31 // A request job that handles reading filesystem: URLs |
| 31 class FileSystemURLRequestJob : public net::URLRequestJob { | 32 class FileSystemURLRequestJob : public FileSystemURLRequestJobBase { |
| 32 public: | 33 public: |
| 33 FileSystemURLRequestJob( | 34 FileSystemURLRequestJob( |
| 34 net::URLRequest* request, FileSystemPathManager* path_manager, | 35 net::URLRequest* request, FileSystemContext* file_system_context, |
| 35 scoped_refptr<base::MessageLoopProxy> file_thread_proxy); | 36 scoped_refptr<base::MessageLoopProxy> file_thread_proxy); |
| 36 | 37 |
| 37 // URLRequestJob methods: | 38 // URLRequestJob methods: |
| 38 virtual void Start(); | 39 virtual void Start(); |
| 39 virtual void Kill(); | 40 virtual void Kill(); |
| 40 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 41 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
| 41 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 42 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); |
| 42 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); | 43 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); |
| 43 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 44 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
| 44 virtual int GetResponseCode() const; | 45 virtual int GetResponseCode() const; |
| 45 | 46 |
| 46 // FilterContext methods (via URLRequestJob): | 47 // FilterContext methods (via URLRequestJob): |
| 47 virtual bool GetMimeType(std::string* mime_type) const; | 48 virtual bool GetMimeType(std::string* mime_type) const; |
| 48 | 49 |
| 50 protected: |
| 51 // FileSystemURLRequestJobBase methods. |
| 52 virtual void DidGetLocalPath(const FilePath& local_path); |
| 53 |
| 49 private: | 54 private: |
| 50 virtual ~FileSystemURLRequestJob(); | 55 virtual ~FileSystemURLRequestJob(); |
| 51 | 56 |
| 52 void StartAsync(); | |
| 53 void DidGetRootPath(bool success, const FilePath& root_path, | |
| 54 const std::string& name); | |
| 55 void DidResolve(base::PlatformFileError error_code, | 57 void DidResolve(base::PlatformFileError error_code, |
| 56 const base::PlatformFileInfo& file_info); | 58 const base::PlatformFileInfo& file_info); |
| 57 void DidOpen(base::PlatformFileError error_code, | 59 void DidOpen(base::PlatformFileError error_code, |
| 58 base::PassPlatformFile file, bool created); | 60 base::PassPlatformFile file, bool created); |
| 59 void DidRead(int result); | 61 void DidRead(int result); |
| 60 | 62 |
| 61 void NotifyFailed(int rv); | 63 ScopedRunnableMethodFactory<FileSystemURLRequestJob> method_factory_; |
| 62 | 64 base::ScopedCallbackFactory<FileSystemURLRequestJob> callback_factory_; |
| 63 FilePath relative_file_path_; | |
| 64 FilePath absolute_file_path_; | |
| 65 FileSystemPathManager* const path_manager_; | |
| 66 | |
| 67 net::CompletionCallbackImpl<FileSystemURLRequestJob> io_callback_; | 65 net::CompletionCallbackImpl<FileSystemURLRequestJob> io_callback_; |
| 68 scoped_ptr<net::FileStream> stream_; | 66 scoped_ptr<net::FileStream> stream_; |
| 69 bool is_directory_; | 67 bool is_directory_; |
| 70 scoped_ptr<net::HttpResponseInfo> response_info_; | 68 scoped_ptr<net::HttpResponseInfo> response_info_; |
| 71 | 69 int64 remaining_bytes_; |
| 72 net::HttpByteRange byte_range_; | 70 net::HttpByteRange byte_range_; |
| 73 int64 remaining_bytes_; | |
| 74 | |
| 75 ScopedRunnableMethodFactory<FileSystemURLRequestJob> method_factory_; | |
| 76 base::ScopedCallbackFactory<FileSystemURLRequestJob> callback_factory_; | |
| 77 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; | |
| 78 | 71 |
| 79 DISALLOW_COPY_AND_ASSIGN(FileSystemURLRequestJob); | 72 DISALLOW_COPY_AND_ASSIGN(FileSystemURLRequestJob); |
| 80 }; | 73 }; |
| 81 | 74 |
| 82 } // namespace fileapi | 75 } // namespace fileapi |
| 83 | 76 |
| 84 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_ | 77 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_ |
| OLD | NEW |