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]; |