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

Unified Diff: chrome/browser/sync_file_system/drive_file_sync_service.cc

Issue 14701004: [Sync FileSystem] Implement directory supported RESOLVE_TO_LOCAL to LocalSync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: handle error, DCHECK fix Created 7 years, 8 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/sync_file_system/drive_file_sync_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_file_sync_service.cc
diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc
index 9c3720ad870b4fd1ee965727f076b4e69c84f488..d56afc13bb39bdad60322af3523b718de3b818eb 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_service.cc
+++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc
@@ -1103,11 +1103,14 @@ void DriveFileSyncService::ApplyLocalChangeInternal(
HandleConflictForLocalSync(param.Pass());
return;
case LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL:
- // TODO(nhiroki): support directory operations (http://crbug.com/161442).
- NOTREACHED();
- FinalizeLocalSync(param->token.Pass(),
- param->callback,
- SYNC_STATUS_FAILED);
+ sync_client_->DeleteFile(
+ drive_metadata.resource_id(),
+ drive_metadata.md5_checksum(),
+ base::Bind(
+ &DriveFileSyncService::DidDeleteForResolveToLocalForLocalSync,
+ AsWeakPtr(),
+ origin_resource_id, local_file_path, url,
+ base::Passed(&param)));
return;
case LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE:
ResolveConflictToRemoteForLocalSync(param.Pass());
@@ -1128,6 +1131,40 @@ void DriveFileSyncService::ApplyLocalChangeInternal(
FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_FAILED);
}
+void DriveFileSyncService::DidDeleteForResolveToLocalForLocalSync(
+ const std::string& origin_resource_id,
+ const base::FilePath& local_file_path,
+ const fileapi::FileSystemURL& url,
+ scoped_ptr<ApplyLocalChangeParam> param,
+ google_apis::GDataErrorCode error) {
+ if (error != google_apis::HTTP_SUCCESS &&
+ error != google_apis::HTTP_NOT_FOUND) {
+ RemoveRemoteChange(param->url);
+ SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error);
+ FinalizeLocalSync(param->token.Pass(), param->callback, status);
+ return;
+ }
+
+ DCHECK_NE(SYNC_FILE_TYPE_UNKNOWN, param->local_metadata.file_type);
+ if (param->local_metadata.file_type == SYNC_FILE_TYPE_FILE) {
+ sync_client_->UploadNewFile(
+ origin_resource_id,
+ local_file_path,
+ PathToTitle(url.path()),
+ base::Bind(&DriveFileSyncService::DidUploadNewFileForLocalSync,
+ AsWeakPtr(), base::Passed(&param)));
+ return;
+ }
+
+ DCHECK(IsSyncDirectoryOperationEnabled());
+ DCHECK_EQ(SYNC_FILE_TYPE_DIRECTORY, param->local_metadata.file_type);
+ sync_client_->CreateDirectory(
+ origin_resource_id,
+ PathToTitle(url.path()),
+ base::Bind(&DriveFileSyncService::DidCreateDirectoryForLocalSync,
+ AsWeakPtr(), base::Passed(&param)));
+}
+
void DriveFileSyncService::DidApplyLocalChange(
scoped_ptr<ApplyLocalChangeParam> param,
const google_apis::GDataErrorCode error,
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698