Index: chrome/browser/browsing_data_remover.cc |
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc |
index 74e294c9e66b0cecc6a62bfc5317582ad1432dd8..3a2bded35dceb68bbb700e4a6a03c34bfd3c9d47 100644 |
--- a/chrome/browser/browsing_data_remover.cc |
+++ b/chrome/browser/browsing_data_remover.cc |
@@ -7,6 +7,8 @@ |
#include <map> |
#include <set> |
+#include "base/logging.h" |
+ |
#include "base/callback.h" |
#include "base/file_util.h" |
#include "base/platform_file.h" |
@@ -560,23 +562,64 @@ void BrowsingDataRemover::ClearFileSystemsOnFILEThread() { |
DCHECK(waiting_for_clear_file_systems_); |
scoped_refptr<fileapi::FileSystemContext> |
fs_context(profile_->GetFileSystemContext()); |
+ |
+ // As long as the FileSystemContext is refcounted, we can use a raw pointer |
+ // here, and let the FileSystemContext delete the FileSystemFileUtil when |
+ // it's destroyed. |
+ fileapi::FileSystemFileUtil* file_util = fs_context->path_manager()-> |
+ sandbox_provider()->GetFileSystemFileUtil(); |
+ |
+ scoped_ptr<fileapi::FileSystemOperationContext> |
+ op_context(new fileapi::FileSystemOperationContext( |
+ fs_context.get(), file_util)); |
+ |
+ // We own the reference to the OriginEnumerator, so we wrap it in a scoped_ptr |
+ // to ensure that it's destroyed when we leave the FILE thread. |
scoped_ptr<fileapi::SandboxMountPointProvider::OriginEnumerator> |
- origin_enumerator(fs_context->path_manager()->sandbox_provider()-> |
+ origins(fs_context->path_manager()->sandbox_provider()-> |
CreateOriginEnumerator()); |
GURL origin; |
- while (!(origin = origin_enumerator->Next()).is_empty()) { |
+ while (!(origin = origins->Next()).is_empty()) { |
if (special_storage_policy_->IsStorageProtected(origin)) |
continue; |
if (delete_begin_ == base::Time()) { |
// If the user chooses to delete browsing data "since the beginning of |
// time" remove both temporary and persistent file systems entirely. |
- fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, |
- fileapi::kFileSystemTypeTemporary); |
- fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, |
- fileapi::kFileSystemTypePersistent); |
+ fs_context->DeleteDataForOriginOnFileThread(origin); |
+ } else { |
+ // Else, walk through the origin's temporary filesystem. If any file has |
+ // been modified in the timeframe, remove the entire filesystem. |
+ if (origins->HasFileSystemType(fileapi::kFileSystemTypeTemporary)) { |
+ op_context->set_src_origin_url(origin); |
+ op_context->set_src_type(fileapi::kFileSystemTypeTemporary); |
+ |
+ // TODO(mkwst): Replace the FileEnumerator with a check against the |
+ // quota system, once last_modified dates are available. |
+ scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> files( |
+ file_util->CreateFileEnumerator(op_context.get(), |
+ FilePath(FILE_PATH_LITERAL("/")))); |
+ |
+ FilePath current; |
+ bool was_modified = false; |
+ while (!(current = files->Next()).empty()) { |
+ base::PlatformFileInfo file_info; |
+ FilePath platform_file_path; |
+ base::PlatformFileError error_code; |
+ error_code = file_util->GetFileInfo(op_context.get(), current, |
+ &file_info, &platform_file_path); |
+ if (error_code == base::PLATFORM_FILE_OK && |
+ file_info.last_modified >= delete_begin_) { |
+ was_modified = true; |
+ break; |
+ } |
+ } |
+ if (was_modified) { |
+ fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, |
+ fileapi::kFileSystemTypeTemporary); |
+ } |
+ } |
} |
- // TODO(mkwst): Else? Decide what to do for time-based deletion: crbug/63700 |
} |
BrowserThread::PostTask( |