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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // Returns a set of dragged MountPointInfos registered for the | 135 // Returns a set of dragged MountPointInfos registered for the |
136 // |filesystem_id|. | 136 // |filesystem_id|. |
137 // The filesystem_id must be pointing to a dragged file system | 137 // The filesystem_id must be pointing to a dragged file system |
138 // (i.e. must be the one registered by RegisterDraggedFileSystem). | 138 // (i.e. must be the one registered by RegisterDraggedFileSystem). |
139 // Returns false if the |filesystem_id| is not valid. | 139 // Returns false if the |filesystem_id| is not valid. |
140 bool GetDraggedFileInfo(const std::string& filesystem_id, | 140 bool GetDraggedFileInfo(const std::string& filesystem_id, |
141 std::vector<MountPointInfo>* files) const; | 141 std::vector<MountPointInfo>* files) const; |
142 | 142 |
143 // MountPoints overrides. | 143 // MountPoints overrides. |
144 virtual bool HandlesFileSystemMountType(FileSystemType type) const override; | 144 bool HandlesFileSystemMountType(FileSystemType type) const override; |
145 virtual bool RevokeFileSystem(const std::string& filesystem_id) override; | 145 bool RevokeFileSystem(const std::string& filesystem_id) override; |
146 virtual bool GetRegisteredPath(const std::string& filesystem_id, | 146 bool GetRegisteredPath(const std::string& filesystem_id, |
147 base::FilePath* path) const override; | 147 base::FilePath* path) const override; |
148 virtual bool CrackVirtualPath( | 148 bool CrackVirtualPath(const base::FilePath& virtual_path, |
149 const base::FilePath& virtual_path, | 149 std::string* filesystem_id, |
150 std::string* filesystem_id, | 150 FileSystemType* type, |
151 FileSystemType* type, | 151 std::string* cracked_id, |
152 std::string* cracked_id, | 152 base::FilePath* path, |
153 base::FilePath* path, | 153 FileSystemMountOption* mount_option) const override; |
154 FileSystemMountOption* mount_option) const override; | 154 FileSystemURL CrackURL(const GURL& url) const override; |
155 virtual FileSystemURL CrackURL(const GURL& url) const override; | 155 FileSystemURL CreateCrackedFileSystemURL( |
156 virtual FileSystemURL CreateCrackedFileSystemURL( | |
157 const GURL& origin, | 156 const GURL& origin, |
158 FileSystemType type, | 157 FileSystemType type, |
159 const base::FilePath& path) const override; | 158 const base::FilePath& path) const override; |
160 | 159 |
161 // Returns the virtual root path that looks like /<filesystem_id>. | 160 // Returns the virtual root path that looks like /<filesystem_id>. |
162 base::FilePath CreateVirtualRootPath(const std::string& filesystem_id) const; | 161 base::FilePath CreateVirtualRootPath(const std::string& filesystem_id) const; |
163 | 162 |
164 private: | 163 private: |
165 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; | 164 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; |
166 | 165 |
167 // Represents each file system instance (defined in the .cc). | 166 // Represents each file system instance (defined in the .cc). |
168 class Instance; | 167 class Instance; |
169 | 168 |
170 typedef std::map<std::string, Instance*> IDToInstance; | 169 typedef std::map<std::string, Instance*> IDToInstance; |
171 | 170 |
172 // Reverse map from registered path to IDs. | 171 // Reverse map from registered path to IDs. |
173 typedef std::map<base::FilePath, std::set<std::string> > PathToID; | 172 typedef std::map<base::FilePath, std::set<std::string> > PathToID; |
174 | 173 |
175 // Obtain an instance of this class via GetInstance(). | 174 // Obtain an instance of this class via GetInstance(). |
176 IsolatedContext(); | 175 IsolatedContext(); |
177 virtual ~IsolatedContext(); | 176 ~IsolatedContext() override; |
178 | 177 |
179 // MountPoints overrides. | 178 // MountPoints overrides. |
180 virtual FileSystemURL CrackFileSystemURL( | 179 FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const override; |
181 const FileSystemURL& url) const override; | |
182 | 180 |
183 // Unregisters a file system of given |filesystem_id|. Must be called with | 181 // Unregisters a file system of given |filesystem_id|. Must be called with |
184 // lock_ held. Returns true if the file system is unregistered. | 182 // lock_ held. Returns true if the file system is unregistered. |
185 bool UnregisterFileSystem(const std::string& filesystem_id); | 183 bool UnregisterFileSystem(const std::string& filesystem_id); |
186 | 184 |
187 // Returns a new filesystem_id. Called with lock. | 185 // Returns a new filesystem_id. Called with lock. |
188 std::string GetNewFileSystemId() const; | 186 std::string GetNewFileSystemId() const; |
189 | 187 |
190 // This lock needs to be obtained when accessing the instance_map_. | 188 // This lock needs to be obtained when accessing the instance_map_. |
191 mutable base::Lock lock_; | 189 mutable base::Lock lock_; |
192 | 190 |
193 IDToInstance instance_map_; | 191 IDToInstance instance_map_; |
194 PathToID path_to_id_map_; | 192 PathToID path_to_id_map_; |
195 | 193 |
196 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); | 194 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); |
197 }; | 195 }; |
198 | 196 |
199 } // namespace storage | 197 } // namespace storage |
200 | 198 |
201 #endif // STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ | 199 #endif // STORAGE_BROWSER_FILEAPI_ISOLATED_CONTEXT_H_ |
OLD | NEW |