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

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: fixes 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..6398e42ea336db68c8c0b0898a7f66d41eafc05d 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& filesystem_id) {
base::AutoLock locker(lock_);
+ return UnregisterFileSystem(filesystem_id);
kinuko 2012/08/13 09:20:26 Changed the mysterious argument name to our usual
+}
+
+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);
}
}
@@ -268,6 +267,7 @@ bool IsolatedContext::CrackIsolatedPath(const FilePath& virtual_path,
std::string name = FilePath(components[1]).AsUTF8Unsafe();
if (!found_instance->second->ResolvePathForName(name, &cracked_path))
return false;
+
for (size_t i = 2; i < components.size(); ++i)
cracked_path = cracked_path.Append(components[i]);
*path = cracked_path;
@@ -311,8 +311,28 @@ IsolatedContext::~IsolatedContext() {
instance_map_.end());
}
+bool IsolatedContext::UnregisterFileSystem(const std::string& filesystem_id) {
+ lock_.AssertAcquired();
+ 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.
+ lock_.AssertAcquired();
uint32 random_data[4];
std::string id;
do {
« 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