Chromium Code Reviews| Index: storage/browser/fileapi/obfuscated_file_util.cc |
| diff --git a/storage/browser/fileapi/obfuscated_file_util.cc b/storage/browser/fileapi/obfuscated_file_util.cc |
| index 8c02dd11bf4a18e2fbcbd7ab2bdc0edbd6b6a1ca..b2abc373f1bc6f78187ea071afe28098c3cdbbd5 100644 |
| --- a/storage/browser/fileapi/obfuscated_file_util.cc |
| +++ b/storage/browser/fileapi/obfuscated_file_util.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/stl_util.h" |
| #include "base/strings/string_number_conversions.h" |
| +#include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/sys_string_conversions.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -906,6 +907,39 @@ bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType( |
| return true; |
| } |
| +bool ObfuscatedFileUtil::DeleteOriginDirectoryForPluginPrivateFileSystem( |
| + const GURL& origin) { |
| + // Delete the plugin private filesystems from the directory database. |
| + const std::string key_prefix = storage::GetIdentifierFromOrigin(origin); |
| + for (DirectoryMap::iterator iter = directories_.lower_bound(key_prefix); |
| + iter != directories_.end();) { |
| + if (!StartsWithASCII(iter->first, key_prefix, true)) |
| + break; |
| + SandboxDirectoryDatabase* database = iter->second; |
| + directories_.erase(iter++); |
| + delete database; |
|
xhwang
2014/09/22 16:41:25
If you use ScopedPtrHashMap for DirectoryMap you d
nhiroki
2014/09/24 06:00:31
Good idea! I'll make a separate patch to replace t
nhiroki
2014/09/25 10:34:16
I tried to replace them with ScopedPtrHashMap in h
|
| + } |
| + |
| + base::File::Error error = base::File::FILE_OK; |
| + |
| + // |origin_path| points to "/path/to/File System/Plugins/<origin>". |
| + base::FilePath origin_path = GetDirectoryForOrigin(origin, false, &error); |
| + if (!origin_path.empty()) { |
| + if (!SandboxDirectoryDatabase::DestroyDatabase(origin_path, env_override_)) |
| + return false; |
| + if (!base::DeleteFile(origin_path, true /* recursive */)) |
| + return false; |
| + } |
| + |
| + // Delete the origin directory from the origin database. |
| + InitOriginDatabase(origin, false); |
| + if (origin_database_) { |
| + origin_database_->RemovePathForOrigin( |
| + storage::GetIdentifierFromOrigin(origin)); |
| + } |
| + return true; |
| +} |
| + |
| ObfuscatedFileUtil::AbstractOriginEnumerator* |
| ObfuscatedFileUtil::CreateOriginEnumerator() { |
| std::vector<SandboxOriginDatabase::OriginRecord> origins; |