| 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_DIR_URL_REQUEST_JOB_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_util_proxy.h" | 13 #include "base/file_util_proxy.h" |
| 14 #include "base/memory/scoped_callback_factory.h" | 14 #include "base/memory/scoped_callback_factory.h" |
| 15 #include "base/message_loop_proxy.h" | 15 #include "base/message_loop_proxy.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/task.h" | 17 #include "base/task.h" |
| 18 #include "net/url_request/url_request_job.h" | 18 #include "net/url_request/url_request_job.h" |
| 19 #include "webkit/fileapi/file_system_url_request_job_base.h" |
| 19 | 20 |
| 20 namespace fileapi { | 21 namespace fileapi { |
| 21 class FileSystemPathManager; | 22 class FileSystemContext; |
| 23 class FileSystemOperation; |
| 22 | 24 |
| 23 // A request job that handles reading filesystem: URLs for directories. | 25 // A request job that handles reading filesystem: URLs for directories. |
| 24 class FileSystemDirURLRequestJob : public net::URLRequestJob { | 26 class FileSystemDirURLRequestJob : public FileSystemURLRequestJobBase { |
| 25 public: | 27 public: |
| 26 FileSystemDirURLRequestJob( | 28 FileSystemDirURLRequestJob( |
| 27 net::URLRequest* request, FileSystemPathManager* path_manager, | 29 net::URLRequest* request, FileSystemContext* file_system_context, |
| 28 scoped_refptr<base::MessageLoopProxy> file_thread_proxy); | 30 scoped_refptr<base::MessageLoopProxy> file_thread_proxy); |
| 29 | 31 |
| 30 // URLRequestJob methods: | 32 // URLRequestJob methods: |
| 31 virtual void Start(); | 33 virtual void Start(); |
| 32 virtual void Kill(); | 34 virtual void Kill(); |
| 33 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 35 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
| 34 virtual bool GetCharset(std::string* charset); | 36 virtual bool GetCharset(std::string* charset); |
| 35 | 37 |
| 36 // FilterContext methods (via URLRequestJob): | 38 // FilterContext methods (via URLRequestJob): |
| 37 virtual bool GetMimeType(std::string* mime_type) const; | 39 virtual bool GetMimeType(std::string* mime_type) const; |
| 38 // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate | 40 // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate |
| 39 // an HTTP response. | 41 // an HTTP response. |
| 40 | 42 |
| 41 private: | 43 protected: |
| 44 // FileSystemURLRequestJobBase methods. |
| 45 virtual void DidGetLocalPath(const FilePath& local_path); |
| 46 |
| 42 virtual ~FileSystemDirURLRequestJob(); | 47 virtual ~FileSystemDirURLRequestJob(); |
| 43 | 48 |
| 44 void StartAsync(); | |
| 45 void DidGetRootPath(bool success, const FilePath& root_path, | |
| 46 const std::string& name); | |
| 47 void DidReadDirectory(base::PlatformFileError error_code, | 49 void DidReadDirectory(base::PlatformFileError error_code, |
| 48 const std::vector<base::FileUtilProxy::Entry>& entries); | 50 const std::vector<base::FileUtilProxy::Entry>& entries); |
| 49 | 51 fileapi::FileSystemOperation* GetNewOperation(); |
| 50 void NotifyFailed(int rv); | |
| 51 | 52 |
| 52 std::string data_; | 53 std::string data_; |
| 53 FilePath relative_dir_path_; | |
| 54 FilePath absolute_dir_path_; | |
| 55 FileSystemPathManager* const path_manager_; | |
| 56 | |
| 57 ScopedRunnableMethodFactory<FileSystemDirURLRequestJob> method_factory_; | 54 ScopedRunnableMethodFactory<FileSystemDirURLRequestJob> method_factory_; |
| 58 base::ScopedCallbackFactory<FileSystemDirURLRequestJob> callback_factory_; | 55 base::ScopedCallbackFactory<FileSystemDirURLRequestJob> callback_factory_; |
| 59 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; | |
| 60 | 56 |
| 61 DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob); | 57 DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob); |
| 62 }; | 58 }; |
| 63 | 59 |
| 64 } // namespace fileapi | 60 } // namespace fileapi |
| 65 | 61 |
| 66 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ | 62 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ |
| OLD | NEW |