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

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

Issue 98513003: drive: Support offline move/rename (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/entry_update_performer.cc
diff --git a/chrome/browser/chromeos/drive/sync/entry_update_performer.cc b/chrome/browser/chromeos/drive/sync/entry_update_performer.cc
index 566ff7cf0d15dd8b85d86e87309825b73f112939..ec25ef6131048fb4f8c0f071bab59a1dd28b654d 100644
--- a/chrome/browser/chromeos/drive/sync/entry_update_performer.cc
+++ b/chrome/browser/chromeos/drive/sync/entry_update_performer.cc
@@ -47,20 +47,20 @@ FileError PrepareUpdate(ResourceMetadata* metadata,
}
FileError FinishUpdate(ResourceMetadata* metadata,
- const std::string& local_id) {
- ResourceEntry entry;
- FileError error = metadata->GetResourceEntryById(local_id, &entry);
+ const std::string& local_id,
+ ResourceEntry* entry) {
+ FileError error = metadata->GetResourceEntryById(local_id, entry);
if (error != FILE_ERROR_OK)
return error;
- switch (entry.metadata_edit_state()) {
+ switch (entry->metadata_edit_state()) {
case ResourceEntry::CLEAN: // Nothing to do.
case ResourceEntry::DIRTY: // Entry was edited again during the update.
break;
case ResourceEntry::SYNCING:
- entry.set_metadata_edit_state(ResourceEntry::CLEAN);
- error = metadata->RefreshEntry(entry);
+ entry->set_metadata_edit_state(ResourceEntry::CLEAN);
+ error = metadata->RefreshEntry(*entry);
if (error != FILE_ERROR_OK)
return error;
break;
@@ -132,12 +132,16 @@ void EntryUpdatePerformer::UpdateEntryAfterPrepare(
return;
}
+ std::string parent_resource_id;
+ if (!util::IsSpecialResourceId(parent_entry->resource_id()))
+ parent_resource_id = parent_entry->resource_id();
+
base::Time last_modified =
base::Time::FromInternalValue(entry->file_info().last_modified());
base::Time last_accessed =
base::Time::FromInternalValue(entry->file_info().last_accessed());
scheduler_->UpdateResource(
- entry->resource_id(), parent_entry->resource_id(),
+ entry->resource_id(), parent_resource_id,
entry->title(), last_modified, last_accessed,
base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource,
weak_ptr_factory_.GetWeakPtr(), callback, entry->local_id()));
@@ -156,11 +160,31 @@ void EntryUpdatePerformer::UpdateEntryAfterUpdateResource(
return;
}
+ ResourceEntry* entry = new ResourceEntry;
base::PostTaskAndReplyWithResult(
blocking_task_runner_.get(),
FROM_HERE,
- base::Bind(&FinishUpdate, metadata_, local_id),
- callback);
+ base::Bind(&FinishUpdate, metadata_, local_id, entry),
+ base::Bind(&EntryUpdatePerformer::UpdateEntryAfterFinish,
+ weak_ptr_factory_.GetWeakPtr(), callback, base::Owned(entry)));
+}
+
+void EntryUpdatePerformer::UpdateEntryAfterFinish(
+ const FileOperationCallback& callback,
+ const ResourceEntry* entry,
+ FileError error) {
+ if (error != FILE_ERROR_OK) {
+ callback.Run(error);
+ return;
+ }
+
+ if (entry->metadata_edit_state() == ResourceEntry::DIRTY) {
+ // The entry was edited during the update. Update again.
+ UpdateEntry(entry->local_id(), callback);
+ return;
+ }
+
+ callback.Run(FILE_ERROR_OK);
}
} // namespace internal
« no previous file with comments | « chrome/browser/chromeos/drive/sync/entry_update_performer.h ('k') | chrome/browser/chromeos/drive/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698