OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ |
6 #define CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ | 6 #define CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/process.h" | 12 #include "chrome/browser/browser_message_filter.h" |
13 #include "base/ref_counted.h" | |
14 #include "ipc/ipc_message.h" | |
15 #include "webkit/fileapi/file_system_types.h" | 13 #include "webkit/fileapi/file_system_types.h" |
16 | 14 |
17 namespace base { | 15 namespace base { |
18 class Time; | 16 class Time; |
19 } | 17 } |
20 | 18 |
21 class ChromeURLRequestContext; | 19 class ChromeURLRequestContext; |
22 class BrowserFileSystemContext; | 20 class BrowserFileSystemContext; |
23 class FilePath; | 21 class FilePath; |
24 class GURL; | 22 class GURL; |
25 class HostContentSettingsMap; | 23 class HostContentSettingsMap; |
26 class Profile; | 24 class Profile; |
27 class Receiver; | 25 class Receiver; |
28 class ResourceMessageFilter; | 26 class ResourceMessageFilter; |
29 class URLRequestContext; | 27 class URLRequestContext; |
30 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
31 | 29 |
32 namespace fileapi { | 30 namespace fileapi { |
33 class SandboxedFileSystemOperation; | 31 class SandboxedFileSystemOperation; |
34 } | 32 } |
35 | 33 |
36 class FileSystemDispatcherHost | 34 class FileSystemDispatcherHost : public BrowserMessageFilter { |
37 : public base::RefCountedThreadSafe<FileSystemDispatcherHost> { | |
38 public: | 35 public: |
39 // Used by the renderer. | 36 // Used by the renderer. |
40 FileSystemDispatcherHost(IPC::Message::Sender* sender, | 37 explicit FileSystemDispatcherHost(Profile* profile); |
41 Profile* profile); | |
42 // Used by the worker, since it has the context handy already. | 38 // Used by the worker, since it has the context handy already. |
43 FileSystemDispatcherHost(IPC::Message::Sender* sender, | 39 explicit FileSystemDispatcherHost(ChromeURLRequestContext* context); |
44 ChromeURLRequestContext* context); | |
45 ~FileSystemDispatcherHost(); | 40 ~FileSystemDispatcherHost(); |
46 void Init(base::ProcessHandle process_handle); | |
47 void Shutdown(); | |
48 | 41 |
49 bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok); | 42 // BrowserMessageFilter implementation. |
| 43 virtual void OnChannelConnected(int32 peer_pid); |
| 44 virtual bool OnMessageReceived(const IPC::Message& message, |
| 45 bool* message_was_ok); |
| 46 |
50 | 47 |
51 void OnOpenFileSystem(int request_id, | 48 void OnOpenFileSystem(int request_id, |
52 const GURL& origin_url, | 49 const GURL& origin_url, |
53 fileapi::FileSystemType type, | 50 fileapi::FileSystemType type, |
54 int64 requested_size, | 51 int64 requested_size, |
55 bool create); | 52 bool create); |
56 void OnMove(int request_id, | 53 void OnMove(int request_id, |
57 const FilePath& src_path, | 54 const FilePath& src_path, |
58 const FilePath& dest_path); | 55 const FilePath& dest_path); |
59 void OnCopy(int request_id, | 56 void OnCopy(int request_id, |
(...skipping 11 matching lines...) Expand all Loading... |
71 void OnWrite(int request_id, | 68 void OnWrite(int request_id, |
72 const FilePath& path, | 69 const FilePath& path, |
73 const GURL& blob_url, | 70 const GURL& blob_url, |
74 int64 offset); | 71 int64 offset); |
75 void OnTruncate(int request_id, const FilePath& path, int64 length); | 72 void OnTruncate(int request_id, const FilePath& path, int64 length); |
76 void OnTouchFile(int request_id, | 73 void OnTouchFile(int request_id, |
77 const FilePath& path, | 74 const FilePath& path, |
78 const base::Time& last_access_time, | 75 const base::Time& last_access_time, |
79 const base::Time& last_modified_time); | 76 const base::Time& last_modified_time); |
80 void OnCancel(int request_id, int request_to_cancel); | 77 void OnCancel(int request_id, int request_to_cancel); |
81 void Send(IPC::Message* message); | |
82 void UnregisterOperation(int request_id); | 78 void UnregisterOperation(int request_id); |
83 | 79 |
84 private: | 80 private: |
85 // Creates a new SandboxedFileSystemOperation. | 81 // Creates a new SandboxedFileSystemOperation. |
86 fileapi::SandboxedFileSystemOperation* GetNewOperation(int request_id); | 82 fileapi::SandboxedFileSystemOperation* GetNewOperation(int request_id); |
87 | 83 |
88 // The sender to be used for sending out IPC messages. | |
89 IPC::Message::Sender* message_sender_; | |
90 | |
91 // The handle of this process. | |
92 base::ProcessHandle process_handle_; | |
93 | |
94 bool shutdown_; | |
95 | |
96 scoped_refptr<BrowserFileSystemContext> context_; | 84 scoped_refptr<BrowserFileSystemContext> context_; |
97 | 85 |
98 // Used to look up permissions. | 86 // Used to look up permissions. |
99 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 87 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
100 | 88 |
101 // Keeps ongoing file system operations. | 89 // Keeps ongoing file system operations. |
102 typedef IDMap<fileapi::SandboxedFileSystemOperation> OperationsMap; | 90 typedef IDMap<fileapi::SandboxedFileSystemOperation> OperationsMap; |
103 OperationsMap operations_; | 91 OperationsMap operations_; |
104 | 92 |
105 // This holds the URLRequestContextGetter until Init() can be called from the | 93 // This holds the URLRequestContextGetter until Init() can be called from the |
106 // IO thread, which will extract the URLRequestContext from it. | 94 // IO thread, which will extract the URLRequestContext from it. |
107 scoped_refptr<URLRequestContextGetter> request_context_getter_; | 95 scoped_refptr<URLRequestContextGetter> request_context_getter_; |
108 scoped_refptr<URLRequestContext> request_context_; | 96 scoped_refptr<URLRequestContext> request_context_; |
109 | 97 |
110 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcherHost); | 98 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcherHost); |
111 }; | 99 }; |
112 | 100 |
113 #endif // CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ | 101 #endif // CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_HOST_H_ |
OLD | NEW |