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

Unified Diff: webkit/fileapi/isolated_context.cc

Issue 10837217: Add RevokeFileSystem back to IsolatedContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 957680d06f3b7701d55e88a25a31b6399bc8540a..45ac32d26b7068d2dbb5a5d0e8e475ba46e09a93 100644
--- a/webkit/fileapi/isolated_context.cc
+++ b/webkit/fileapi/isolated_context.cc
@@ -166,8 +166,9 @@ std::string IsolatedContext::RegisterDraggedFileSystem(
std::string IsolatedContext::RegisterFileSystemForPath(
FileSystemType type,
- const FilePath& path,
+ const FilePath& path_in,
std::string* register_name) {
+ FilePath path(path_in.NormalizePathSeparators());
DCHECK(!path.ReferencesParent() && path.IsAbsolute());
std::string name;
if (register_name && !register_name->empty()) {
@@ -185,8 +186,14 @@ std::string IsolatedContext::RegisterFileSystemForPath(
return filesystem_id;
}
-void IsolatedContext::RevokeFileSystemByPath(const FilePath& path) {
+bool IsolatedContext::RevokeFileSystem(const std::string& id_or_name) {
base::AutoLock locker(lock_);
+ return UnregisterFileSystem(id_or_name);
+}
+
+void IsolatedContext::RevokeFileSystemByPath(const FilePath& path_in) {
+ base::AutoLock locker(lock_);
+ FilePath path(path_in.NormalizePathSeparators());
PathToID::iterator ids_iter = path_to_id_map_.find(path);
if (ids_iter == path_to_id_map_.end())
return;
@@ -219,16 +226,8 @@ void IsolatedContext::RemoveReference(const std::string& filesystem_id) {
DCHECK(instance->ref_counts() > 0);
instance->RemoveRef();
if (instance->ref_counts() == 0) {
- if (instance->IsSinglePathInstance()) {
- PathToID::iterator ids_iter = path_to_id_map_.find(
- instance->file_info().path);
- DCHECK(ids_iter != path_to_id_map_.end());
- ids_iter->second.erase(filesystem_id);
- if (ids_iter->second.empty())
- path_to_id_map_.erase(ids_iter);
- }
- delete instance;
- instance_map_.erase(found);
+ bool deleted = UnregisterFileSystem(filesystem_id);
+ DCHECK(deleted);
}
}
@@ -311,6 +310,24 @@ IsolatedContext::~IsolatedContext() {
instance_map_.end());
}
+bool IsolatedContext::UnregisterFileSystem(const std::string& filesystem_id) {
tzik 2012/08/13 09:03:32 Could you add some assertion like this (maybe in s
kinuko 2012/08/13 09:20:26 Good idea! Done.
+ IDToInstance::iterator found = instance_map_.find(filesystem_id);
+ if (found == instance_map_.end())
+ return false;
+ Instance* instance = found->second;
+ if (instance->IsSinglePathInstance()) {
+ PathToID::iterator ids_iter = path_to_id_map_.find(
+ instance->file_info().path);
+ DCHECK(ids_iter != path_to_id_map_.end());
+ ids_iter->second.erase(filesystem_id);
+ if (ids_iter->second.empty())
+ path_to_id_map_.erase(ids_iter);
+ }
+ delete found->second;
+ instance_map_.erase(found);
+ return true;
+}
+
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