| 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_ISOLATED_CONTEXT_H_ | 5 #ifndef WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ |
| 6 #define WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ | 6 #define WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // Registers a new isolated filesystem for a given |path| of filesystem | 94 // Registers a new isolated filesystem for a given |path| of filesystem |
| 95 // |type| filesystem and returns a new filesystem ID. | 95 // |type| filesystem and returns a new filesystem ID. |
| 96 // |path| must be an absolute path which has no parent references ('..'). | 96 // |path| must be an absolute path which has no parent references ('..'). |
| 97 // If |register_name| is non-null and has non-empty string the path is | 97 // If |register_name| is non-null and has non-empty string the path is |
| 98 // registered as the given |register_name|, otherwise it is populated | 98 // registered as the given |register_name|, otherwise it is populated |
| 99 // with the name internally assigned to the path. | 99 // with the name internally assigned to the path. |
| 100 std::string RegisterFileSystemForPath(FileSystemType type, | 100 std::string RegisterFileSystemForPath(FileSystemType type, |
| 101 const FilePath& path, | 101 const FilePath& path, |
| 102 std::string* register_name); | 102 std::string* register_name); |
| 103 | 103 |
| 104 // Revokes the filesystem |filesystem_id| |
| 105 // Returns false if the |filesystem_id| is not (no longer) registered. |
| 106 bool RevokeFileSystem(const std::string& filesystem_id); |
| 107 |
| 104 // Revokes all filesystem(s) registered for the given path. | 108 // Revokes all filesystem(s) registered for the given path. |
| 105 // This is assumed to be called when the registered path becomes | 109 // This is assumed to be called when the registered path becomes |
| 106 // globally invalid, e.g. when a device for the path is detached. | 110 // globally invalid, e.g. when a device for the path is detached. |
| 107 // | 111 // |
| 108 // Note that this revokes the filesystem no matter how many references it has. | 112 // Note that this revokes the filesystem no matter how many references it has. |
| 109 // It is ok to call this for the path that has no associated filesystems. | 113 // It is ok to call this for the path that has no associated filesystems. |
| 110 // Note that this only works for the filesystems registered by | 114 // Note that this only works for the filesystems registered by |
| 111 // |RegisterFileSystemForPath|. | 115 // |RegisterFileSystemForPath|. |
| 112 void RevokeFileSystemByPath(const FilePath& path); | 116 void RevokeFileSystemByPath(const FilePath& path); |
| 113 | 117 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 206 |
| 203 typedef std::map<std::string, Instance*> IDToInstance; | 207 typedef std::map<std::string, Instance*> IDToInstance; |
| 204 | 208 |
| 205 // Reverse map from registered path to IDs. | 209 // Reverse map from registered path to IDs. |
| 206 typedef std::map<FilePath, std::set<std::string> > PathToID; | 210 typedef std::map<FilePath, std::set<std::string> > PathToID; |
| 207 | 211 |
| 208 // Obtain an instance of this class via GetInstance(). | 212 // Obtain an instance of this class via GetInstance(). |
| 209 IsolatedContext(); | 213 IsolatedContext(); |
| 210 ~IsolatedContext(); | 214 ~IsolatedContext(); |
| 211 | 215 |
| 216 // Unregisters a file system of given |filesystem_id|. Must be called with |
| 217 // lock_ held. Returns true if the file system is unregistered. |
| 218 bool UnregisterFileSystem(const std::string& filesystem_id); |
| 219 |
| 212 // Returns a new filesystem_id. Called with lock. | 220 // Returns a new filesystem_id. Called with lock. |
| 213 std::string GetNewFileSystemId() const; | 221 std::string GetNewFileSystemId() const; |
| 214 | 222 |
| 215 // This lock needs to be obtained when accessing the instance_map_. | 223 // This lock needs to be obtained when accessing the instance_map_. |
| 216 mutable base::Lock lock_; | 224 mutable base::Lock lock_; |
| 217 | 225 |
| 218 IDToInstance instance_map_; | 226 IDToInstance instance_map_; |
| 219 PathToID path_to_id_map_; | 227 PathToID path_to_id_map_; |
| 220 | 228 |
| 221 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); | 229 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); |
| 222 }; | 230 }; |
| 223 | 231 |
| 224 } // namespace fileapi | 232 } // namespace fileapi |
| 225 | 233 |
| 226 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ | 234 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ |
| OLD | NEW |