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