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 STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ |
6 #define STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ | 6 #define STORAGE_BROWSER_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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 // Returns the virtual root path that looks like /<filesystem_id>. | 160 // Returns the virtual root path that looks like /<filesystem_id>. |
161 base::FilePath CreateVirtualRootPath(const std::string& filesystem_id) const; | 161 base::FilePath CreateVirtualRootPath(const std::string& filesystem_id) const; |
162 | 162 |
163 private: | 163 private: |
164 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; | 164 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; |
165 | 165 |
166 // Represents each file system instance (defined in the .cc). | 166 // Represents each file system instance (defined in the .cc). |
167 class Instance; | 167 class Instance; |
168 | 168 |
169 typedef std::map<std::string, Instance*> IDToInstance; | |
170 | |
171 // Reverse map from registered path to IDs. | |
172 typedef std::map<base::FilePath, std::set<std::string> > PathToID; | |
173 | |
174 // Obtain an instance of this class via GetInstance(). | 169 // Obtain an instance of this class via GetInstance(). |
175 IsolatedContext(); | 170 IsolatedContext(); |
176 ~IsolatedContext() override; | 171 ~IsolatedContext() override; |
177 | 172 |
178 // MountPoints overrides. | 173 // MountPoints overrides. |
179 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const override; | 174 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const override; |
180 | 175 |
181 // Unregisters a file system of given |filesystem_id|. Must be called with | 176 // Unregisters a file system of given |filesystem_id|. Must be called with |
182 // lock_ held. Returns true if the file system is unregistered. | 177 // lock_ held. Returns true if the file system is unregistered. |
183 bool UnregisterFileSystem(const std::string& filesystem_id); | 178 bool UnregisterFileSystem(const std::string& filesystem_id); |
184 | 179 |
185 // Returns a new filesystem_id. Called with lock. | 180 // Returns a new filesystem_id. Called with lock. |
186 std::string GetNewFileSystemId() const; | 181 std::string GetNewFileSystemId() const; |
187 | 182 |
188 // This lock needs to be obtained when accessing the instance_map_. | 183 // This lock needs to be obtained when accessing the instance_map_. |
189 mutable base::Lock lock_; | 184 mutable base::Lock lock_; |
190 | 185 |
191 IDToInstance instance_map_; | 186 std::map<std::string, std::unique_ptr<Instance>> instance_map_; |
192 PathToID path_to_id_map_; | 187 |
| 188 // Reverse map from registered path to IDs. |
| 189 std::map<base::FilePath, std::set<std::string>> path_to_id_map_; |
193 | 190 |
194 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); | 191 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); |
195 }; | 192 }; |
196 | 193 |
197 } // namespace storage | 194 } // namespace storage |
198 | 195 |
199 #endif // STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ | 196 #endif // STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ |
OLD | NEW |