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

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

Issue 10658029: Revert 144115 - Manage IsolatedContext with reference counts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
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>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // it can properly return the original path '/a/b/foo' by looking up the 47 // it can properly return the original path '/a/b/foo' by looking up the
48 // internal mapping. Similarly if a dropped entry is a directory and its 48 // internal mapping. Similarly if a dropped entry is a directory and its
49 // path is like '/a/b/dir' a virtual path like '/<fsid>/dir/foo' can be 49 // path is like '/a/b/dir' a virtual path like '/<fsid>/dir/foo' can be
50 // cracked into '/a/b/dir/foo'. 50 // cracked into '/a/b/dir/foo'.
51 // 51 //
52 // This may return an empty string (thus invalid as an ID) if the given 52 // This may return an empty string (thus invalid as an ID) if the given
53 // file set contains non absolute paths. 53 // file set contains non absolute paths.
54 std::string RegisterIsolatedFileSystem(const std::set<FilePath>& fileset); 54 std::string RegisterIsolatedFileSystem(const std::set<FilePath>& fileset);
55 55
56 // Revokes filesystem specified by the given filesystem_id. 56 // Revokes filesystem specified by the given filesystem_id.
57 // Note that this revokes the filesystem no matter how many references it has.
58 // It is ok to call this on the filesystem that has been already deleted
59 // (if its reference count had reached 0).
60 void RevokeIsolatedFileSystem(const std::string& filesystem_id); 57 void RevokeIsolatedFileSystem(const std::string& filesystem_id);
61 58
62 // Adds a reference to a filesystem specified by the given filesystem_id.
63 void AddReference(const std::string& filesystem_id);
64
65 // Removes a reference to a filesystem specified by the given filesystem_id.
66 // If the reference count reaches 0 the isolated context gets destroyed.
67 // It is ok to call this on the filesystem that has been already deleted
68 // (e.g. by RevokeIsolatedFileSystem).
69 void RemoveReference(const std::string& filesystem_id);
70
71 // Cracks the given |virtual_path| (which should look like 59 // Cracks the given |virtual_path| (which should look like
72 // "/<filesystem_id>/<relative_path>") and populates the |filesystem_id| 60 // "/<filesystem_id>/<relative_path>") and populates the |filesystem_id|
73 // and |platform_path| if the embedded <filesystem_id> is registerred 61 // and |platform_path| if the embedded <filesystem_id> is registerred
74 // to this context. |root_path| is also populated to have the platform 62 // to this context. |root_path| is also populated to have the platform
75 // root (toplevel) path for the |virtual_path| 63 // root (toplevel) path for the |virtual_path|
76 // (i.e. |platform_path| = |root_path| + <relative_path>). 64 // (i.e. |platform_path| = |root_path| + <relative_path>).
77 // 65 //
78 // Returns false if the given virtual_path or the cracked filesystem_id 66 // Returns false if the given virtual_path or the cracked filesystem_id
79 // is not valid. 67 // is not valid.
80 // 68 //
(...skipping 26 matching lines...) Expand all
107 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; 95 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>;
108 96
109 // Maps from filesystem id to a path conversion map for top-level entries. 97 // Maps from filesystem id to a path conversion map for top-level entries.
110 typedef std::map<FilePath, FilePath> PathMap; 98 typedef std::map<FilePath, FilePath> PathMap;
111 typedef std::map<std::string, PathMap> IDToPathMap; 99 typedef std::map<std::string, PathMap> IDToPathMap;
112 100
113 // Obtain an instance of this class via GetInstance(). 101 // Obtain an instance of this class via GetInstance().
114 IsolatedContext(); 102 IsolatedContext();
115 ~IsolatedContext(); 103 ~IsolatedContext();
116 104
117 // Removes the given filesystem without locking.
118 // (The caller must hold a lock)
119 void RevokeWithoutLocking(const std::string& filesystem_id);
120
121 // Returns a new filesystem_id. Called with lock. 105 // Returns a new filesystem_id. Called with lock.
122 std::string GetNewFileSystemId() const; 106 std::string GetNewFileSystemId() const;
123 107
124 // This lock needs to be obtained when accessing the toplevel_map_. 108 // This lock needs to be obtained when accessing the toplevel_map_.
125 mutable base::Lock lock_; 109 mutable base::Lock lock_;
126 110
127 // Maps the toplevel entries to the filesystem id. 111 // Maps the toplevel entries to the filesystem id.
128 IDToPathMap toplevel_map_; 112 IDToPathMap toplevel_map_;
129 113
130 // Holds a set of writable ids. 114 // Holds a set of writable ids.
131 // Isolated file systems are created read-only by default, and this set 115 // Isolated file systems are created read-only by default, and this set
132 // holds a list of exceptions. 116 // holds a list of exceptions.
133 // Detailed filesystem permission may be provided by an external 117 // Detailed filesystem permission may be provided by an external
134 // security policy manager, e.g. ChildProcessSecurityPolicy. 118 // security policy manager, e.g. ChildProcessSecurityPolicy.
135 std::set<std::string> writable_ids_; 119 std::set<std::string> writable_ids_;
136 120
137 // Reference counts. Note that an isolated filesystem is created with ref==0.
138 // and will get deleted when the ref count reaches <=0.
139 std::map<std::string, int> ref_counts_;
140
141 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); 121 DISALLOW_COPY_AND_ASSIGN(IsolatedContext);
142 }; 122 };
143 123
144 } // namespace fileapi 124 } // namespace fileapi
145 125
146 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ 126 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_unittest.cc ('k') | webkit/fileapi/isolated_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698