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

Unified Diff: webkit/fileapi/isolated_context.cc

Issue 10536200: Manage IsolatedContext with reference counts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « webkit/fileapi/isolated_context.h ('k') | webkit/fileapi/isolated_context_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/isolated_context.cc
diff --git a/webkit/fileapi/isolated_context.cc b/webkit/fileapi/isolated_context.cc
index e8b52ae83f0ae9bc77904e2934878aac00714bde..adece4277a539b45a47ca7f15b2f487acb8f66ee 100644
--- a/webkit/fileapi/isolated_context.cc
+++ b/webkit/fileapi/isolated_context.cc
@@ -43,15 +43,24 @@ std::string IsolatedContext::RegisterIsolatedFileSystem(
toplevels.insert(std::make_pair(basename, fullpath));
}
toplevel_map_[filesystem_id] = toplevels;
+
+ // Each file system is created with refcount == 0.
+ ref_counts_[filesystem_id] = 0;
+
return filesystem_id;
}
-// Revoke any registered drag context for the child_id.
-void IsolatedContext::RevokeIsolatedFileSystem(
- const std::string& filesystem_id) {
+void IsolatedContext::AddReference(const std::string& filesystem_id) {
base::AutoLock locker(lock_);
- toplevel_map_.erase(filesystem_id);
- writable_ids_.erase(filesystem_id);
+ DCHECK(ref_counts_.find(filesystem_id) != ref_counts_.end());
+ ref_counts_[filesystem_id]++;
+}
+
+void IsolatedContext::RemoveReference(const std::string& filesystem_id) {
+ base::AutoLock locker(lock_);
tzik 2012/06/21 14:00:35 Could you add DCHECK(ref_counts_.find(filesystem_i
kinuko 2012/06/22 04:53:30 Done. We didn't have similar check in RevokeIsola
+ // Refcount could become <0 if it has never gotten referenced.
+ if (--ref_counts_[filesystem_id] <= 0)
+ RevokeWithoutLocking(filesystem_id);
}
bool IsolatedContext::CrackIsolatedPath(const FilePath& virtual_path,
@@ -147,6 +156,13 @@ IsolatedContext::IsolatedContext() {
IsolatedContext::~IsolatedContext() {
}
+void IsolatedContext::RevokeWithoutLocking(
+ const std::string& filesystem_id) {
+ toplevel_map_.erase(filesystem_id);
+ writable_ids_.erase(filesystem_id);
+ ref_counts_.erase(filesystem_id);
+}
+
std::string IsolatedContext::GetNewFileSystemId() const {
// Returns an arbitrary random string which must be unique in the map.
uint32 random_data[4];
« no previous file with comments | « webkit/fileapi/isolated_context.h ('k') | webkit/fileapi/isolated_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698