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

Unified Diff: chrome/browser/chromeos/drive/sync/remove_performer.cc

Issue 148283003: drive: Make sync performers aware of locally created files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/drive/sync/remove_performer.cc
diff --git a/chrome/browser/chromeos/drive/sync/remove_performer.cc b/chrome/browser/chromeos/drive/sync/remove_performer.cc
index 8408ead531761feb512f04fd003eb2bb7d2985fa..0a0f44c60f5f6fbdab2c7b791a11c872219f59af 100644
--- a/chrome/browser/chromeos/drive/sync/remove_performer.cc
+++ b/chrome/browser/chromeos/drive/sync/remove_performer.cc
@@ -67,6 +67,17 @@ RemovePerformer::~RemovePerformer() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
+// Returns |entry| corresponding to |local_id|.
+// Adding to that, removes the entry when it does not exist on the server.
+FileError TryToRemoveLocally(ResourceMetadata* metadata,
+ const std::string& local_id,
+ ResourceEntry* entry) {
+ FileError error = metadata->GetResourceEntryById(local_id, entry);
+ if (error != FILE_ERROR_OK || !entry->resource_id().empty())
+ return error;
+ return metadata->RemoveEntry(local_id);
+}
+
void RemovePerformer::Remove(const std::string& local_id,
const ClientContext& context,
const FileOperationCallback& callback) {
@@ -77,10 +88,7 @@ void RemovePerformer::Remove(const std::string& local_id,
base::PostTaskAndReplyWithResult(
blocking_task_runner_.get(),
FROM_HERE,
- base::Bind(&ResourceMetadata::GetResourceEntryById,
- base::Unretained(metadata_),
- local_id,
- entry),
+ base::Bind(&TryToRemoveLocally, metadata_, local_id, entry),
base::Bind(&RemovePerformer::RemoveAfterGetResourceEntry,
weak_ptr_factory_.GetWeakPtr(),
context,
@@ -96,7 +104,7 @@ void RemovePerformer::RemoveAfterGetResourceEntry(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- if (error != FILE_ERROR_OK) {
+ if (error != FILE_ERROR_OK || entry->resource_id().empty()) {
callback.Run(error);
return;
}

Powered by Google App Engine
This is Rietveld 408576698