| OLD | NEW |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 void EmptyStatusCallback(fileapi::SyncStatusCode code) {} | 77 void EmptyStatusCallback(fileapi::SyncStatusCode code) {} |
| 78 | 78 |
| 79 void DidRemoveOrigin(const GURL& origin, fileapi::SyncStatusCode status) { | 79 void DidRemoveOrigin(const GURL& origin, fileapi::SyncStatusCode status) { |
| 80 // TODO(calvinlo): Disable syncing if status not ok (http://crbug.com/171611). | 80 // TODO(calvinlo): Disable syncing if status not ok (http://crbug.com/171611). |
| 81 DCHECK_EQ(fileapi::SYNC_STATUS_OK, status); | 81 DCHECK_EQ(fileapi::SYNC_STATUS_OK, status); |
| 82 LOG(WARNING) << "Remove origin failed for: " << origin.spec() | 82 LOG(WARNING) << "Remove origin failed for: " << origin.spec() |
| 83 << " status=" << status; | 83 << " status=" << status; |
| 84 } | 84 } |
| 85 | 85 |
| 86 fileapi::FileChange CreateFileChange(bool is_deleted) { | 86 FileChange CreateFileChange(bool is_deleted) { |
| 87 if (is_deleted) { | 87 if (is_deleted) { |
| 88 return fileapi::FileChange(fileapi::FileChange::FILE_CHANGE_DELETE, | 88 return FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN); |
| 89 fileapi::SYNC_FILE_TYPE_UNKNOWN); | |
| 90 } | 89 } |
| 91 return fileapi::FileChange(fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 90 return FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_FILE); |
| 92 fileapi::SYNC_FILE_TYPE_FILE); | |
| 93 } | 91 } |
| 94 | 92 |
| 95 } // namespace | 93 } // namespace |
| 96 | 94 |
| 97 const char DriveFileSyncService::kServiceName[] = "drive"; | 95 const char DriveFileSyncService::kServiceName[] = "drive"; |
| 98 | 96 |
| 99 class DriveFileSyncService::TaskToken { | 97 class DriveFileSyncService::TaskToken { |
| 100 public: | 98 public: |
| 101 explicit TaskToken(const base::WeakPtr<DriveFileSyncService>& sync_service) | 99 explicit TaskToken(const base::WeakPtr<DriveFileSyncService>& sync_service) |
| 102 : sync_service_(sync_service), | 100 : sync_service_(sync_service), |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (left.changestamp != right.changestamp) | 220 if (left.changestamp != right.changestamp) |
| 223 return left.changestamp < right.changestamp; | 221 return left.changestamp < right.changestamp; |
| 224 if (left.sync_type != right.sync_type) | 222 if (left.sync_type != right.sync_type) |
| 225 return left.sync_type < right.sync_type; | 223 return left.sync_type < right.sync_type; |
| 226 return fileapi::FileSystemURL::Comparator()(left.url, right.url); | 224 return fileapi::FileSystemURL::Comparator()(left.url, right.url); |
| 227 } | 225 } |
| 228 | 226 |
| 229 DriveFileSyncService::RemoteChange::RemoteChange() | 227 DriveFileSyncService::RemoteChange::RemoteChange() |
| 230 : changestamp(0), | 228 : changestamp(0), |
| 231 sync_type(REMOTE_SYNC_TYPE_INCREMENTAL), | 229 sync_type(REMOTE_SYNC_TYPE_INCREMENTAL), |
| 232 change(fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 230 change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_UNKNOWN) { |
| 233 fileapi::SYNC_FILE_TYPE_UNKNOWN) { | |
| 234 } | 231 } |
| 235 | 232 |
| 236 DriveFileSyncService::RemoteChange::RemoteChange( | 233 DriveFileSyncService::RemoteChange::RemoteChange( |
| 237 int64 changestamp, | 234 int64 changestamp, |
| 238 const std::string& resource_id, | 235 const std::string& resource_id, |
| 239 const std::string& md5_checksum, | 236 const std::string& md5_checksum, |
| 240 RemoteSyncType sync_type, | 237 RemoteSyncType sync_type, |
| 241 const fileapi::FileSystemURL& url, | 238 const fileapi::FileSystemURL& url, |
| 242 const fileapi::FileChange& change, | 239 const FileChange& change, |
| 243 PendingChangeQueue::iterator position_in_queue) | 240 PendingChangeQueue::iterator position_in_queue) |
| 244 : changestamp(changestamp), | 241 : changestamp(changestamp), |
| 245 resource_id(resource_id), | 242 resource_id(resource_id), |
| 246 md5_checksum(md5_checksum), | 243 md5_checksum(md5_checksum), |
| 247 sync_type(sync_type), | 244 sync_type(sync_type), |
| 248 url(url), | 245 url(url), |
| 249 change(change), | 246 change(change), |
| 250 position_in_queue(position_in_queue) { | 247 position_in_queue(position_in_queue) { |
| 251 } | 248 } |
| 252 | 249 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 Observer, service_observers_, | 508 Observer, service_observers_, |
| 512 OnRemoteServiceStateUpdated(GetCurrentState(), status_message)); | 509 OnRemoteServiceStateUpdated(GetCurrentState(), status_message)); |
| 513 | 510 |
| 514 if (GetCurrentState() == REMOTE_SERVICE_OK) { | 511 if (GetCurrentState() == REMOTE_SERVICE_OK) { |
| 515 UpdatePollingDelay(kMinimumPollingDelaySeconds); | 512 UpdatePollingDelay(kMinimumPollingDelaySeconds); |
| 516 SchedulePolling(); | 513 SchedulePolling(); |
| 517 } | 514 } |
| 518 } | 515 } |
| 519 | 516 |
| 520 void DriveFileSyncService::ApplyLocalChange( | 517 void DriveFileSyncService::ApplyLocalChange( |
| 521 const fileapi::FileChange& local_file_change, | 518 const FileChange& local_file_change, |
| 522 const base::FilePath& local_file_path, | 519 const base::FilePath& local_file_path, |
| 523 const fileapi::FileSystemURL& url, | 520 const fileapi::FileSystemURL& url, |
| 524 const fileapi::SyncStatusCallback& callback) { | 521 const fileapi::SyncStatusCallback& callback) { |
| 525 // TODO(nhiroki): support directory operations (http://crbug.com/161442). | 522 // TODO(nhiroki): support directory operations (http://crbug.com/161442). |
| 526 DCHECK(!local_file_change.IsDirectory()); | 523 DCHECK(!local_file_change.IsDirectory()); |
| 527 | 524 |
| 528 scoped_ptr<TaskToken> token(GetToken( | 525 scoped_ptr<TaskToken> token(GetToken( |
| 529 FROM_HERE, TASK_TYPE_DATABASE, "Apply local change")); | 526 FROM_HERE, TASK_TYPE_DATABASE, "Apply local change")); |
| 530 if (!token) { | 527 if (!token) { |
| 531 pending_tasks_.push_back(base::Bind( | 528 pending_tasks_.push_back(base::Bind( |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 const fileapi::SyncStatusCallback& callback, | 1062 const fileapi::SyncStatusCallback& callback, |
| 1066 fileapi::SyncStatusCode status) { | 1063 fileapi::SyncStatusCode status) { |
| 1067 NotifyTaskDone(status, token.Pass()); | 1064 NotifyTaskDone(status, token.Pass()); |
| 1068 callback.Run(status); | 1065 callback.Run(status); |
| 1069 } | 1066 } |
| 1070 | 1067 |
| 1071 void DriveFileSyncService::DidGetRemoteFileMetadata( | 1068 void DriveFileSyncService::DidGetRemoteFileMetadata( |
| 1072 const fileapi::SyncFileMetadataCallback& callback, | 1069 const fileapi::SyncFileMetadataCallback& callback, |
| 1073 google_apis::GDataErrorCode error, | 1070 google_apis::GDataErrorCode error, |
| 1074 scoped_ptr<google_apis::ResourceEntry> entry) { | 1071 scoped_ptr<google_apis::ResourceEntry> entry) { |
| 1075 fileapi::SyncFileType file_type = fileapi::SYNC_FILE_TYPE_UNKNOWN; | 1072 SyncFileType file_type = SYNC_FILE_TYPE_UNKNOWN; |
| 1076 if (entry->is_file()) | 1073 if (entry->is_file()) |
| 1077 file_type = fileapi::SYNC_FILE_TYPE_FILE; | 1074 file_type = SYNC_FILE_TYPE_FILE; |
| 1078 else if (entry->is_folder()) | 1075 else if (entry->is_folder()) |
| 1079 file_type = fileapi::SYNC_FILE_TYPE_DIRECTORY; | 1076 file_type = SYNC_FILE_TYPE_DIRECTORY; |
| 1080 callback.Run(GDataErrorCodeToSyncStatusCodeWrapper(error), | 1077 callback.Run(GDataErrorCodeToSyncStatusCodeWrapper(error), |
| 1081 fileapi::SyncFileMetadata(file_type, | 1078 fileapi::SyncFileMetadata(file_type, |
| 1082 entry->file_size(), | 1079 entry->file_size(), |
| 1083 entry->updated_time())); | 1080 entry->updated_time())); |
| 1084 } | 1081 } |
| 1085 | 1082 |
| 1086 DriveFileSyncService::LocalSyncOperationType | 1083 DriveFileSyncService::LocalSyncOperationType |
| 1087 DriveFileSyncService::ResolveLocalSyncOperationType( | 1084 DriveFileSyncService::ResolveLocalSyncOperationType( |
| 1088 const fileapi::FileChange& local_file_change, | 1085 const FileChange& local_file_change, |
| 1089 const fileapi::FileSystemURL& url) { | 1086 const fileapi::FileSystemURL& url) { |
| 1090 DriveMetadata metadata; | 1087 DriveMetadata metadata; |
| 1091 const bool has_metadata = | 1088 const bool has_metadata = |
| 1092 (metadata_store_->ReadEntry(url, &metadata) == fileapi::SYNC_STATUS_OK); | 1089 (metadata_store_->ReadEntry(url, &metadata) == fileapi::SYNC_STATUS_OK); |
| 1093 | 1090 |
| 1094 if (has_metadata && metadata.conflicted()) { | 1091 if (has_metadata && metadata.conflicted()) { |
| 1095 // The file has been marked as conflicted. | 1092 // The file has been marked as conflicted. |
| 1096 if (local_file_change.IsAddOrUpdate()) | 1093 if (local_file_change.IsAddOrUpdate()) |
| 1097 return LOCAL_SYNC_OPERATION_NONE; | 1094 return LOCAL_SYNC_OPERATION_NONE; |
| 1098 else if (local_file_change.IsDelete()) | 1095 else if (local_file_change.IsDelete()) |
| 1099 return LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE; | 1096 return LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE; |
| 1100 NOTREACHED(); | 1097 NOTREACHED(); |
| 1101 return LOCAL_SYNC_OPERATION_FAIL; | 1098 return LOCAL_SYNC_OPERATION_FAIL; |
| 1102 } | 1099 } |
| 1103 | 1100 |
| 1104 RemoteChange remote_change; | 1101 RemoteChange remote_change; |
| 1105 const bool has_remote_change = GetPendingChangeForFileSystemURL( | 1102 const bool has_remote_change = GetPendingChangeForFileSystemURL( |
| 1106 url, &remote_change); | 1103 url, &remote_change); |
| 1107 | 1104 |
| 1108 if (has_remote_change) { | 1105 if (has_remote_change) { |
| 1109 // Remote change for the file identified by |url| exists in the pending | 1106 // Remote change for the file identified by |url| exists in the pending |
| 1110 // change queue. | 1107 // change queue. |
| 1111 const fileapi::FileChange& remote_file_change = remote_change.change; | 1108 const FileChange& remote_file_change = remote_change.change; |
| 1112 | 1109 |
| 1113 // (RemoteChange) + (LocalChange) -> (Operation Type) | 1110 // (RemoteChange) + (LocalChange) -> (Operation Type) |
| 1114 // AddOrUpdate + AddOrUpdate -> CONFLICT | 1111 // AddOrUpdate + AddOrUpdate -> CONFLICT |
| 1115 // AddOrUpdate + Delete -> NONE | 1112 // AddOrUpdate + Delete -> NONE |
| 1116 // Delete + AddOrUpdate -> ADD | 1113 // Delete + AddOrUpdate -> ADD |
| 1117 // Delete + Delete -> NONE | 1114 // Delete + Delete -> NONE |
| 1118 | 1115 |
| 1119 if (remote_file_change.IsAddOrUpdate() && local_file_change.IsAddOrUpdate()) | 1116 if (remote_file_change.IsAddOrUpdate() && local_file_change.IsAddOrUpdate()) |
| 1120 return LOCAL_SYNC_OPERATION_CONFLICT; | 1117 return LOCAL_SYNC_OPERATION_CONFLICT; |
| 1121 else if (remote_file_change.IsDelete() && local_file_change.IsAddOrUpdate()) | 1118 else if (remote_file_change.IsDelete() && local_file_change.IsAddOrUpdate()) |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 FinalizeLocalSync(token.Pass(), callback, status); | 1305 FinalizeLocalSync(token.Pass(), callback, status); |
| 1309 return; | 1306 return; |
| 1310 } | 1307 } |
| 1311 } | 1308 } |
| 1312 } | 1309 } |
| 1313 | 1310 |
| 1314 void DriveFileSyncService::DidPrepareForProcessRemoteChange( | 1311 void DriveFileSyncService::DidPrepareForProcessRemoteChange( |
| 1315 scoped_ptr<ProcessRemoteChangeParam> param, | 1312 scoped_ptr<ProcessRemoteChangeParam> param, |
| 1316 fileapi::SyncStatusCode status, | 1313 fileapi::SyncStatusCode status, |
| 1317 const fileapi::SyncFileMetadata& metadata, | 1314 const fileapi::SyncFileMetadata& metadata, |
| 1318 const fileapi::FileChangeList& local_changes) { | 1315 const FileChangeList& local_changes) { |
| 1319 if (status != fileapi::SYNC_STATUS_OK) { | 1316 if (status != fileapi::SYNC_STATUS_OK) { |
| 1320 AbortRemoteSync(param.Pass(), status); | 1317 AbortRemoteSync(param.Pass(), status); |
| 1321 return; | 1318 return; |
| 1322 } | 1319 } |
| 1323 | 1320 |
| 1324 const fileapi::FileSystemURL& url = param->remote_change.url; | 1321 const fileapi::FileSystemURL& url = param->remote_change.url; |
| 1325 const DriveMetadata& drive_metadata = param->drive_metadata; | 1322 const DriveMetadata& drive_metadata = param->drive_metadata; |
| 1326 const fileapi::FileChange& remote_file_change = param->remote_change.change; | 1323 const FileChange& remote_file_change = param->remote_change.change; |
| 1327 | 1324 |
| 1328 status = metadata_store_->ReadEntry(param->remote_change.url, | 1325 status = metadata_store_->ReadEntry(param->remote_change.url, |
| 1329 ¶m->drive_metadata); | 1326 ¶m->drive_metadata); |
| 1330 DCHECK(status == fileapi::SYNC_STATUS_OK || | 1327 DCHECK(status == fileapi::SYNC_STATUS_OK || |
| 1331 status == fileapi::SYNC_DATABASE_ERROR_NOT_FOUND); | 1328 status == fileapi::SYNC_DATABASE_ERROR_NOT_FOUND); |
| 1332 | 1329 |
| 1333 bool missing_db_entry = (status != fileapi::SYNC_STATUS_OK); | 1330 bool missing_db_entry = (status != fileapi::SYNC_STATUS_OK); |
| 1334 if (missing_db_entry) { | 1331 if (missing_db_entry) { |
| 1335 param->drive_metadata.set_resource_id(param->remote_change.resource_id); | 1332 param->drive_metadata.set_resource_id(param->remote_change.resource_id); |
| 1336 param->drive_metadata.set_md5_checksum(std::string()); | 1333 param->drive_metadata.set_md5_checksum(std::string()); |
| 1337 param->drive_metadata.set_conflicted(false); | 1334 param->drive_metadata.set_conflicted(false); |
| 1338 param->drive_metadata.set_to_be_fetched(false); | 1335 param->drive_metadata.set_to_be_fetched(false); |
| 1339 } | 1336 } |
| 1340 bool missing_local_file = | 1337 bool missing_local_file = |
| 1341 (metadata.file_type == fileapi::SYNC_FILE_TYPE_UNKNOWN); | 1338 (metadata.file_type == SYNC_FILE_TYPE_UNKNOWN); |
| 1342 | 1339 |
| 1343 if (param->drive_metadata.conflicted()) { | 1340 if (param->drive_metadata.conflicted()) { |
| 1344 if (missing_local_file) { | 1341 if (missing_local_file) { |
| 1345 if (remote_file_change.IsAddOrUpdate()) { | 1342 if (remote_file_change.IsAddOrUpdate()) { |
| 1346 // Resolve conflict to remote change automatically. | 1343 // Resolve conflict to remote change automatically. |
| 1347 DVLOG(1) << "ProcessRemoteChange for " << url.DebugString() | 1344 DVLOG(1) << "ProcessRemoteChange for " << url.DebugString() |
| 1348 << (param->drive_metadata.conflicted() ? " (conflicted)" : " ") | 1345 << (param->drive_metadata.conflicted() ? " (conflicted)" : " ") |
| 1349 << (missing_local_file ? " (missing local file)" : " ") | 1346 << (missing_local_file ? " (missing local file)" : " ") |
| 1350 << " remote_change: " << remote_file_change.DebugString() | 1347 << " remote_change: " << remote_file_change.DebugString() |
| 1351 << " ==> operation: ResolveConflictToRemoteChange"; | 1348 << " ==> operation: ResolveConflictToRemoteChange"; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 << (missing_local_file ? " (missing local file)" : " ") | 1383 << (missing_local_file ? " (missing local file)" : " ") |
| 1387 << " remote_change: " << remote_file_change.DebugString() | 1384 << " remote_change: " << remote_file_change.DebugString() |
| 1388 << " ==> operation: ResolveConflictToLocalChange"; | 1385 << " ==> operation: ResolveConflictToLocalChange"; |
| 1389 | 1386 |
| 1390 param->sync_action = fileapi::SYNC_ACTION_NONE; | 1387 param->sync_action = fileapi::SYNC_ACTION_NONE; |
| 1391 param->clear_local_changes = false; | 1388 param->clear_local_changes = false; |
| 1392 | 1389 |
| 1393 RemoteChangeProcessor* processor = param->processor; | 1390 RemoteChangeProcessor* processor = param->processor; |
| 1394 processor->RecordFakeLocalChange( | 1391 processor->RecordFakeLocalChange( |
| 1395 url, | 1392 url, |
| 1396 fileapi::FileChange(fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 1393 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_FILE), |
| 1397 fileapi::SYNC_FILE_TYPE_FILE), | |
| 1398 base::Bind(&DriveFileSyncService::DidResolveConflictToLocalChange, | 1394 base::Bind(&DriveFileSyncService::DidResolveConflictToLocalChange, |
| 1399 AsWeakPtr(), base::Passed(¶m))); | 1395 AsWeakPtr(), base::Passed(¶m))); |
| 1400 return; | 1396 return; |
| 1401 } | 1397 } |
| 1402 | 1398 |
| 1403 DCHECK(!param->drive_metadata.conflicted()); | 1399 DCHECK(!param->drive_metadata.conflicted()); |
| 1404 if (remote_file_change.IsAddOrUpdate()) { | 1400 if (remote_file_change.IsAddOrUpdate()) { |
| 1405 if (local_changes.empty()) { | 1401 if (local_changes.empty()) { |
| 1406 if (missing_local_file) { | 1402 if (missing_local_file) { |
| 1407 param->sync_action = fileapi::SYNC_ACTION_ADDED; | 1403 param->sync_action = fileapi::SYNC_ACTION_ADDED; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 param->sync_action = fileapi::SYNC_ACTION_NONE; | 1439 param->sync_action = fileapi::SYNC_ACTION_NONE; |
| 1444 if (missing_db_entry) | 1440 if (missing_db_entry) |
| 1445 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK); | 1441 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK); |
| 1446 else | 1442 else |
| 1447 DeleteMetadataForRemoteSync(param.Pass()); | 1443 DeleteMetadataForRemoteSync(param.Pass()); |
| 1448 return; | 1444 return; |
| 1449 } | 1445 } |
| 1450 DCHECK(!missing_local_file); | 1446 DCHECK(!missing_local_file); |
| 1451 param->sync_action = fileapi::SYNC_ACTION_DELETED; | 1447 param->sync_action = fileapi::SYNC_ACTION_DELETED; |
| 1452 | 1448 |
| 1453 const fileapi::FileChange& file_change = remote_file_change; | 1449 const FileChange& file_change = remote_file_change; |
| 1454 param->processor->ApplyRemoteChange( | 1450 param->processor->ApplyRemoteChange( |
| 1455 file_change, base::FilePath(), url, | 1451 file_change, base::FilePath(), url, |
| 1456 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, AsWeakPtr(), | 1452 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, AsWeakPtr(), |
| 1457 base::Passed(¶m))); | 1453 base::Passed(¶m))); |
| 1458 return; | 1454 return; |
| 1459 } | 1455 } |
| 1460 | 1456 |
| 1461 DCHECK(!local_changes.empty()); | 1457 DCHECK(!local_changes.empty()); |
| 1462 if (local_changes.list().back().IsAddOrUpdate()) { | 1458 if (local_changes.list().back().IsAddOrUpdate()) { |
| 1463 param->sync_action = fileapi::SYNC_ACTION_NONE; | 1459 param->sync_action = fileapi::SYNC_ACTION_NONE; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 return; | 1531 return; |
| 1536 } | 1532 } |
| 1537 | 1533 |
| 1538 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error); | 1534 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error); |
| 1539 if (status != fileapi::SYNC_STATUS_OK) { | 1535 if (status != fileapi::SYNC_STATUS_OK) { |
| 1540 AbortRemoteSync(param.Pass(), status); | 1536 AbortRemoteSync(param.Pass(), status); |
| 1541 return; | 1537 return; |
| 1542 } | 1538 } |
| 1543 | 1539 |
| 1544 param->drive_metadata.set_md5_checksum(md5_checksum); | 1540 param->drive_metadata.set_md5_checksum(md5_checksum); |
| 1545 const fileapi::FileChange& change = param->remote_change.change; | 1541 const FileChange& change = param->remote_change.change; |
| 1546 const base::FilePath& temporary_file_path = param->temporary_file_path; | 1542 const base::FilePath& temporary_file_path = param->temporary_file_path; |
| 1547 const fileapi::FileSystemURL& url = param->remote_change.url; | 1543 const fileapi::FileSystemURL& url = param->remote_change.url; |
| 1548 param->processor->ApplyRemoteChange( | 1544 param->processor->ApplyRemoteChange( |
| 1549 change, temporary_file_path, url, | 1545 change, temporary_file_path, url, |
| 1550 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, | 1546 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, |
| 1551 AsWeakPtr(), base::Passed(¶m))); | 1547 AsWeakPtr(), base::Passed(¶m))); |
| 1552 } | 1548 } |
| 1553 | 1549 |
| 1554 void DriveFileSyncService::DidApplyRemoteChange( | 1550 void DriveFileSyncService::DidApplyRemoteChange( |
| 1555 scoped_ptr<ProcessRemoteChangeParam> param, | 1551 scoped_ptr<ProcessRemoteChangeParam> param, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1736 !local_file_md5.empty() && | 1732 !local_file_md5.empty() && |
| 1737 remote_file_md5 == local_file_md5) | 1733 remote_file_md5 == local_file_md5) |
| 1738 return false; | 1734 return false; |
| 1739 | 1735 |
| 1740 // Drop any change if the change has unknown resource id. | 1736 // Drop any change if the change has unknown resource id. |
| 1741 if (!remote_resource_id.empty() && | 1737 if (!remote_resource_id.empty() && |
| 1742 !local_resource_id.empty() && | 1738 !local_resource_id.empty() && |
| 1743 remote_resource_id != local_resource_id) | 1739 remote_resource_id != local_resource_id) |
| 1744 return false; | 1740 return false; |
| 1745 | 1741 |
| 1746 fileapi::FileChange file_change(CreateFileChange(is_deleted)); | 1742 FileChange file_change(CreateFileChange(is_deleted)); |
| 1747 | 1743 |
| 1748 // Do not return in this block. These changes should be done together. | 1744 // Do not return in this block. These changes should be done together. |
| 1749 { | 1745 { |
| 1750 if (overridden_queue_item != pending_changes_.end()) | 1746 if (overridden_queue_item != pending_changes_.end()) |
| 1751 pending_changes_.erase(overridden_queue_item); | 1747 pending_changes_.erase(overridden_queue_item); |
| 1752 | 1748 |
| 1753 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = | 1749 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = |
| 1754 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); | 1750 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); |
| 1755 DCHECK(inserted_to_queue.second); | 1751 DCHECK(inserted_to_queue.second); |
| 1756 | 1752 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 DCHECK_EQ(fileapi::SYNC_ACTION_NONE, action_taken); | 2015 DCHECK_EQ(fileapi::SYNC_ACTION_NONE, action_taken); |
| 2020 DCHECK_EQ(fileapi::SYNC_DIRECTION_NONE, direction); | 2016 DCHECK_EQ(fileapi::SYNC_DIRECTION_NONE, direction); |
| 2021 } | 2017 } |
| 2022 | 2018 |
| 2023 FOR_EACH_OBSERVER( | 2019 FOR_EACH_OBSERVER( |
| 2024 FileStatusObserver, file_status_observers_, | 2020 FileStatusObserver, file_status_observers_, |
| 2025 OnFileStatusChanged(url, sync_status, action_taken, direction)); | 2021 OnFileStatusChanged(url, sync_status, action_taken, direction)); |
| 2026 } | 2022 } |
| 2027 | 2023 |
| 2028 } // namespace sync_file_system | 2024 } // namespace sync_file_system |
| OLD | NEW |