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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 // The file is already conflicted. 1096 // The file is already conflicted.
1097 HandleConflictForLocalSync(param.Pass()); 1097 HandleConflictForLocalSync(param.Pass());
1098 return; 1098 return;
1099 case LOCAL_SYNC_OPERATION_NONE: 1099 case LOCAL_SYNC_OPERATION_NONE:
1100 FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_OK); 1100 FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_OK);
1101 return; 1101 return;
1102 case LOCAL_SYNC_OPERATION_CONFLICT: 1102 case LOCAL_SYNC_OPERATION_CONFLICT:
1103 HandleConflictForLocalSync(param.Pass()); 1103 HandleConflictForLocalSync(param.Pass());
1104 return; 1104 return;
1105 case LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL: 1105 case LOCAL_SYNC_OPERATION_RESOLVE_TO_LOCAL:
1106 // TODO(nhiroki): support directory operations (http://crbug.com/161442). 1106 sync_client_->DeleteFile(
1107 NOTREACHED(); 1107 drive_metadata.resource_id(),
1108 FinalizeLocalSync(param->token.Pass(), 1108 drive_metadata.md5_checksum(),
1109 param->callback, 1109 base::Bind(
1110 SYNC_STATUS_FAILED); 1110 &DriveFileSyncService::DidDeleteForResolveToLocalForLocalSync,
1111 AsWeakPtr(),
1112 origin_resource_id, local_file_path, url,
1113 base::Passed(&param)));
1111 return; 1114 return;
1112 case LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE: 1115 case LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE:
1113 ResolveConflictToRemoteForLocalSync(param.Pass()); 1116 ResolveConflictToRemoteForLocalSync(param.Pass());
1114 return; 1117 return;
1115 case LOCAL_SYNC_OPERATION_DELETE_METADATA: 1118 case LOCAL_SYNC_OPERATION_DELETE_METADATA:
1116 metadata_store_->DeleteEntry( 1119 metadata_store_->DeleteEntry(
1117 url, 1120 url,
1118 base::Bind(&DriveFileSyncService::DidApplyLocalChange, 1121 base::Bind(&DriveFileSyncService::DidApplyLocalChange,
1119 AsWeakPtr(), base::Passed(&param), 1122 AsWeakPtr(), base::Passed(&param),
1120 google_apis::HTTP_SUCCESS)); 1123 google_apis::HTTP_SUCCESS));
1121 return; 1124 return;
1122 case LOCAL_SYNC_OPERATION_FAIL: { 1125 case LOCAL_SYNC_OPERATION_FAIL: {
1123 FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_FAILED); 1126 FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_FAILED);
1124 return; 1127 return;
1125 } 1128 }
1126 } 1129 }
1127 NOTREACHED(); 1130 NOTREACHED();
1128 FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_FAILED); 1131 FinalizeLocalSync(param->token.Pass(), callback, SYNC_STATUS_FAILED);
1129 } 1132 }
1130 1133
1134 void DriveFileSyncService::DidDeleteForResolveToLocalForLocalSync(
1135 const std::string& origin_resource_id,
1136 const base::FilePath& local_file_path,
1137 const fileapi::FileSystemURL& url,
1138 scoped_ptr<ApplyLocalChangeParam> param,
1139 google_apis::GDataErrorCode error) {
1140 if (error != google_apis::HTTP_SUCCESS &&
1141 error != google_apis::HTTP_NOT_FOUND) {
1142 RemoveRemoteChange(param->url);
1143 SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error);
1144 FinalizeLocalSync(param->token.Pass(), param->callback, status);
1145 return;
1146 }
1147
1148 DCHECK_NE(SYNC_FILE_TYPE_UNKNOWN, param->local_metadata.file_type);
1149 if (param->local_metadata.file_type == SYNC_FILE_TYPE_FILE) {
1150 sync_client_->UploadNewFile(
1151 origin_resource_id,
1152 local_file_path,
1153 PathToTitle(url.path()),
1154 base::Bind(&DriveFileSyncService::DidUploadNewFileForLocalSync,
1155 AsWeakPtr(), base::Passed(&param)));
1156 return;
1157 }
1158
1159 DCHECK(IsSyncDirectoryOperationEnabled());
1160 DCHECK_EQ(SYNC_FILE_TYPE_DIRECTORY, param->local_metadata.file_type);
1161 sync_client_->CreateDirectory(
1162 origin_resource_id,
1163 PathToTitle(url.path()),
1164 base::Bind(&DriveFileSyncService::DidCreateDirectoryForLocalSync,
1165 AsWeakPtr(), base::Passed(&param)));
1166 }
1167
1131 void DriveFileSyncService::DidApplyLocalChange( 1168 void DriveFileSyncService::DidApplyLocalChange(
1132 scoped_ptr<ApplyLocalChangeParam> param, 1169 scoped_ptr<ApplyLocalChangeParam> param,
1133 const google_apis::GDataErrorCode error, 1170 const google_apis::GDataErrorCode error,
1134 SyncStatusCode status) { 1171 SyncStatusCode status) {
1135 if (status == SYNC_STATUS_OK) { 1172 if (status == SYNC_STATUS_OK) {
1136 RemoveRemoteChange(param->url); 1173 RemoveRemoteChange(param->url);
1137 status = GDataErrorCodeToSyncStatusCodeWrapper(error); 1174 status = GDataErrorCodeToSyncStatusCodeWrapper(error);
1138 } 1175 }
1139 FinalizeLocalSync(param->token.Pass(), param->callback, status); 1176 FinalizeLocalSync(param->token.Pass(), param->callback, status);
1140 } 1177 }
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 pending_batch_sync_origins_.insert(origin); 2347 pending_batch_sync_origins_.insert(origin);
2311 } 2348 }
2312 callback.Run(status, resource_id); 2349 callback.Run(status, resource_id);
2313 } 2350 }
2314 2351
2315 std::string DriveFileSyncService::sync_root_resource_id() { 2352 std::string DriveFileSyncService::sync_root_resource_id() {
2316 return metadata_store_->sync_root_directory(); 2353 return metadata_store_->sync_root_directory();
2317 } 2354 }
2318 2355
2319 } // namespace sync_file_system 2356 } // namespace sync_file_system
OLDNEW
« 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