Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_backend/remote_to_local_syncer.h " | 5 #include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h " |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 sync_root_deletion_(false), | 99 sync_root_deletion_(false), |
| 100 weak_ptr_factory_(this) { | 100 weak_ptr_factory_(this) { |
| 101 } | 101 } |
| 102 | 102 |
| 103 RemoteToLocalSyncer::~RemoteToLocalSyncer() { | 103 RemoteToLocalSyncer::~RemoteToLocalSyncer() { |
| 104 } | 104 } |
| 105 | 105 |
| 106 void RemoteToLocalSyncer::RunPreflight(scoped_ptr<SyncTaskToken> token) { | 106 void RemoteToLocalSyncer::RunPreflight(scoped_ptr<SyncTaskToken> token) { |
| 107 token->InitializeTaskLog("Remote -> Local"); | 107 token->InitializeTaskLog("Remote -> Local"); |
| 108 | 108 |
| 109 scoped_ptr<TaskBlocker> task_blocker(new TaskBlocker); | |
| 110 task_blocker->exclusive = true; | |
| 111 SyncTaskManager::UpdateTaskBlocker( | |
| 112 token.Pass(), task_blocker.Pass(), | |
| 113 base::Bind(&RemoteToLocalSyncer::RunExclusive, | |
| 114 weak_ptr_factory_.GetWeakPtr())); | |
| 115 } | |
| 116 | |
| 117 void RemoteToLocalSyncer::RunExclusive(scoped_ptr<SyncTaskToken> token) { | |
| 118 if (!drive_service() || !metadata_database() || !remote_change_processor()) { | 109 if (!drive_service() || !metadata_database() || !remote_change_processor()) { |
| 119 token->RecordLog("Context not ready."); | 110 token->RecordLog("Context not ready."); |
| 120 SyncTaskManager::NotifyTaskDone(token.Pass(), SYNC_STATUS_FAILED); | 111 SyncTaskManager::NotifyTaskDone(token.Pass(), SYNC_STATUS_FAILED); |
| 121 return; | 112 return; |
| 122 } | 113 } |
| 123 | 114 |
| 124 dirty_tracker_ = make_scoped_ptr(new FileTracker); | 115 dirty_tracker_ = make_scoped_ptr(new FileTracker); |
| 125 if (metadata_database()->GetDirtyTracker(dirty_tracker_.get())) { | 116 if (metadata_database()->GetDirtyTracker(dirty_tracker_.get())) { |
| 126 token->RecordLog(base::StringPrintf( | 117 token->RecordLog(base::StringPrintf( |
| 127 "Start: tracker_id=%" PRId64, dirty_tracker_->tracker_id())); | 118 "Start: tracker_id=%" PRId64, dirty_tracker_->tracker_id())); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 139 remote_metadata_ = GetFileMetadata( | 130 remote_metadata_ = GetFileMetadata( |
| 140 metadata_database(), dirty_tracker_->file_id()); | 131 metadata_database(), dirty_tracker_->file_id()); |
| 141 | 132 |
| 142 if (!remote_metadata_ || !remote_metadata_->has_details()) { | 133 if (!remote_metadata_ || !remote_metadata_->has_details()) { |
| 143 if (remote_metadata_ && !remote_metadata_->has_details()) { | 134 if (remote_metadata_ && !remote_metadata_->has_details()) { |
| 144 token->RecordLog( | 135 token->RecordLog( |
| 145 "Missing details of a remote file: " + remote_metadata_->file_id()); | 136 "Missing details of a remote file: " + remote_metadata_->file_id()); |
| 146 NOTREACHED(); | 137 NOTREACHED(); |
| 147 } | 138 } |
| 148 token->RecordLog("Missing remote metadata case."); | 139 token->RecordLog("Missing remote metadata case."); |
| 149 HandleMissingRemoteMetadata(token.Pass()); | 140 |
| 141 MoveToBackground( | |
| 142 token.Pass(), | |
| 143 base::Bind(&RemoteToLocalSyncer::HandleMissingRemoteMetadata, | |
| 144 weak_ptr_factory_.GetWeakPtr())); | |
| 150 return; | 145 return; |
| 151 } | 146 } |
| 152 | 147 |
| 153 DCHECK(remote_metadata_); | 148 DCHECK(remote_metadata_); |
| 154 DCHECK(remote_metadata_->has_details()); | 149 DCHECK(remote_metadata_->has_details()); |
| 155 const FileDetails& remote_details = remote_metadata_->details(); | 150 const FileDetails& remote_details = remote_metadata_->details(); |
| 156 | 151 |
| 157 if (!dirty_tracker_->active() || | 152 if (!dirty_tracker_->active() || |
| 158 HasDisabledAppRoot(metadata_database(), *dirty_tracker_)) { | 153 HasDisabledAppRoot(metadata_database(), *dirty_tracker_)) { |
| 159 // Handle inactive tracker in SyncCompleted. | 154 // Handle inactive tracker in SyncCompleted. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 176 | 171 |
| 177 DCHECK(dirty_tracker_->has_synced_details()); | 172 DCHECK(dirty_tracker_->has_synced_details()); |
| 178 const FileDetails& synced_details = dirty_tracker_->synced_details(); | 173 const FileDetails& synced_details = dirty_tracker_->synced_details(); |
| 179 | 174 |
| 180 if (dirty_tracker_->tracker_id() == | 175 if (dirty_tracker_->tracker_id() == |
| 181 metadata_database()->GetSyncRootTrackerID()) { | 176 metadata_database()->GetSyncRootTrackerID()) { |
| 182 if (remote_details.missing() || | 177 if (remote_details.missing() || |
| 183 synced_details.title() != remote_details.title() || | 178 synced_details.title() != remote_details.title() || |
| 184 remote_details.parent_folder_ids_size()) { | 179 remote_details.parent_folder_ids_size()) { |
| 185 token->RecordLog("Sync-root deletion."); | 180 token->RecordLog("Sync-root deletion."); |
| 186 HandleSyncRootDeletion(token.Pass()); | 181 sync_root_deletion_ = true; |
| 182 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | |
| 187 return; | 183 return; |
| 188 } | 184 } |
| 189 token->RecordLog("Trivial sync-root change."); | 185 token->RecordLog("Trivial sync-root change."); |
| 190 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | 186 SyncCompleted(token.Pass(), SYNC_STATUS_OK); |
| 191 return; | 187 return; |
| 192 } | 188 } |
| 193 | 189 |
| 194 DCHECK_NE(dirty_tracker_->tracker_id(), | 190 DCHECK_NE(dirty_tracker_->tracker_id(), |
| 195 metadata_database()->GetSyncRootTrackerID()); | 191 metadata_database()->GetSyncRootTrackerID()); |
| 196 | 192 |
| 193 if (!BuildFileSystemURL(metadata_database(), *dirty_tracker_, &url_)) { | |
| 194 NOTREACHED(); | |
| 195 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); | |
| 196 return; | |
| 197 } | |
| 198 | |
| 199 DCHECK(url_.is_valid()); | |
| 200 | |
| 197 if (remote_details.missing()) { | 201 if (remote_details.missing()) { |
| 198 if (!synced_details.missing()) { | 202 if (!synced_details.missing()) { |
| 199 token->RecordLog("Remote file deletion."); | 203 token->RecordLog("Remote file deletion."); |
| 200 HandleDeletion(token.Pass()); | 204 MoveToBackground(token.Pass(), |
| 205 base::Bind(&RemoteToLocalSyncer::HandleDeletion, | |
| 206 weak_ptr_factory_.GetWeakPtr())); | |
| 201 return; | 207 return; |
| 202 } | 208 } |
| 203 | 209 |
| 204 DCHECK(synced_details.missing()); | 210 DCHECK(synced_details.missing()); |
| 205 token->RecordLog("Found a stray missing tracker: " + | 211 token->RecordLog("Found a stray missing tracker: " + |
| 206 dirty_tracker_->file_id()); | 212 dirty_tracker_->file_id()); |
| 207 NOTREACHED(); | 213 NOTREACHED(); |
| 208 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | 214 SyncCompleted(token.Pass(), SYNC_STATUS_OK); |
| 209 return; | 215 return; |
| 210 } | 216 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 231 NOTREACHED(); | 237 NOTREACHED(); |
| 232 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); | 238 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); |
| 233 return; | 239 return; |
| 234 } | 240 } |
| 235 DCHECK(remote_details.file_kind() == FILE_KIND_FILE || | 241 DCHECK(remote_details.file_kind() == FILE_KIND_FILE || |
| 236 remote_details.file_kind() == FILE_KIND_FOLDER); | 242 remote_details.file_kind() == FILE_KIND_FOLDER); |
| 237 | 243 |
| 238 if (synced_details.title() != remote_details.title()) { | 244 if (synced_details.title() != remote_details.title()) { |
| 239 // Handle rename as deletion + addition. | 245 // Handle rename as deletion + addition. |
| 240 token->RecordLog("Detected file rename."); | 246 token->RecordLog("Detected file rename."); |
| 241 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, | 247 |
| 242 weak_ptr_factory_.GetWeakPtr(), | 248 MoveToBackground(token.Pass(), |
| 243 base::Passed(&token))); | 249 base::Bind(&RemoteToLocalSyncer::HandleFileMove, |
| 250 weak_ptr_factory_.GetWeakPtr())); | |
| 244 return; | 251 return; |
| 245 } | 252 } |
| 246 DCHECK_EQ(synced_details.title(), remote_details.title()); | 253 DCHECK_EQ(synced_details.title(), remote_details.title()); |
| 247 | 254 |
| 248 FileTracker parent_tracker; | 255 FileTracker parent_tracker; |
| 249 if (!metadata_database()->FindTrackerByTrackerID( | 256 if (!metadata_database()->FindTrackerByTrackerID( |
| 250 dirty_tracker_->parent_tracker_id(), &parent_tracker)) { | 257 dirty_tracker_->parent_tracker_id(), &parent_tracker)) { |
| 251 token->RecordLog("Missing parent tracker for a non sync-root tracker: " | 258 token->RecordLog("Missing parent tracker for a non sync-root tracker: " |
| 252 + dirty_tracker_->file_id()); | 259 + dirty_tracker_->file_id()); |
| 253 NOTREACHED(); | 260 NOTREACHED(); |
| 254 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); | 261 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); |
| 255 return; | 262 return; |
| 256 } | 263 } |
| 257 | 264 |
| 258 if (!HasFolderAsParent(remote_details, parent_tracker.file_id())) { | 265 if (!HasFolderAsParent(remote_details, parent_tracker.file_id())) { |
| 259 // Handle reorganize as deletion + addition. | 266 // Handle reorganize as deletion + addition. |
| 260 token->RecordLog("Detected file reorganize."); | 267 token->RecordLog("Detected file reorganize."); |
| 261 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, | 268 |
| 262 weak_ptr_factory_.GetWeakPtr(), | 269 MoveToBackground(token.Pass(), |
| 263 base::Passed(&token))); | 270 base::Bind(&RemoteToLocalSyncer::HandleFileMove, |
| 271 weak_ptr_factory_.GetWeakPtr())); | |
| 264 return; | 272 return; |
| 265 } | 273 } |
| 266 | 274 |
| 267 if (synced_details.file_kind() == FILE_KIND_FILE) { | 275 if (synced_details.file_kind() == FILE_KIND_FILE) { |
| 268 if (synced_details.md5() != remote_details.md5()) { | 276 if (synced_details.md5() != remote_details.md5()) { |
| 269 token->RecordLog("Detected file content update."); | 277 token->RecordLog("Detected file content update."); |
| 270 HandleContentUpdate(token.Pass()); | 278 MoveToBackground(token.Pass(), |
| 279 base::Bind(&RemoteToLocalSyncer::HandleContentUpdate, | |
| 280 weak_ptr_factory_.GetWeakPtr())); | |
| 271 return; | 281 return; |
| 272 } | 282 } |
| 273 } else { | 283 } else { |
| 274 DCHECK_EQ(FILE_KIND_FOLDER, synced_details.file_kind()); | 284 DCHECK_EQ(FILE_KIND_FOLDER, synced_details.file_kind()); |
| 275 if (synced_details.missing()) { | 285 if (synced_details.missing()) { |
| 276 token->RecordLog("Detected folder update."); | 286 token->RecordLog("Detected folder update."); |
| 277 HandleFolderUpdate(token.Pass()); | 287 MoveToBackground(token.Pass(), |
| 288 base::Bind(&RemoteToLocalSyncer::HandleFolderUpdate, | |
| 289 weak_ptr_factory_.GetWeakPtr())); | |
| 278 return; | 290 return; |
| 279 } | 291 } |
| 280 if (dirty_tracker_->needs_folder_listing()) { | 292 if (dirty_tracker_->needs_folder_listing()) { |
| 281 token->RecordLog("Needs listing folder."); | 293 token->RecordLog("Needs listing folder."); |
| 282 ListFolderContent(token.Pass()); | 294 MoveToBackground(token.Pass(), |
| 295 base::Bind(&RemoteToLocalSyncer::ListFolderContent, | |
| 296 weak_ptr_factory_.GetWeakPtr())); | |
| 283 return; | 297 return; |
| 284 } | 298 } |
| 285 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | 299 SyncCompleted(token.Pass(), SYNC_STATUS_OK); |
| 286 return; | 300 return; |
| 287 } | 301 } |
| 288 | 302 |
| 289 token->RecordLog("Trivial file change."); | 303 token->RecordLog("Trivial file change."); |
| 290 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | 304 SyncCompleted(token.Pass(), SYNC_STATUS_OK); |
| 291 } | 305 } |
| 292 | 306 |
| 307 void RemoteToLocalSyncer::MoveToBackground(scoped_ptr<SyncTaskToken> token, | |
| 308 const Continuation& continuation) { | |
| 309 DCHECK(dirty_tracker_); | |
| 310 | |
| 311 scoped_ptr<TaskBlocker> blocker(new TaskBlocker); | |
| 312 blocker->app_id = dirty_tracker_->app_id(); | |
| 313 if (url_.is_valid()) | |
| 314 blocker->paths.push_back(url_.path()); | |
| 315 blocker->file_ids.push_back(dirty_tracker_->file_id()); | |
| 316 blocker->tracker_ids.push_back(dirty_tracker_->tracker_id()); | |
| 317 | |
| 318 SyncTaskManager::UpdateTaskBlocker( | |
| 319 token.Pass(), blocker.Pass(), | |
| 320 base::Bind(&RemoteToLocalSyncer::ContinueAsBackgroundTask, | |
| 321 weak_ptr_factory_.GetWeakPtr(), continuation)); | |
| 322 } | |
| 323 | |
| 324 void RemoteToLocalSyncer::ContinueAsBackgroundTask( | |
| 325 const Continuation& continuation, | |
| 326 scoped_ptr<SyncTaskToken> token) { | |
| 327 DCHECK(dirty_tracker_); | |
| 328 | |
| 329 // The SyncTask runs as a background task beyond this point. | |
| 330 // Not that any task can run between MoveToBackground() and | |
| 331 // ContinueAsBackgroundTask(), so we need to make sure other tasks didn't | |
| 332 // affect to the current RemoteToLocalSyncer task. | |
| 333 // | |
| 334 // - For LocalToRemoteSyncer, it may update or delete any of FileTracker and | |
| 335 // FileMetadata. When it updates FileMetadata or FileDetais in FileTracker, | |
|
nhiroki
2014/09/16 08:42:27
s/FileDetais/FileDetails/
tzik
2014/09/24 06:01:49
Done.
| |
| 336 // it also updates |change_id|. So, ensure the target FileTracker and | |
| 337 // FileMetadata exist and their |change_id|s are not updated. | |
| 338 // - For ListChangesTask, it may update FileMetadata together with |change_id| | |
| 339 // and may delete FileTracker. | |
| 340 // - For UnininstallAppTask, it may delete FileMetadata and FileTracker. | |
|
nhiroki
2014/09/16 08:42:27
s/UnininstallAppTask/UninstallAppTask/
tzik
2014/09/24 06:01:49
Done.
| |
| 341 // Check if FileTracker still exists. | |
| 342 // - For other RemoteToLocalSyncer, it may delete the FileTracker of parent. | |
| 343 // Note that since RemoteToLocalSyncer demotes the target FileTracker first, | |
| 344 // any other RemoteToLocalSyncer does not run for current |dirty_tracker_|. | |
| 345 // - Others, SyncEngineInitializer and RegisterAppTask doesn't affect to | |
| 346 | |
| 347 FileTracker latest_dirty_tracker; | |
| 348 if (!metadata_database()->FindTrackerByTrackerID( | |
| 349 dirty_tracker_->tracker_id(), &latest_dirty_tracker) || | |
| 350 dirty_tracker_->active() != latest_dirty_tracker.active() || | |
| 351 !latest_dirty_tracker.dirty()) { | |
| 352 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | |
| 353 return; | |
| 354 } | |
| 355 | |
| 356 int64 current_change_id = kint64min; | |
| 357 int64 latest_change_id = kint64min; | |
| 358 if (dirty_tracker_->has_synced_details()) | |
| 359 current_change_id = dirty_tracker_->synced_details().change_id(); | |
| 360 if (latest_dirty_tracker.has_synced_details()) | |
| 361 latest_change_id = latest_dirty_tracker.synced_details().change_id(); | |
| 362 if (current_change_id != latest_change_id) { | |
| 363 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | |
| 364 return; | |
| 365 } | |
| 366 | |
| 367 FileMetadata latest_file_metadata; | |
| 368 if (metadata_database()->FindFileByFileID(dirty_tracker_->file_id(), | |
| 369 &latest_file_metadata)) { | |
| 370 if (!remote_metadata_) { | |
| 371 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | |
| 372 return; | |
| 373 } | |
| 374 | |
| 375 if (remote_metadata_->details().change_id() != | |
| 376 latest_file_metadata.details().change_id()) { | |
|
nhiroki
2014/09/16 08:42:27
nit: You may need a 4-space indent.
tzik
2014/09/24 06:01:49
Done.
I introduced local variable for them.
| |
| 377 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | |
| 378 return; | |
| 379 } | |
| 380 } else { | |
| 381 if (remote_metadata_) { | |
| 382 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); | |
| 383 return; | |
| 384 } | |
| 385 } | |
| 386 continuation.Run(token.Pass()); | |
| 387 } | |
| 388 | |
| 293 void RemoteToLocalSyncer::HandleMissingRemoteMetadata( | 389 void RemoteToLocalSyncer::HandleMissingRemoteMetadata( |
| 294 scoped_ptr<SyncTaskToken> token) { | 390 scoped_ptr<SyncTaskToken> token) { |
| 295 DCHECK(dirty_tracker_); | 391 DCHECK(dirty_tracker_); |
| 296 | 392 |
| 297 drive_service()->GetFileResource( | 393 drive_service()->GetFileResource( |
| 298 dirty_tracker_->file_id(), | 394 dirty_tracker_->file_id(), |
| 299 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, | 395 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, |
| 300 weak_ptr_factory_.GetWeakPtr(), | 396 weak_ptr_factory_.GetWeakPtr(), |
| 301 base::Passed(&token))); | 397 base::Passed(&token))); |
| 302 } | 398 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 return; | 533 return; |
| 438 } | 534 } |
| 439 | 535 |
| 440 DCHECK_EQ(SYNC_FILE_TYPE_FILE, local_metadata_->file_type); | 536 DCHECK_EQ(SYNC_FILE_TYPE_FILE, local_metadata_->file_type); |
| 441 sync_action_ = SYNC_ACTION_ADDED; | 537 sync_action_ = SYNC_ACTION_ADDED; |
| 442 // Got a remote folder for existing local file. | 538 // Got a remote folder for existing local file. |
| 443 // Our policy prioritize folders in this case. | 539 // Our policy prioritize folders in this case. |
| 444 CreateFolder(token.Pass()); | 540 CreateFolder(token.Pass()); |
| 445 } | 541 } |
| 446 | 542 |
| 447 void RemoteToLocalSyncer::HandleSyncRootDeletion( | |
| 448 scoped_ptr<SyncTaskToken> token) { | |
| 449 sync_root_deletion_ = true; | |
| 450 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | |
| 451 } | |
| 452 | |
| 453 void RemoteToLocalSyncer::HandleDeletion( | 543 void RemoteToLocalSyncer::HandleDeletion( |
| 454 scoped_ptr<SyncTaskToken> token) { | 544 scoped_ptr<SyncTaskToken> token) { |
| 455 DCHECK(dirty_tracker_); | 545 DCHECK(dirty_tracker_); |
| 456 DCHECK(dirty_tracker_->active()); | 546 DCHECK(dirty_tracker_->active()); |
| 457 DCHECK(!HasDisabledAppRoot(metadata_database(), *dirty_tracker_)); | 547 DCHECK(!HasDisabledAppRoot(metadata_database(), *dirty_tracker_)); |
| 458 DCHECK(dirty_tracker_->has_synced_details()); | 548 DCHECK(dirty_tracker_->has_synced_details()); |
| 459 DCHECK(!dirty_tracker_->synced_details().missing()); | 549 DCHECK(!dirty_tracker_->synced_details().missing()); |
| 460 | 550 |
| 461 DCHECK(remote_metadata_); | 551 DCHECK(remote_metadata_); |
| 462 DCHECK(remote_metadata_->has_details()); | 552 DCHECK(remote_metadata_->has_details()); |
| 463 DCHECK(remote_metadata_->details().missing()); | 553 DCHECK(remote_metadata_->details().missing()); |
| 464 | 554 |
| 465 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, | 555 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, |
| 466 weak_ptr_factory_.GetWeakPtr(), | 556 weak_ptr_factory_.GetWeakPtr(), |
| 467 base::Passed(&token))); | 557 base::Passed(&token))); |
| 468 } | 558 } |
| 469 | 559 |
| 560 void RemoteToLocalSyncer::HandleFileMove(scoped_ptr<SyncTaskToken> token) { | |
| 561 DCHECK(dirty_tracker_); | |
| 562 DCHECK(dirty_tracker_->active()); | |
| 563 DCHECK(!HasDisabledAppRoot(metadata_database(), *dirty_tracker_)); | |
| 564 DCHECK(dirty_tracker_->has_synced_details()); | |
| 565 | |
| 566 DCHECK(remote_metadata_); | |
| 567 DCHECK(remote_metadata_->has_details()); | |
| 568 DCHECK(!remote_metadata_->details().missing()); | |
| 569 | |
| 570 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, | |
| 571 weak_ptr_factory_.GetWeakPtr(), | |
| 572 base::Passed(&token))); | |
| 573 } | |
| 574 | |
| 470 void RemoteToLocalSyncer::DidPrepareForDeletion( | 575 void RemoteToLocalSyncer::DidPrepareForDeletion( |
| 471 scoped_ptr<SyncTaskToken> token, | 576 scoped_ptr<SyncTaskToken> token, |
| 472 SyncStatusCode status) { | 577 SyncStatusCode status) { |
| 473 if (status != SYNC_STATUS_OK) { | 578 if (status != SYNC_STATUS_OK) { |
| 474 SyncCompleted(token.Pass(), status); | 579 SyncCompleted(token.Pass(), status); |
| 475 return; | 580 return; |
| 476 } | 581 } |
| 477 | 582 |
| 478 DCHECK(url_.is_valid()); | 583 DCHECK(url_.is_valid()); |
| 479 DCHECK(local_metadata_); | 584 DCHECK(local_metadata_); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 url_, false /* clear_local_change */, | 737 url_, false /* clear_local_change */, |
| 633 base::Bind(SyncTaskManager::NotifyTaskDone, | 738 base::Bind(SyncTaskManager::NotifyTaskDone, |
| 634 base::Passed(&token), status)); | 739 base::Passed(&token), status)); |
| 635 return; | 740 return; |
| 636 } | 741 } |
| 637 | 742 |
| 638 SyncTaskManager::NotifyTaskDone(token.Pass(), status); | 743 SyncTaskManager::NotifyTaskDone(token.Pass(), status); |
| 639 } | 744 } |
| 640 | 745 |
| 641 void RemoteToLocalSyncer::Prepare(const SyncStatusCallback& callback) { | 746 void RemoteToLocalSyncer::Prepare(const SyncStatusCallback& callback) { |
| 642 bool should_success = BuildFileSystemURL( | |
| 643 metadata_database(), *dirty_tracker_, &url_); | |
| 644 DCHECK(should_success); | |
| 645 DCHECK(url_.is_valid()); | 747 DCHECK(url_.is_valid()); |
| 646 remote_change_processor()->PrepareForProcessRemoteChange( | 748 remote_change_processor()->PrepareForProcessRemoteChange( |
| 647 url_, | 749 url_, |
| 648 base::Bind(&RemoteToLocalSyncer::DidPrepare, | 750 base::Bind(&RemoteToLocalSyncer::DidPrepare, |
| 649 weak_ptr_factory_.GetWeakPtr(), | 751 weak_ptr_factory_.GetWeakPtr(), |
| 650 callback)); | 752 callback)); |
| 651 } | 753 } |
| 652 | 754 |
| 653 void RemoteToLocalSyncer::DidPrepare(const SyncStatusCallback& callback, | 755 void RemoteToLocalSyncer::DidPrepare(const SyncStatusCallback& callback, |
| 654 SyncStatusCode status, | 756 SyncStatusCode status, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 | 854 |
| 753 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( | 855 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( |
| 754 scoped_ptr<SyncTaskToken> token) { | 856 scoped_ptr<SyncTaskToken> token) { |
| 755 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, | 857 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, |
| 756 weak_ptr_factory_.GetWeakPtr(), | 858 weak_ptr_factory_.GetWeakPtr(), |
| 757 base::Passed(&token)); | 859 base::Passed(&token)); |
| 758 } | 860 } |
| 759 | 861 |
| 760 } // namespace drive_backend | 862 } // namespace drive_backend |
| 761 } // namespace sync_file_system | 863 } // namespace sync_file_system |
| OLD | NEW |