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

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: naming 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 DCHECK_NE(SYNC_FILE_TYPE_UNKNOWN, param->local_metadata.file_type);
nhiroki 2013/05/02 03:32:01 What happen if delete operation failed?
tzik 2013/05/02 03:52:56 Done. Hmm, I thought it's ignorable since any sti
1141 if (param->local_metadata.file_type == SYNC_FILE_TYPE_FILE) {
1142 sync_client_->UploadNewFile(
1143 origin_resource_id,
1144 local_file_path,
1145 PathToTitle(url.path()),
1146 base::Bind(&DriveFileSyncService::DidUploadNewFileForLocalSync,
1147 AsWeakPtr(), base::Passed(&param)));
1148 return;
1149 }
1150
1151 DCHECK(IsSyncDirectoryOperationEnabled());
1152 DCHECK_EQ(SYNC_FILE_TYPE_FILE, param->local_metadata.file_type);
nhiroki 2013/05/02 03:32:01 Probably you'd meant to put SYNC_FILE_TYPE_DIRECTO
tzik 2013/05/02 03:52:56 Yes, I meant. Thanks! Done.
1153 sync_client_->CreateDirectory(
1154 origin_resource_id,
1155 PathToTitle(url.path()),
1156 base::Bind(&DriveFileSyncService::DidCreateDirectoryForLocalSync,
1157 AsWeakPtr(), base::Passed(&param)));
1158 }
1159
1131 void DriveFileSyncService::DidApplyLocalChange( 1160 void DriveFileSyncService::DidApplyLocalChange(
1132 scoped_ptr<ApplyLocalChangeParam> param, 1161 scoped_ptr<ApplyLocalChangeParam> param,
1133 const google_apis::GDataErrorCode error, 1162 const google_apis::GDataErrorCode error,
1134 SyncStatusCode status) { 1163 SyncStatusCode status) {
1135 if (status == SYNC_STATUS_OK) { 1164 if (status == SYNC_STATUS_OK) {
1136 RemoveRemoteChange(param->url); 1165 RemoveRemoteChange(param->url);
1137 status = GDataErrorCodeToSyncStatusCodeWrapper(error); 1166 status = GDataErrorCodeToSyncStatusCodeWrapper(error);
1138 } 1167 }
1139 FinalizeLocalSync(param->token.Pass(), param->callback, status); 1168 FinalizeLocalSync(param->token.Pass(), param->callback, status);
1140 } 1169 }
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 pending_batch_sync_origins_.insert(origin); 2339 pending_batch_sync_origins_.insert(origin);
2311 } 2340 }
2312 callback.Run(status, resource_id); 2341 callback.Run(status, resource_id);
2313 } 2342 }
2314 2343
2315 std::string DriveFileSyncService::sync_root_resource_id() { 2344 std::string DriveFileSyncService::sync_root_resource_id() {
2316 return metadata_store_->sync_root_directory(); 2345 return metadata_store_->sync_root_directory();
2317 } 2346 }
2318 2347
2319 } // namespace sync_file_system 2348 } // 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