| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ | |
| 6 #define CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/id_map.h" | |
| 12 #include "chrome/browser/browser_message_filter.h" | |
| 13 #include "webkit/fileapi/file_system_types.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class Time; | |
| 17 } | |
| 18 | |
| 19 class ChromeURLRequestContext; | |
| 20 class FilePath; | |
| 21 class GURL; | |
| 22 class HostContentSettingsMap; | |
| 23 class Profile; | |
| 24 class Receiver; | |
| 25 class RenderMessageFilter; | |
| 26 class URLRequestContextGetter; | |
| 27 | |
| 28 namespace net { | |
| 29 class URLRequestContext; | |
| 30 } // namespace net | |
| 31 | |
| 32 namespace fileapi { | |
| 33 class FileSystemContext; | |
| 34 class FileSystemOperation; | |
| 35 } | |
| 36 | |
| 37 class FileSystemDispatcherHost : public BrowserMessageFilter { | |
| 38 public: | |
| 39 // Used by the renderer. | |
| 40 explicit FileSystemDispatcherHost(Profile* profile); | |
| 41 // Used by the worker, since it has the context handy already. | |
| 42 explicit FileSystemDispatcherHost(ChromeURLRequestContext* context); | |
| 43 ~FileSystemDispatcherHost(); | |
| 44 | |
| 45 // BrowserMessageFilter implementation. | |
| 46 virtual void OnChannelConnected(int32 peer_pid); | |
| 47 virtual bool OnMessageReceived(const IPC::Message& message, | |
| 48 bool* message_was_ok); | |
| 49 | |
| 50 | |
| 51 void OnOpenFileSystem(int request_id, | |
| 52 const GURL& origin_url, | |
| 53 fileapi::FileSystemType type, | |
| 54 int64 requested_size, | |
| 55 bool create); | |
| 56 void OnMove(int request_id, | |
| 57 const FilePath& src_path, | |
| 58 const FilePath& dest_path); | |
| 59 void OnCopy(int request_id, | |
| 60 const FilePath& src_path, | |
| 61 const FilePath& dest_path); | |
| 62 void OnRemove(int request_id, const FilePath& path, bool recursive); | |
| 63 void OnReadMetadata(int request_id, const FilePath& path); | |
| 64 void OnCreate(int request_id, | |
| 65 const FilePath& path, | |
| 66 bool exclusive, | |
| 67 bool is_directory, | |
| 68 bool recursive); | |
| 69 void OnExists(int request_id, const FilePath& path, bool is_directory); | |
| 70 void OnReadDirectory(int request_id, const FilePath& path); | |
| 71 void OnWrite(int request_id, | |
| 72 const FilePath& path, | |
| 73 const GURL& blob_url, | |
| 74 int64 offset); | |
| 75 void OnTruncate(int request_id, const FilePath& path, int64 length); | |
| 76 void OnTouchFile(int request_id, | |
| 77 const FilePath& path, | |
| 78 const base::Time& last_access_time, | |
| 79 const base::Time& last_modified_time); | |
| 80 void OnCancel(int request_id, int request_to_cancel); | |
| 81 void UnregisterOperation(int request_id); | |
| 82 | |
| 83 private: | |
| 84 // Creates a new FileSystemOperation. | |
| 85 fileapi::FileSystemOperation* GetNewOperation(int request_id); | |
| 86 | |
| 87 scoped_refptr<fileapi::FileSystemContext> context_; | |
| 88 | |
| 89 // Used to look up permissions. | |
| 90 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | |
| 91 | |
| 92 // Keeps ongoing file system operations. | |
| 93 typedef IDMap<fileapi::FileSystemOperation> OperationsMap; | |
| 94 OperationsMap operations_; | |
| 95 | |
| 96 // This holds the URLRequestContextGetter until Init() can be called from the | |
| 97 // IO thread, which will extract the net::URLRequestContext from it. | |
| 98 scoped_refptr<URLRequestContextGetter> request_context_getter_; | |
| 99 scoped_refptr<net::URLRequestContext> request_context_; | |
| 100 | |
| 101 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcherHost); | |
| 102 }; | |
| 103 | |
| 104 #endif // CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ | |
| OLD | NEW |