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 FileDetails in FileTracker, |
| 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 UninstallAppTask, it may delete FileMetadata and FileTracker. |
| 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 int64 change_id = remote_metadata_->details().change_id(); |
| 376 int64 latest_change_id = latest_file_metadata.details().change_id(); |
| 377 if (change_id != latest_change_id) { |
| 378 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 379 return; |
| 380 } |
| 381 } else { |
| 382 if (remote_metadata_) { |
| 383 SyncCompleted(token.Pass(), SYNC_STATUS_RETRY); |
| 384 return; |
| 385 } |
| 386 } |
| 387 continuation.Run(token.Pass()); |
| 388 } |
| 389 |
293 void RemoteToLocalSyncer::HandleMissingRemoteMetadata( | 390 void RemoteToLocalSyncer::HandleMissingRemoteMetadata( |
294 scoped_ptr<SyncTaskToken> token) { | 391 scoped_ptr<SyncTaskToken> token) { |
295 DCHECK(dirty_tracker_); | 392 DCHECK(dirty_tracker_); |
296 | 393 |
297 drive_service()->GetFileResource( | 394 drive_service()->GetFileResource( |
298 dirty_tracker_->file_id(), | 395 dirty_tracker_->file_id(), |
299 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, | 396 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, |
300 weak_ptr_factory_.GetWeakPtr(), | 397 weak_ptr_factory_.GetWeakPtr(), |
301 base::Passed(&token))); | 398 base::Passed(&token))); |
302 } | 399 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 return; | 534 return; |
438 } | 535 } |
439 | 536 |
440 DCHECK_EQ(SYNC_FILE_TYPE_FILE, local_metadata_->file_type); | 537 DCHECK_EQ(SYNC_FILE_TYPE_FILE, local_metadata_->file_type); |
441 sync_action_ = SYNC_ACTION_ADDED; | 538 sync_action_ = SYNC_ACTION_ADDED; |
442 // Got a remote folder for existing local file. | 539 // Got a remote folder for existing local file. |
443 // Our policy prioritize folders in this case. | 540 // Our policy prioritize folders in this case. |
444 CreateFolder(token.Pass()); | 541 CreateFolder(token.Pass()); |
445 } | 542 } |
446 | 543 |
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( | 544 void RemoteToLocalSyncer::HandleDeletion( |
454 scoped_ptr<SyncTaskToken> token) { | 545 scoped_ptr<SyncTaskToken> token) { |
455 DCHECK(dirty_tracker_); | 546 DCHECK(dirty_tracker_); |
456 DCHECK(dirty_tracker_->active()); | 547 DCHECK(dirty_tracker_->active()); |
457 DCHECK(!HasDisabledAppRoot(metadata_database(), *dirty_tracker_)); | 548 DCHECK(!HasDisabledAppRoot(metadata_database(), *dirty_tracker_)); |
458 DCHECK(dirty_tracker_->has_synced_details()); | 549 DCHECK(dirty_tracker_->has_synced_details()); |
459 DCHECK(!dirty_tracker_->synced_details().missing()); | 550 DCHECK(!dirty_tracker_->synced_details().missing()); |
460 | 551 |
461 DCHECK(remote_metadata_); | 552 DCHECK(remote_metadata_); |
462 DCHECK(remote_metadata_->has_details()); | 553 DCHECK(remote_metadata_->has_details()); |
463 DCHECK(remote_metadata_->details().missing()); | 554 DCHECK(remote_metadata_->details().missing()); |
464 | 555 |
465 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, | 556 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, |
466 weak_ptr_factory_.GetWeakPtr(), | 557 weak_ptr_factory_.GetWeakPtr(), |
467 base::Passed(&token))); | 558 base::Passed(&token))); |
468 } | 559 } |
469 | 560 |
| 561 void RemoteToLocalSyncer::HandleFileMove(scoped_ptr<SyncTaskToken> token) { |
| 562 DCHECK(dirty_tracker_); |
| 563 DCHECK(dirty_tracker_->active()); |
| 564 DCHECK(!HasDisabledAppRoot(metadata_database(), *dirty_tracker_)); |
| 565 DCHECK(dirty_tracker_->has_synced_details()); |
| 566 |
| 567 DCHECK(remote_metadata_); |
| 568 DCHECK(remote_metadata_->has_details()); |
| 569 DCHECK(!remote_metadata_->details().missing()); |
| 570 |
| 571 Prepare(base::Bind(&RemoteToLocalSyncer::DidPrepareForDeletion, |
| 572 weak_ptr_factory_.GetWeakPtr(), |
| 573 base::Passed(&token))); |
| 574 } |
| 575 |
470 void RemoteToLocalSyncer::DidPrepareForDeletion( | 576 void RemoteToLocalSyncer::DidPrepareForDeletion( |
471 scoped_ptr<SyncTaskToken> token, | 577 scoped_ptr<SyncTaskToken> token, |
472 SyncStatusCode status) { | 578 SyncStatusCode status) { |
473 if (status != SYNC_STATUS_OK) { | 579 if (status != SYNC_STATUS_OK) { |
474 SyncCompleted(token.Pass(), status); | 580 SyncCompleted(token.Pass(), status); |
475 return; | 581 return; |
476 } | 582 } |
477 | 583 |
478 DCHECK(url_.is_valid()); | 584 DCHECK(url_.is_valid()); |
479 DCHECK(local_metadata_); | 585 DCHECK(local_metadata_); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 url_, false /* clear_local_change */, | 738 url_, false /* clear_local_change */, |
633 base::Bind(SyncTaskManager::NotifyTaskDone, | 739 base::Bind(SyncTaskManager::NotifyTaskDone, |
634 base::Passed(&token), status)); | 740 base::Passed(&token), status)); |
635 return; | 741 return; |
636 } | 742 } |
637 | 743 |
638 SyncTaskManager::NotifyTaskDone(token.Pass(), status); | 744 SyncTaskManager::NotifyTaskDone(token.Pass(), status); |
639 } | 745 } |
640 | 746 |
641 void RemoteToLocalSyncer::Prepare(const SyncStatusCallback& callback) { | 747 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()); | 748 DCHECK(url_.is_valid()); |
646 remote_change_processor()->PrepareForProcessRemoteChange( | 749 remote_change_processor()->PrepareForProcessRemoteChange( |
647 url_, | 750 url_, |
648 base::Bind(&RemoteToLocalSyncer::DidPrepare, | 751 base::Bind(&RemoteToLocalSyncer::DidPrepare, |
649 weak_ptr_factory_.GetWeakPtr(), | 752 weak_ptr_factory_.GetWeakPtr(), |
650 callback)); | 753 callback)); |
651 } | 754 } |
652 | 755 |
653 void RemoteToLocalSyncer::DidPrepare(const SyncStatusCallback& callback, | 756 void RemoteToLocalSyncer::DidPrepare(const SyncStatusCallback& callback, |
654 SyncStatusCode status, | 757 SyncStatusCode status, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 855 |
753 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( | 856 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( |
754 scoped_ptr<SyncTaskToken> token) { | 857 scoped_ptr<SyncTaskToken> token) { |
755 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, | 858 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, |
756 weak_ptr_factory_.GetWeakPtr(), | 859 weak_ptr_factory_.GetWeakPtr(), |
757 base::Passed(&token)); | 860 base::Passed(&token)); |
758 } | 861 } |
759 | 862 |
760 } // namespace drive_backend | 863 } // namespace drive_backend |
761 } // namespace sync_file_system | 864 } // namespace sync_file_system |
OLD | NEW |