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

Unified Diff: chrome/browser/chromeos/drive/sync_client.cc

Issue 214363002: drive: Return cancel closure from FileSystem::GetFileContent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment Created 6 years, 9 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 | « chrome/browser/chromeos/drive/sync_client.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/sync_client.cc
diff --git a/chrome/browser/chromeos/drive/sync_client.cc b/chrome/browser/chromeos/drive/sync_client.cc
index 489769c5f5706040dcf90056fa21cff9d1f33d87..f76b3b21aec7cde4c1ad54aed29e56fb55ffbd33 100644
--- a/chrome/browser/chromeos/drive/sync_client.cc
+++ b/chrome/browser/chromeos/drive/sync_client.cc
@@ -127,6 +127,12 @@ void CheckExistingPinnedFiles(ResourceMetadata* metadata,
DCHECK(!it->HasError());
}
+// Runs the task and returns a dummy cancel closure.
+base::Closure RunTaskAndReturnDummyCancelClosure(const base::Closure& task) {
+ task.Run();
+ return base::Closure();
+}
+
} // namespace
SyncClient::SyncTask::SyncTask() : state(PENDING), should_run_again(false) {}
@@ -235,8 +241,7 @@ void SyncClient::AddFetchTaskInternal(const std::string& local_id,
base::Unretained(download_operation_.get()),
local_id,
ClientContext(BACKGROUND),
- base::Bind(&SyncClient::OnGetFileContentInitialized,
- weak_ptr_factory_.GetWeakPtr()),
+ GetFileContentInitializedCallback(),
google_apis::GetContentCallback(),
base::Bind(&SyncClient::OnFetchFileComplete,
weak_ptr_factory_.GetWeakPtr(),
@@ -249,13 +254,14 @@ void SyncClient::AddUpdateTaskInternal(const ClientContext& context,
const base::TimeDelta& delay) {
SyncTask task;
task.task = base::Bind(
- &EntryUpdatePerformer::UpdateEntry,
- base::Unretained(entry_update_performer_.get()),
- local_id,
- context,
- base::Bind(&SyncClient::OnUpdateComplete,
- weak_ptr_factory_.GetWeakPtr(),
- local_id));
+ &RunTaskAndReturnDummyCancelClosure,
+ base::Bind(&EntryUpdatePerformer::UpdateEntry,
+ base::Unretained(entry_update_performer_.get()),
+ local_id,
+ context,
+ base::Bind(&SyncClient::OnUpdateComplete,
+ weak_ptr_factory_.GetWeakPtr(),
+ local_id)));
AddTask(SyncTasks::key_type(UPDATE, local_id), task, delay);
}
@@ -296,7 +302,7 @@ void SyncClient::StartTask(const SyncTasks::key_type& key) {
switch (task->state) {
case PENDING:
task->state = RUNNING;
- task->task.Run();
+ task->cancel_closure = task->task.Run();
break;
case RUNNING: // Do nothing.
break;
@@ -330,23 +336,6 @@ void SyncClient::AddFetchTasks(const std::vector<std::string>* local_ids) {
AddFetchTask((*local_ids)[i]);
}
-void SyncClient::OnGetFileContentInitialized(
- FileError error,
- scoped_ptr<ResourceEntry> entry,
- const base::FilePath& local_cache_file_path,
- const base::Closure& cancel_download_closure) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- if (error != FILE_ERROR_OK)
- return;
-
- const SyncTasks::key_type key(FETCH, entry->local_id());
- SyncTasks::iterator it = tasks_.find(key);
- DCHECK(it != tasks_.end());
-
- it->second.cancel_closure = cancel_download_closure;
-}
-
bool SyncClient::OnTaskComplete(SyncType type, const std::string& local_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698