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

Unified Diff: webkit/fileapi/isolated_context.h

Issue 10536200: Manage IsolatedContext with reference counts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win test fix Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/isolated_context.h
diff --git a/webkit/fileapi/isolated_context.h b/webkit/fileapi/isolated_context.h
index fa6d0a9ef0011d81c969f509eb0e3b6778611f34..15603281a782c63a56d8580c0dcac9eb00d192bf 100644
--- a/webkit/fileapi/isolated_context.h
+++ b/webkit/fileapi/isolated_context.h
@@ -54,8 +54,20 @@ class FILEAPI_EXPORT IsolatedContext {
std::string RegisterIsolatedFileSystem(const std::set<FilePath>& fileset);
// Revokes filesystem specified by the given filesystem_id.
+ // Note that this revokes the filesystem no matter how many references it has.
+ // It is ok to call this on the filesystem that has been already deleted
+ // (if its reference count had reached 0).
void RevokeIsolatedFileSystem(const std::string& filesystem_id);
+ // Adds a reference to a filesystem specified by the given filesystem_id.
+ void AddReference(const std::string& filesystem_id);
+
+ // Removes a reference to a filesystem specified by the given filesystem_id.
+ // If the reference count reaches 0 the isolated context gets destroyed.
+ // It is ok to call this on the filesystem that has been already deleted
+ // (e.g. by RevokeIsolatedFileSystem).
+ void RemoveReference(const std::string& filesystem_id);
+
// Cracks the given |virtual_path| (which should look like
// "/<filesystem_id>/<relative_path>") and populates the |filesystem_id|
// and |platform_path| if the embedded <filesystem_id> is registerred
@@ -102,6 +114,10 @@ class FILEAPI_EXPORT IsolatedContext {
IsolatedContext();
~IsolatedContext();
+ // Removes the given filesystem without locking.
+ // (The caller must hold a lock)
+ void RevokeWithoutLocking(const std::string& filesystem_id);
+
// Returns a new filesystem_id. Called with lock.
std::string GetNewFileSystemId() const;
@@ -118,6 +134,10 @@ class FILEAPI_EXPORT IsolatedContext {
// security policy manager, e.g. ChildProcessSecurityPolicy.
std::set<std::string> writable_ids_;
+ // Reference counts. Note that an isolated filesystem is created with ref==0.
+ // and will get deleted when the ref count reaches <=0.
+ std::map<std::string, int> ref_counts_;
+
DISALLOW_COPY_AND_ASSIGN(IsolatedContext);
};

Powered by Google App Engine
This is Rietveld 408576698