OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file.h" | 13 #include "base/files/file.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/chromeos/file_system_provider/observer.h" | 20 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
| 21 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_defs
.h" |
21 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 22 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
22 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse
rver.h" | 23 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse
rver.h" |
23 #include "chrome/browser/chromeos/file_system_provider/watcher.h" | 24 #include "chrome/browser/chromeos/file_system_provider/watcher.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/common/extensions/api/file_system_provider.h" | 26 #include "chrome/common/extensions/api/file_system_provider.h" |
26 #include "components/keyed_service/core/keyed_service.h" | 27 #include "components/keyed_service/core/keyed_service.h" |
27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
28 #include "extensions/browser/extension_registry_observer.h" | 29 #include "extensions/browser/extension_registry_observer.h" |
29 #include "extensions/common/extension.h" | 30 #include "extensions/common/extension.h" |
30 #include "storage/browser/fileapi/watcher_manager.h" | 31 #include "storage/browser/fileapi/watcher_manager.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 // Sets a custom Registry implementation. Used by unit tests. | 89 // Sets a custom Registry implementation. Used by unit tests. |
89 void SetRegistryForTesting(scoped_ptr<RegistryInterface> registry); | 90 void SetRegistryForTesting(scoped_ptr<RegistryInterface> registry); |
90 | 91 |
91 // Mounts a file system provided by an extension with the |extension_id|. If | 92 // Mounts a file system provided by an extension with the |extension_id|. If |
92 // |writable| is set to true, then the file system is mounted in a R/W mode. | 93 // |writable| is set to true, then the file system is mounted in a R/W mode. |
93 // Otherwise, only read-only operations are supported. If change notification | 94 // Otherwise, only read-only operations are supported. If change notification |
94 // tags are supported, then |supports_notify_tag| must be true. Note, that | 95 // tags are supported, then |supports_notify_tag| must be true. Note, that |
95 // it is required in order to enable the internal cache. For success, returns | 96 // it is required in order to enable the internal cache. For success, returns |
96 // base::File::FILE_OK, otherwise an error code. | 97 // base::File::FILE_OK, otherwise an error code. |
97 base::File::Error MountFileSystem(const std::string& extension_id, | 98 base::File::Error MountFileSystem( |
98 const MountOptions& options); | 99 const std::string& source_id, |
| 100 const MountOptions& options, |
| 101 Source_Type source_type = Source_Type::extension); |
99 | 102 |
100 // Unmounts a file system with the specified |file_system_id| for the | 103 // Unmounts a file system with the specified |file_system_id| for the |
101 // |extension_id|. For success returns base::File::FILE_OK, otherwise an error | 104 // |extension_id|. For success returns base::File::FILE_OK, otherwise an error |
102 // code. | 105 // code. |
103 base::File::Error UnmountFileSystem(const std::string& extension_id, | 106 base::File::Error UnmountFileSystem(const std::string& source_id, |
104 const std::string& file_system_id, | 107 const std::string& file_system_id, |
105 UnmountReason reason); | 108 UnmountReason reason); |
106 | 109 |
107 // Requests unmounting of the file system. Returns false if the request could | 110 // Requests unmounting of the file system. Returns false if the request could |
108 // not been created, true otherwise. | 111 // not been created, true otherwise. |
109 bool RequestUnmount(const std::string& extension_id, | 112 bool RequestUnmount(const std::string& extension_id, |
110 const std::string& file_system_id); | 113 const std::string& file_system_id); |
111 | 114 |
112 // Requests mounting a new file system by the providing extension with | 115 // Requests mounting a new file system by the providing extension with |
113 // |extension_id|. Returns false if the request could not been created, true | 116 // |extension_id|. Returns false if the request could not been created, true |
114 // otherwise. | 117 // otherwise. |
115 bool RequestMount(const std::string& extension_id); | 118 bool RequestMount(const std::string& extension_id); |
116 | 119 |
117 // Returns a list of information of all currently provided file systems. All | 120 // Returns a list of information of all currently provided file systems. All |
118 // items are copied. | 121 // items are copied. |
119 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); | 122 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); |
120 | 123 |
121 // Returns a provided file system with |file_system_id|, handled by | 124 // Returns a provided file system with |file_system_id|, handled by |
122 // the extension with |extension_id|. If not found, then returns NULL. | 125 // the extension with |extension_id|. If not found, then returns NULL. |
123 ProvidedFileSystemInterface* GetProvidedFileSystem( | 126 ProvidedFileSystemInterface* GetProvidedFileSystem( |
124 const std::string& extension_id, | 127 const std::string& source_id, |
125 const std::string& file_system_id); | 128 const std::string& file_system_id); |
126 | 129 |
127 // Returns a provided file system attached to the the passed | 130 // Returns a provided file system attached to the the passed |
128 // |mount_point_name|. If not found, then returns NULL. | 131 // |mount_point_name|. If not found, then returns NULL. |
129 ProvidedFileSystemInterface* GetProvidedFileSystem( | 132 ProvidedFileSystemInterface* GetProvidedFileSystem( |
130 const std::string& mount_point_name); | 133 const std::string& mount_point_name); |
131 | 134 |
132 // Returns a list of information of all currently installed providing | 135 // Returns a list of information of all currently installed providing |
133 // extensions. | 136 // extensions. |
134 std::vector<ProvidingExtensionInfo> GetProvidingExtensionInfoList() const; | 137 std::vector<ProvidingExtensionInfo> GetProvidingExtensionInfoList() const; |
(...skipping 30 matching lines...) Expand all Loading... |
165 // Key is a pair of an extension id and file system id, which makes it | 168 // Key is a pair of an extension id and file system id, which makes it |
166 // unique among the entire service instance. | 169 // unique among the entire service instance. |
167 typedef std::pair<std::string, std::string> FileSystemKey; | 170 typedef std::pair<std::string, std::string> FileSystemKey; |
168 | 171 |
169 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*> | 172 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*> |
170 ProvidedFileSystemMap; | 173 ProvidedFileSystemMap; |
171 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap; | 174 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap; |
172 | 175 |
173 // Mounts the file system in the specified context. See MountFileSystem() for | 176 // Mounts the file system in the specified context. See MountFileSystem() for |
174 // more information. | 177 // more information. |
175 base::File::Error MountFileSystemInternal(const std::string& extension_id, | 178 base::File::Error MountFileSystemInternal( |
176 const MountOptions& options, | 179 const std::string& source_id, |
177 MountContext context); | 180 const MountOptions& options, |
| 181 MountContext context, |
| 182 Source_Type source_type = Source_Type::extension); |
178 | 183 |
179 // Called when the providing extension accepts or refuses a unmount request. | 184 // Called when the providing extension accepts or refuses a unmount request. |
180 // If |error| is equal to FILE_OK, then the request is accepted. | 185 // If |error| is equal to FILE_OK, then the request is accepted. |
181 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, | 186 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, |
182 base::File::Error error); | 187 base::File::Error error); |
183 | 188 |
184 // Remembers the file system in preferences, in order to remount after a | 189 // Remembers the file system in preferences, in order to remount after a |
185 // reboot. | 190 // reboot. |
186 void RememberFileSystem(const ProvidedFileSystemInfo& file_system_info, | 191 void RememberFileSystem(const ProvidedFileSystemInfo& file_system_info, |
187 const Watchers& watchers); | 192 const Watchers& watchers); |
(...skipping 17 matching lines...) Expand all Loading... |
205 base::ThreadChecker thread_checker_; | 210 base::ThreadChecker thread_checker_; |
206 | 211 |
207 base::WeakPtrFactory<Service> weak_ptr_factory_; | 212 base::WeakPtrFactory<Service> weak_ptr_factory_; |
208 DISALLOW_COPY_AND_ASSIGN(Service); | 213 DISALLOW_COPY_AND_ASSIGN(Service); |
209 }; | 214 }; |
210 | 215 |
211 } // namespace file_system_provider | 216 } // namespace file_system_provider |
212 } // namespace chromeos | 217 } // namespace chromeos |
213 | 218 |
214 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 219 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
OLD | NEW |