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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (left.changestamp != right.changestamp) | 210 if (left.changestamp != right.changestamp) |
213 return left.changestamp < right.changestamp; | 211 return left.changestamp < right.changestamp; |
214 if (left.sync_type != right.sync_type) | 212 if (left.sync_type != right.sync_type) |
215 return left.sync_type < right.sync_type; | 213 return left.sync_type < right.sync_type; |
216 return fileapi::FileSystemURL::Comparator()(left.url, right.url); | 214 return fileapi::FileSystemURL::Comparator()(left.url, right.url); |
217 } | 215 } |
218 | 216 |
219 DriveFileSyncService::RemoteChange::RemoteChange() | 217 DriveFileSyncService::RemoteChange::RemoteChange() |
220 : changestamp(0), | 218 : changestamp(0), |
221 sync_type(REMOTE_SYNC_TYPE_INCREMENTAL), | 219 sync_type(REMOTE_SYNC_TYPE_INCREMENTAL), |
222 change(fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 220 change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_UNKNOWN) { |
223 fileapi::SYNC_FILE_TYPE_UNKNOWN) { | |
224 } | 221 } |
225 | 222 |
226 DriveFileSyncService::RemoteChange::RemoteChange( | 223 DriveFileSyncService::RemoteChange::RemoteChange( |
227 int64 changestamp, | 224 int64 changestamp, |
228 const std::string& resource_id, | 225 const std::string& resource_id, |
229 const std::string& md5_checksum, | 226 const std::string& md5_checksum, |
230 RemoteSyncType sync_type, | 227 RemoteSyncType sync_type, |
231 const fileapi::FileSystemURL& url, | 228 const fileapi::FileSystemURL& url, |
232 const fileapi::FileChange& change, | 229 const FileChange& change, |
233 PendingChangeQueue::iterator position_in_queue) | 230 PendingChangeQueue::iterator position_in_queue) |
234 : changestamp(changestamp), | 231 : changestamp(changestamp), |
235 resource_id(resource_id), | 232 resource_id(resource_id), |
236 md5_checksum(md5_checksum), | 233 md5_checksum(md5_checksum), |
237 sync_type(sync_type), | 234 sync_type(sync_type), |
238 url(url), | 235 url(url), |
239 change(change), | 236 change(change), |
240 position_in_queue(position_in_queue) { | 237 position_in_queue(position_in_queue) { |
241 } | 238 } |
242 | 239 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 Observer, service_observers_, | 498 Observer, service_observers_, |
502 OnRemoteServiceStateUpdated(GetCurrentState(), status_message)); | 499 OnRemoteServiceStateUpdated(GetCurrentState(), status_message)); |
503 | 500 |
504 if (GetCurrentState() == REMOTE_SERVICE_OK) { | 501 if (GetCurrentState() == REMOTE_SERVICE_OK) { |
505 UpdatePollingDelay(kMinimumPollingDelaySeconds); | 502 UpdatePollingDelay(kMinimumPollingDelaySeconds); |
506 SchedulePolling(); | 503 SchedulePolling(); |
507 } | 504 } |
508 } | 505 } |
509 | 506 |
510 void DriveFileSyncService::ApplyLocalChange( | 507 void DriveFileSyncService::ApplyLocalChange( |
511 const fileapi::FileChange& local_file_change, | 508 const FileChange& local_file_change, |
512 const base::FilePath& local_file_path, | 509 const base::FilePath& local_file_path, |
513 const fileapi::FileSystemURL& url, | 510 const fileapi::FileSystemURL& url, |
514 const fileapi::SyncStatusCallback& callback) { | 511 const fileapi::SyncStatusCallback& callback) { |
515 // TODO(nhiroki): support directory operations (http://crbug.com/161442). | 512 // TODO(nhiroki): support directory operations (http://crbug.com/161442). |
516 DCHECK(!local_file_change.IsDirectory()); | 513 DCHECK(!local_file_change.IsDirectory()); |
517 | 514 |
518 scoped_ptr<TaskToken> token(GetToken( | 515 scoped_ptr<TaskToken> token(GetToken( |
519 FROM_HERE, TASK_TYPE_DATABASE, "Apply local change")); | 516 FROM_HERE, TASK_TYPE_DATABASE, "Apply local change")); |
520 if (!token) { | 517 if (!token) { |
521 pending_tasks_.push_back(base::Bind( | 518 pending_tasks_.push_back(base::Bind( |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 const fileapi::SyncStatusCallback& callback, | 1052 const fileapi::SyncStatusCallback& callback, |
1056 fileapi::SyncStatusCode status) { | 1053 fileapi::SyncStatusCode status) { |
1057 NotifyTaskDone(status, token.Pass()); | 1054 NotifyTaskDone(status, token.Pass()); |
1058 callback.Run(status); | 1055 callback.Run(status); |
1059 } | 1056 } |
1060 | 1057 |
1061 void DriveFileSyncService::DidGetRemoteFileMetadata( | 1058 void DriveFileSyncService::DidGetRemoteFileMetadata( |
1062 const fileapi::SyncFileMetadataCallback& callback, | 1059 const fileapi::SyncFileMetadataCallback& callback, |
1063 google_apis::GDataErrorCode error, | 1060 google_apis::GDataErrorCode error, |
1064 scoped_ptr<google_apis::ResourceEntry> entry) { | 1061 scoped_ptr<google_apis::ResourceEntry> entry) { |
1065 fileapi::SyncFileType file_type = fileapi::SYNC_FILE_TYPE_UNKNOWN; | 1062 SyncFileType file_type = SYNC_FILE_TYPE_UNKNOWN; |
1066 if (entry->is_file()) | 1063 if (entry->is_file()) |
1067 file_type = fileapi::SYNC_FILE_TYPE_FILE; | 1064 file_type = SYNC_FILE_TYPE_FILE; |
1068 else if (entry->is_folder()) | 1065 else if (entry->is_folder()) |
1069 file_type = fileapi::SYNC_FILE_TYPE_DIRECTORY; | 1066 file_type = SYNC_FILE_TYPE_DIRECTORY; |
1070 callback.Run(GDataErrorCodeToSyncStatusCodeWrapper(error), | 1067 callback.Run(GDataErrorCodeToSyncStatusCodeWrapper(error), |
1071 fileapi::SyncFileMetadata(file_type, | 1068 fileapi::SyncFileMetadata(file_type, |
1072 entry->file_size(), | 1069 entry->file_size(), |
1073 entry->updated_time())); | 1070 entry->updated_time())); |
1074 } | 1071 } |
1075 | 1072 |
1076 DriveFileSyncService::LocalSyncOperationType | 1073 DriveFileSyncService::LocalSyncOperationType |
1077 DriveFileSyncService::ResolveLocalSyncOperationType( | 1074 DriveFileSyncService::ResolveLocalSyncOperationType( |
1078 const fileapi::FileChange& local_file_change, | 1075 const FileChange& local_file_change, |
1079 const fileapi::FileSystemURL& url) { | 1076 const fileapi::FileSystemURL& url) { |
1080 DriveMetadata metadata; | 1077 DriveMetadata metadata; |
1081 const bool has_metadata = | 1078 const bool has_metadata = |
1082 (metadata_store_->ReadEntry(url, &metadata) == fileapi::SYNC_STATUS_OK); | 1079 (metadata_store_->ReadEntry(url, &metadata) == fileapi::SYNC_STATUS_OK); |
1083 | 1080 |
1084 if (has_metadata && metadata.conflicted()) { | 1081 if (has_metadata && metadata.conflicted()) { |
1085 // The file has been marked as conflicted. | 1082 // The file has been marked as conflicted. |
1086 if (local_file_change.IsAddOrUpdate()) | 1083 if (local_file_change.IsAddOrUpdate()) |
1087 return LOCAL_SYNC_OPERATION_NONE; | 1084 return LOCAL_SYNC_OPERATION_NONE; |
1088 else if (local_file_change.IsDelete()) | 1085 else if (local_file_change.IsDelete()) |
1089 return LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE; | 1086 return LOCAL_SYNC_OPERATION_RESOLVE_TO_REMOTE; |
1090 NOTREACHED(); | 1087 NOTREACHED(); |
1091 return LOCAL_SYNC_OPERATION_FAIL; | 1088 return LOCAL_SYNC_OPERATION_FAIL; |
1092 } | 1089 } |
1093 | 1090 |
1094 RemoteChange remote_change; | 1091 RemoteChange remote_change; |
1095 const bool has_remote_change = GetPendingChangeForFileSystemURL( | 1092 const bool has_remote_change = GetPendingChangeForFileSystemURL( |
1096 url, &remote_change); | 1093 url, &remote_change); |
1097 | 1094 |
1098 if (has_remote_change) { | 1095 if (has_remote_change) { |
1099 // Remote change for the file identified by |url| exists in the pending | 1096 // Remote change for the file identified by |url| exists in the pending |
1100 // change queue. | 1097 // change queue. |
1101 const fileapi::FileChange& remote_file_change = remote_change.change; | 1098 const FileChange& remote_file_change = remote_change.change; |
1102 | 1099 |
1103 // (RemoteChange) + (LocalChange) -> (Operation Type) | 1100 // (RemoteChange) + (LocalChange) -> (Operation Type) |
1104 // AddOrUpdate + AddOrUpdate -> CONFLICT | 1101 // AddOrUpdate + AddOrUpdate -> CONFLICT |
1105 // AddOrUpdate + Delete -> NONE | 1102 // AddOrUpdate + Delete -> NONE |
1106 // Delete + AddOrUpdate -> ADD | 1103 // Delete + AddOrUpdate -> ADD |
1107 // Delete + Delete -> NONE | 1104 // Delete + Delete -> NONE |
1108 | 1105 |
1109 if (remote_file_change.IsAddOrUpdate() && local_file_change.IsAddOrUpdate()) | 1106 if (remote_file_change.IsAddOrUpdate() && local_file_change.IsAddOrUpdate()) |
1110 return LOCAL_SYNC_OPERATION_CONFLICT; | 1107 return LOCAL_SYNC_OPERATION_CONFLICT; |
1111 else if (remote_file_change.IsDelete() && local_file_change.IsAddOrUpdate()) | 1108 else if (remote_file_change.IsDelete() && local_file_change.IsAddOrUpdate()) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 FinalizeLocalSync(token.Pass(), callback, status); | 1295 FinalizeLocalSync(token.Pass(), callback, status); |
1299 return; | 1296 return; |
1300 } | 1297 } |
1301 } | 1298 } |
1302 } | 1299 } |
1303 | 1300 |
1304 void DriveFileSyncService::DidPrepareForProcessRemoteChange( | 1301 void DriveFileSyncService::DidPrepareForProcessRemoteChange( |
1305 scoped_ptr<ProcessRemoteChangeParam> param, | 1302 scoped_ptr<ProcessRemoteChangeParam> param, |
1306 fileapi::SyncStatusCode status, | 1303 fileapi::SyncStatusCode status, |
1307 const fileapi::SyncFileMetadata& metadata, | 1304 const fileapi::SyncFileMetadata& metadata, |
1308 const fileapi::FileChangeList& local_changes) { | 1305 const FileChangeList& local_changes) { |
1309 if (status != fileapi::SYNC_STATUS_OK) { | 1306 if (status != fileapi::SYNC_STATUS_OK) { |
1310 AbortRemoteSync(param.Pass(), status); | 1307 AbortRemoteSync(param.Pass(), status); |
1311 return; | 1308 return; |
1312 } | 1309 } |
1313 | 1310 |
1314 const fileapi::FileSystemURL& url = param->remote_change.url; | 1311 const fileapi::FileSystemURL& url = param->remote_change.url; |
1315 const DriveMetadata& drive_metadata = param->drive_metadata; | 1312 const DriveMetadata& drive_metadata = param->drive_metadata; |
1316 const fileapi::FileChange& remote_file_change = param->remote_change.change; | 1313 const FileChange& remote_file_change = param->remote_change.change; |
1317 | 1314 |
1318 status = metadata_store_->ReadEntry(param->remote_change.url, | 1315 status = metadata_store_->ReadEntry(param->remote_change.url, |
1319 ¶m->drive_metadata); | 1316 ¶m->drive_metadata); |
1320 DCHECK(status == fileapi::SYNC_STATUS_OK || | 1317 DCHECK(status == fileapi::SYNC_STATUS_OK || |
1321 status == fileapi::SYNC_DATABASE_ERROR_NOT_FOUND); | 1318 status == fileapi::SYNC_DATABASE_ERROR_NOT_FOUND); |
1322 | 1319 |
1323 bool missing_db_entry = (status != fileapi::SYNC_STATUS_OK); | 1320 bool missing_db_entry = (status != fileapi::SYNC_STATUS_OK); |
1324 if (missing_db_entry) { | 1321 if (missing_db_entry) { |
1325 param->drive_metadata.set_resource_id(param->remote_change.resource_id); | 1322 param->drive_metadata.set_resource_id(param->remote_change.resource_id); |
1326 param->drive_metadata.set_md5_checksum(std::string()); | 1323 param->drive_metadata.set_md5_checksum(std::string()); |
1327 param->drive_metadata.set_conflicted(false); | 1324 param->drive_metadata.set_conflicted(false); |
1328 param->drive_metadata.set_to_be_fetched(false); | 1325 param->drive_metadata.set_to_be_fetched(false); |
1329 } | 1326 } |
1330 bool missing_local_file = | 1327 bool missing_local_file = |
1331 (metadata.file_type == fileapi::SYNC_FILE_TYPE_UNKNOWN); | 1328 (metadata.file_type == SYNC_FILE_TYPE_UNKNOWN); |
1332 | 1329 |
1333 if (param->drive_metadata.conflicted()) { | 1330 if (param->drive_metadata.conflicted()) { |
1334 if (missing_local_file) { | 1331 if (missing_local_file) { |
1335 if (remote_file_change.IsAddOrUpdate()) { | 1332 if (remote_file_change.IsAddOrUpdate()) { |
1336 // Resolve conflict to remote change automatically. | 1333 // Resolve conflict to remote change automatically. |
1337 DVLOG(1) << "ProcessRemoteChange for " << url.DebugString() | 1334 DVLOG(1) << "ProcessRemoteChange for " << url.DebugString() |
1338 << (param->drive_metadata.conflicted() ? " (conflicted)" : " ") | 1335 << (param->drive_metadata.conflicted() ? " (conflicted)" : " ") |
1339 << (missing_local_file ? " (missing local file)" : " ") | 1336 << (missing_local_file ? " (missing local file)" : " ") |
1340 << " remote_change: " << remote_file_change.DebugString() | 1337 << " remote_change: " << remote_file_change.DebugString() |
1341 << " ==> operation: ResolveConflictToRemoteChange"; | 1338 << " ==> operation: ResolveConflictToRemoteChange"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 << (missing_local_file ? " (missing local file)" : " ") | 1373 << (missing_local_file ? " (missing local file)" : " ") |
1377 << " remote_change: " << remote_file_change.DebugString() | 1374 << " remote_change: " << remote_file_change.DebugString() |
1378 << " ==> operation: ResolveConflictToLocalChange"; | 1375 << " ==> operation: ResolveConflictToLocalChange"; |
1379 | 1376 |
1380 param->sync_action = SYNC_ACTION_NONE; | 1377 param->sync_action = SYNC_ACTION_NONE; |
1381 param->clear_local_changes = false; | 1378 param->clear_local_changes = false; |
1382 | 1379 |
1383 RemoteChangeProcessor* processor = param->processor; | 1380 RemoteChangeProcessor* processor = param->processor; |
1384 processor->RecordFakeLocalChange( | 1381 processor->RecordFakeLocalChange( |
1385 url, | 1382 url, |
1386 fileapi::FileChange(fileapi::FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 1383 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_FILE), |
1387 fileapi::SYNC_FILE_TYPE_FILE), | |
1388 base::Bind(&DriveFileSyncService::DidResolveConflictToLocalChange, | 1384 base::Bind(&DriveFileSyncService::DidResolveConflictToLocalChange, |
1389 AsWeakPtr(), base::Passed(¶m))); | 1385 AsWeakPtr(), base::Passed(¶m))); |
1390 return; | 1386 return; |
1391 } | 1387 } |
1392 | 1388 |
1393 DCHECK(!param->drive_metadata.conflicted()); | 1389 DCHECK(!param->drive_metadata.conflicted()); |
1394 if (remote_file_change.IsAddOrUpdate()) { | 1390 if (remote_file_change.IsAddOrUpdate()) { |
1395 if (local_changes.empty()) { | 1391 if (local_changes.empty()) { |
1396 if (missing_local_file) { | 1392 if (missing_local_file) { |
1397 param->sync_action = SYNC_ACTION_ADDED; | 1393 param->sync_action = SYNC_ACTION_ADDED; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 param->sync_action = SYNC_ACTION_NONE; | 1429 param->sync_action = SYNC_ACTION_NONE; |
1434 if (missing_db_entry) | 1430 if (missing_db_entry) |
1435 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK); | 1431 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK); |
1436 else | 1432 else |
1437 DeleteMetadataForRemoteSync(param.Pass()); | 1433 DeleteMetadataForRemoteSync(param.Pass()); |
1438 return; | 1434 return; |
1439 } | 1435 } |
1440 DCHECK(!missing_local_file); | 1436 DCHECK(!missing_local_file); |
1441 param->sync_action = SYNC_ACTION_DELETED; | 1437 param->sync_action = SYNC_ACTION_DELETED; |
1442 | 1438 |
1443 const fileapi::FileChange& file_change = remote_file_change; | 1439 const FileChange& file_change = remote_file_change; |
1444 param->processor->ApplyRemoteChange( | 1440 param->processor->ApplyRemoteChange( |
1445 file_change, base::FilePath(), url, | 1441 file_change, base::FilePath(), url, |
1446 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, AsWeakPtr(), | 1442 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, AsWeakPtr(), |
1447 base::Passed(¶m))); | 1443 base::Passed(¶m))); |
1448 return; | 1444 return; |
1449 } | 1445 } |
1450 | 1446 |
1451 DCHECK(!local_changes.empty()); | 1447 DCHECK(!local_changes.empty()); |
1452 if (local_changes.list().back().IsAddOrUpdate()) { | 1448 if (local_changes.list().back().IsAddOrUpdate()) { |
1453 param->sync_action = SYNC_ACTION_NONE; | 1449 param->sync_action = SYNC_ACTION_NONE; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 return; | 1521 return; |
1526 } | 1522 } |
1527 | 1523 |
1528 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error); | 1524 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCodeWrapper(error); |
1529 if (status != fileapi::SYNC_STATUS_OK) { | 1525 if (status != fileapi::SYNC_STATUS_OK) { |
1530 AbortRemoteSync(param.Pass(), status); | 1526 AbortRemoteSync(param.Pass(), status); |
1531 return; | 1527 return; |
1532 } | 1528 } |
1533 | 1529 |
1534 param->drive_metadata.set_md5_checksum(md5_checksum); | 1530 param->drive_metadata.set_md5_checksum(md5_checksum); |
1535 const fileapi::FileChange& change = param->remote_change.change; | 1531 const FileChange& change = param->remote_change.change; |
1536 const base::FilePath& temporary_file_path = param->temporary_file_path; | 1532 const base::FilePath& temporary_file_path = param->temporary_file_path; |
1537 const fileapi::FileSystemURL& url = param->remote_change.url; | 1533 const fileapi::FileSystemURL& url = param->remote_change.url; |
1538 param->processor->ApplyRemoteChange( | 1534 param->processor->ApplyRemoteChange( |
1539 change, temporary_file_path, url, | 1535 change, temporary_file_path, url, |
1540 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, | 1536 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, |
1541 AsWeakPtr(), base::Passed(¶m))); | 1537 AsWeakPtr(), base::Passed(¶m))); |
1542 } | 1538 } |
1543 | 1539 |
1544 void DriveFileSyncService::DidApplyRemoteChange( | 1540 void DriveFileSyncService::DidApplyRemoteChange( |
1545 scoped_ptr<ProcessRemoteChangeParam> param, | 1541 scoped_ptr<ProcessRemoteChangeParam> param, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 !local_file_md5.empty() && | 1722 !local_file_md5.empty() && |
1727 remote_file_md5 == local_file_md5) | 1723 remote_file_md5 == local_file_md5) |
1728 return false; | 1724 return false; |
1729 | 1725 |
1730 // Drop any change if the change has unknown resource id. | 1726 // Drop any change if the change has unknown resource id. |
1731 if (!remote_resource_id.empty() && | 1727 if (!remote_resource_id.empty() && |
1732 !local_resource_id.empty() && | 1728 !local_resource_id.empty() && |
1733 remote_resource_id != local_resource_id) | 1729 remote_resource_id != local_resource_id) |
1734 return false; | 1730 return false; |
1735 | 1731 |
1736 fileapi::FileChange file_change(CreateFileChange(is_deleted)); | 1732 FileChange file_change(CreateFileChange(is_deleted)); |
1737 | 1733 |
1738 // Do not return in this block. These changes should be done together. | 1734 // Do not return in this block. These changes should be done together. |
1739 { | 1735 { |
1740 if (overridden_queue_item != pending_changes_.end()) | 1736 if (overridden_queue_item != pending_changes_.end()) |
1741 pending_changes_.erase(overridden_queue_item); | 1737 pending_changes_.erase(overridden_queue_item); |
1742 | 1738 |
1743 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = | 1739 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = |
1744 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); | 1740 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); |
1745 DCHECK(inserted_to_queue.second); | 1741 DCHECK(inserted_to_queue.second); |
1746 | 1742 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 DCHECK_EQ(SYNC_ACTION_NONE, action_taken); | 2015 DCHECK_EQ(SYNC_ACTION_NONE, action_taken); |
2020 DCHECK_EQ(SYNC_DIRECTION_NONE, direction); | 2016 DCHECK_EQ(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 |