summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-14 06:54:18 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-14 06:54:18 +0000
commitc0229d005f10b612bba2bd714f70b20aa55f5202 (patch)
treebdd3b38d245839c7472e2270ad4bce4aec67297b /webkit/fileapi
parent1d0a00e48f6ba2c4760f7db0daa63e2eb3986fd5 (diff)
downloadchromium_src-c0229d005f10b612bba2bd714f70b20aa55f5202.zip
chromium_src-c0229d005f10b612bba2bd714f70b20aa55f5202.tar.gz
chromium_src-c0229d005f10b612bba2bd714f70b20aa55f5202.tar.bz2
Delete filesystem origin info in the origin database if it is empty
Note that we only do this if a filesystem for a particular origin/type pair is deleted via QuotaClient::DeleteOriginData BUG=86087 TEST=manually tested Review URL: http://codereview.chromium.org/7324053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_context.cc16
-rw-r--r--webkit/fileapi/obfuscated_file_system_file_util.cc24
2 files changed, 24 insertions, 16 deletions
diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc
index 16bf067..d4dffc2 100644
--- a/webkit/fileapi/file_system_context.cc
+++ b/webkit/fileapi/file_system_context.cc
@@ -73,17 +73,11 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread(
DCHECK(sandbox_provider());
// Delete temporary and persistent data.
- sandbox_provider()->DeleteOriginDataOnFileThread(
- quota_manager_proxy(), origin_url, kFileSystemTypeTemporary);
- sandbox_provider()->DeleteOriginDataOnFileThread(
- quota_manager_proxy(), origin_url, kFileSystemTypePersistent);
-
- // Delete the upper level directory.
- FilePath path_for_origin =
- sandbox_provider()->GetBaseDirectoryForOrigin(origin_url, false);
- if (!file_util::PathExists(path_for_origin))
- return true;
- return file_util::Delete(path_for_origin, true /* recursive */);
+ return
+ sandbox_provider()->DeleteOriginDataOnFileThread(
+ quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) &&
+ sandbox_provider()->DeleteOriginDataOnFileThread(
+ quota_manager_proxy(), origin_url, kFileSystemTypePersistent);
}
bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread(
diff --git a/webkit/fileapi/obfuscated_file_system_file_util.cc b/webkit/fileapi/obfuscated_file_system_file_util.cc
index b28dc92..48a5336 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util.cc
+++ b/webkit/fileapi/obfuscated_file_system_file_util.cc
@@ -22,8 +22,6 @@
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
-// TODO(ericu): Make deleting an origin [or a type under the origin, if it's the
-// last type] remove the origin from origin_database_ as well.
namespace {
const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes
@@ -848,8 +846,8 @@ FilePath ObfuscatedFileSystemFileUtil::GetDirectoryForOrigin(
bool ObfuscatedFileSystemFileUtil::DeleteDirectoryForOriginAndType(
const GURL& origin, FileSystemType type) {
- FilePath path_for_origin = GetDirectoryForOriginAndType(origin, type, false);
- if (!file_util::PathExists(path_for_origin))
+ FilePath origin_type_path = GetDirectoryForOriginAndType(origin, type, false);
+ if (!file_util::PathExists(origin_type_path))
return true;
// TODO(dmikurube): Consider the return value of DestroyDirectoryDatabase.
@@ -857,7 +855,23 @@ bool ObfuscatedFileSystemFileUtil::DeleteDirectoryForOriginAndType(
// 2) it always returns false in Windows because of LevelDB's implementation.
// Information about failure would be useful for debugging.
DestroyDirectoryDatabase(origin, type);
- return file_util::Delete(path_for_origin, true /* recursive */);
+ if (!file_util::Delete(origin_type_path, true /* recursive */))
+ return false;
+
+ FilePath origin_path = origin_type_path.DirName();
+ DCHECK_EQ(origin_path.value(), GetDirectoryForOrigin(origin, false).value());
+
+ // Delete the origin directory if the deleted one was the last remaining
+ // type for the origin.
+ if (file_util::Delete(origin_path, false /* recursive */)) {
+ InitOriginDatabase(false);
+ if (origin_database_.get())
+ origin_database_->RemovePathForOrigin(GetOriginIdentifierFromURL(origin));
+ }
+
+ // At this point we are sure we had successfully deleted the origin/type
+ // directory, so just returning true here.
+ return true;
}
bool ObfuscatedFileSystemFileUtil::MigrateFromOldSandbox(