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

Unified Diff: chrome/browser/chromeos/gdata/gdata_cache.cc

Issue 10823125: Drive: add a method to clear all local cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review fix Created 8 years, 5 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
Index: chrome/browser/chromeos/gdata/gdata_cache.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_cache.cc b/chrome/browser/chromeos/gdata/gdata_cache.cc
index 7558f7c0bcdbb1539d64d31b40e63c4d67c9d58e..d52d4807e50c6ad949f31a664dfc0d1168f41a65 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache.cc
@@ -239,9 +239,9 @@ void CollectAnyFile(std::vector<std::string>* resource_ids,
// Runs callback with pointers dereferenced.
// Used to implement SetMountedStateOnUIThread.
-void RunSetMountedStateCallback(const SetMountedStateCallback& callback,
- GDataFileError* error,
- FilePath* cache_file_path) {
+void RunSetMountedStateCallback(const ChangeCacheStateCallback& callback,
satorux1 2012/08/01 21:56:31 Please rename this function. please also update th
yoshiki 2012/08/01 23:07:59 Done.
+ const GDataFileError* error,
+ const FilePath* cache_file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(error);
DCHECK(cache_file_path);
@@ -574,7 +574,7 @@ void GDataCache::UnpinOnUIThread(const std::string& resource_id,
void GDataCache::SetMountedStateOnUIThread(
const FilePath& file_path,
bool to_mount,
- const SetMountedStateCallback& callback) {
+ const ChangeCacheStateCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
GDataFileError* error =
@@ -683,6 +683,22 @@ void GDataCache::RemoveOnUIThread(const std::string& resource_id,
"" /* md5 */));
}
+void GDataCache::ClearAllOnUIThread(const ChangeCacheStateCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ GDataFileError* error = new GDataFileError(GDATA_FILE_OK);
+
+ blocking_task_runner_->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&GDataCache::ClearAll,
+ base::Unretained(this),
+ error),
+ base::Bind(&RunSetMountedStateCallback,
+ callback,
+ base::Owned(error),
+ &cache_root_path_));
+}
+
void GDataCache::RequestInitializeOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -1436,6 +1452,13 @@ void GDataCache::Remove(const std::string& resource_id,
*error = GDATA_FILE_OK;
}
+void GDataCache::ClearAll(GDataFileError* error) {
+ DCHECK(error);
+ file_util::Delete(cache_root_path_, true);
+ Initialize();
+ *error = GDATA_FILE_OK;
+}
+
void GDataCache::OnPinned(GDataFileError* error,
const std::string& resource_id,
const std::string& md5,

Powered by Google App Engine
This is Rietveld 408576698