| 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 #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/weak_ptr.h" | 14 #include "base/memory/weak_ptr.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 "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace fileapi { |
| 20 class FileSystemContext; | 20 class FileSystemContext; |
| 21 class FileSystemOperationInterface; | 21 class FileSystemOperationInterface; |
| 22 | 22 |
| 23 // A request job that handles reading filesystem: URLs for directories. | 23 // A request job that handles reading filesystem: URLs for directories. |
| 24 class FileSystemDirURLRequestJob : public net::URLRequestJob { | 24 class FileSystemDirURLRequestJob : public net::URLRequestJob { |
| 25 public: | 25 public: |
| 26 FileSystemDirURLRequestJob( | 26 FileSystemDirURLRequestJob( |
| 27 net::URLRequest* request, | 27 net::URLRequest* request, |
| 28 FileSystemContext* file_system_context, | 28 FileSystemContext* file_system_context); |
| 29 scoped_refptr<base::MessageLoopProxy> file_thread_proxy); | |
| 30 | 29 |
| 31 // URLRequestJob methods: | 30 // URLRequestJob methods: |
| 32 virtual void Start() OVERRIDE; | 31 virtual void Start() OVERRIDE; |
| 33 virtual void Kill() OVERRIDE; | 32 virtual void Kill() OVERRIDE; |
| 34 virtual bool ReadRawData(net::IOBuffer* buf, | 33 virtual bool ReadRawData(net::IOBuffer* buf, |
| 35 int buf_size, | 34 int buf_size, |
| 36 int* bytes_read) OVERRIDE; | 35 int* bytes_read) OVERRIDE; |
| 37 virtual bool GetCharset(std::string* charset) OVERRIDE; | 36 virtual bool GetCharset(std::string* charset) OVERRIDE; |
| 38 | 37 |
| 39 // FilterContext methods (via URLRequestJob): | 38 // FilterContext methods (via URLRequestJob): |
| 40 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 39 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 41 // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate | 40 // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate |
| 42 // an HTTP response. | 41 // an HTTP response. |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 class CallbackDispatcher; | 44 class CallbackDispatcher; |
| 46 | 45 |
| 47 virtual ~FileSystemDirURLRequestJob(); | 46 virtual ~FileSystemDirURLRequestJob(); |
| 48 | 47 |
| 49 void StartAsync(); | 48 void StartAsync(); |
| 50 void DidReadDirectory(base::PlatformFileError result, | 49 void DidReadDirectory(base::PlatformFileError result, |
| 51 const std::vector<base::FileUtilProxy::Entry>& entries, | 50 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 52 bool has_more); | 51 bool has_more); |
| 53 FileSystemOperationInterface* GetNewOperation(const GURL& url); | 52 FileSystemOperationInterface* GetNewOperation(const GURL& url); |
| 54 | 53 |
| 55 std::string data_; | 54 std::string data_; |
| 56 FileSystemContext* file_system_context_; | 55 FileSystemContext* file_system_context_; |
| 57 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; | |
| 58 base::WeakPtrFactory<FileSystemDirURLRequestJob> weak_factory_; | 56 base::WeakPtrFactory<FileSystemDirURLRequestJob> weak_factory_; |
| 59 | 57 |
| 60 DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob); | 58 DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob); |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 } // namespace fileapi | 61 } // namespace fileapi |
| 64 | 62 |
| 65 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ | 63 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_ |
| OLD | NEW |