Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1075)

Side by Side Diff: webkit/fileapi/isolated_context.h

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/file_system_url_unittest.cc ('k') | webkit/fileapi/isolated_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "webkit/fileapi/file_system_types.h" 18 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/fileapi/mount_points.h" 19 #include "webkit/fileapi/mount_points.h"
20 #include "webkit/storage/webkit_storage_export.h" 20 #include "webkit/storage/webkit_storage_export.h"
21 21
22 namespace fileapi { 22 namespace fileapi {
23 class FileSystemURL;
24 }
25
26 namespace fileapi {
23 27
24 // Manages isolated filesystem mount points which have no well-known names 28 // Manages isolated filesystem mount points which have no well-known names
25 // and are identified by a string 'filesystem ID', which usually just looks 29 // and are identified by a string 'filesystem ID', which usually just looks
26 // like random value. 30 // like random value.
27 // This type of filesystem can be created on the fly and may go away when it has 31 // This type of filesystem can be created on the fly and may go away when it has
28 // no references from renderers. 32 // no references from renderers.
29 // Files in an isolated filesystem are registered with corresponding names and 33 // Files in an isolated filesystem are registered with corresponding names and
30 // identified by a filesystem URL like: 34 // identified by a filesystem URL like:
31 // 35 //
32 // filesystem:<origin>/isolated/<filesystem_id>/<name>/relative/path 36 // filesystem:<origin>/isolated/<filesystem_id>/<name>/relative/path
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Registers a new isolated filesystem for a given |path| of filesystem 95 // Registers a new isolated filesystem for a given |path| of filesystem
92 // |type| filesystem and returns a new filesystem ID. 96 // |type| filesystem and returns a new filesystem ID.
93 // |path| must be an absolute path which has no parent references ('..'). 97 // |path| must be an absolute path which has no parent references ('..').
94 // If |register_name| is non-null and has non-empty string the path is 98 // If |register_name| is non-null and has non-empty string the path is
95 // registered as the given |register_name|, otherwise it is populated 99 // registered as the given |register_name|, otherwise it is populated
96 // with the name internally assigned to the path. 100 // with the name internally assigned to the path.
97 std::string RegisterFileSystemForPath(FileSystemType type, 101 std::string RegisterFileSystemForPath(FileSystemType type,
98 const FilePath& path, 102 const FilePath& path,
99 std::string* register_name); 103 std::string* register_name);
100 104
101 // MountPoints override.
102 virtual bool RevokeFileSystem(const std::string& filesystem_id) OVERRIDE;
103 virtual bool GetRegisteredPath(const std::string& filesystem_id,
104 FilePath* path) const OVERRIDE;
105 virtual bool CrackVirtualPath(const FilePath& virtual_path,
106 std::string* filesystem_id,
107 FileSystemType* type,
108 FilePath* path) const OVERRIDE;
109
110 // Revokes all filesystem(s) registered for the given path. 105 // Revokes all filesystem(s) registered for the given path.
111 // This is assumed to be called when the registered path becomes 106 // This is assumed to be called when the registered path becomes
112 // globally invalid, e.g. when a device for the path is detached. 107 // globally invalid, e.g. when a device for the path is detached.
113 // 108 //
114 // Note that this revokes the filesystem no matter how many references it has. 109 // Note that this revokes the filesystem no matter how many references it has.
115 // It is ok to call this for the path that has no associated filesystems. 110 // It is ok to call this for the path that has no associated filesystems.
116 // Note that this only works for the filesystems registered by 111 // Note that this only works for the filesystems registered by
117 // |RegisterFileSystemForPath|. 112 // |RegisterFileSystemForPath|.
118 void RevokeFileSystemByPath(const FilePath& path); 113 void RevokeFileSystemByPath(const FilePath& path);
119 114
120 // Adds a reference to a filesystem specified by the given filesystem_id. 115 // Adds a reference to a filesystem specified by the given filesystem_id.
121 void AddReference(const std::string& filesystem_id); 116 void AddReference(const std::string& filesystem_id);
122 117
123 // Removes a reference to a filesystem specified by the given filesystem_id. 118 // Removes a reference to a filesystem specified by the given filesystem_id.
124 // If the reference count reaches 0 the isolated context gets destroyed. 119 // If the reference count reaches 0 the isolated context gets destroyed.
125 // It is OK to call this on the filesystem that has been already deleted 120 // It is OK to call this on the filesystem that has been already deleted
126 // (e.g. by RevokeFileSystemByPath). 121 // (e.g. by RevokeFileSystemByPath).
127 void RemoveReference(const std::string& filesystem_id); 122 void RemoveReference(const std::string& filesystem_id);
128 123
129 // Returns a set of dragged MountPointInfos registered for the 124 // Returns a set of dragged MountPointInfos registered for the
130 // |filesystem_id|. 125 // |filesystem_id|.
131 // The filesystem_id must be pointing to a dragged file system 126 // The filesystem_id must be pointing to a dragged file system
132 // (i.e. must be the one registered by RegisterDraggedFileSystem). 127 // (i.e. must be the one registered by RegisterDraggedFileSystem).
133 // Returns false if the |filesystem_id| is not valid. 128 // Returns false if the |filesystem_id| is not valid.
134 bool GetDraggedFileInfo(const std::string& filesystem_id, 129 bool GetDraggedFileInfo(const std::string& filesystem_id,
135 std::vector<MountPointInfo>* files) const; 130 std::vector<MountPointInfo>* files) const;
136 131
132 // MountPoints overrides.
133 virtual bool HandlesFileSystemMountType(FileSystemType type) const OVERRIDE;
134 virtual bool RevokeFileSystem(const std::string& filesystem_id) OVERRIDE;
135 virtual bool GetRegisteredPath(const std::string& filesystem_id,
136 FilePath* path) const OVERRIDE;
137 virtual bool CrackVirtualPath(const FilePath& virtual_path,
138 std::string* filesystem_id,
139 FileSystemType* type,
140 FilePath* path) const OVERRIDE;
141 virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE;
142 virtual FileSystemURL CreateCrackedFileSystemURL(
143 const GURL& origin,
144 FileSystemType type,
145 const FilePath& path) const OVERRIDE;
146
137 // Returns the virtual root path that looks like /<filesystem_id>. 147 // Returns the virtual root path that looks like /<filesystem_id>.
138 FilePath CreateVirtualRootPath(const std::string& filesystem_id) const; 148 FilePath CreateVirtualRootPath(const std::string& filesystem_id) const;
139 149
140 private: 150 private:
141 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; 151 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>;
142 152
143 // Represents each file system instance (defined in the .cc). 153 // Represents each file system instance (defined in the .cc).
144 class Instance; 154 class Instance;
145 155
146 typedef std::map<std::string, Instance*> IDToInstance; 156 typedef std::map<std::string, Instance*> IDToInstance;
(...skipping 17 matching lines...) Expand all
164 174
165 IDToInstance instance_map_; 175 IDToInstance instance_map_;
166 PathToID path_to_id_map_; 176 PathToID path_to_id_map_;
167 177
168 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); 178 DISALLOW_COPY_AND_ASSIGN(IsolatedContext);
169 }; 179 };
170 180
171 } // namespace fileapi 181 } // namespace fileapi
172 182
173 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ 183 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_url_unittest.cc ('k') | webkit/fileapi/isolated_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698