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/sync_engine.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/drive/drive_api_service.h" | 10 #include "chrome/browser/drive/drive_api_service.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 | 563 |
| 564 if (!metadata_database_) | 564 if (!metadata_database_) |
| 565 return; | 565 return; |
| 566 | 566 |
| 567 if (listing_remote_changes_) | 567 if (listing_remote_changes_) |
| 568 return; | 568 return; |
| 569 | 569 |
| 570 base::TimeTicks now = base::TimeTicks::Now(); | 570 base::TimeTicks now = base::TimeTicks::Now(); |
| 571 if (!should_check_remote_change_ && now < time_to_check_changes_) { | 571 if (!should_check_remote_change_ && now < time_to_check_changes_) { |
| 572 if (!metadata_database_->HasDirtyTracker() && should_check_conflict_) { | 572 if (!metadata_database_->HasDirtyTracker() && should_check_conflict_) { |
| 573 should_check_conflict_ = false; | |
| 573 task_manager_->ScheduleSyncTaskIfIdle( | 574 task_manager_->ScheduleSyncTaskIfIdle( |
| 574 scoped_ptr<SyncTask>(new ConflictResolver(this)), | 575 scoped_ptr<SyncTask>(new ConflictResolver(this)), |
| 575 base::Bind(&SyncEngine::DidResolveConflict, | 576 base::Bind(&SyncEngine::DidResolveConflict, |
| 576 weak_ptr_factory_.GetWeakPtr())); | 577 weak_ptr_factory_.GetWeakPtr())); |
| 577 } | 578 } |
| 578 return; | 579 return; |
| 579 } | 580 } |
| 580 | 581 |
| 581 if (task_manager_->ScheduleSyncTaskIfIdle( | 582 if (task_manager_->ScheduleSyncTaskIfIdle( |
| 582 scoped_ptr<SyncTask>(new ListChangesTask(this)), | 583 scoped_ptr<SyncTask>(new ListChangesTask(this)), |
| 583 base::Bind(&SyncEngine::DidFetchChanges, | 584 base::Bind(&SyncEngine::DidFetchChanges, |
| 584 weak_ptr_factory_.GetWeakPtr()))) { | 585 weak_ptr_factory_.GetWeakPtr()))) { |
| 585 should_check_remote_change_ = false; | 586 should_check_remote_change_ = false; |
| 586 listing_remote_changes_ = true; | 587 listing_remote_changes_ = true; |
| 587 time_to_check_changes_ = | 588 time_to_check_changes_ = |
| 588 now + base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds); | 589 now + base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds); |
| 589 } | 590 } |
| 590 } | 591 } |
| 591 | 592 |
| 592 void SyncEngine::DidResolveConflict(SyncStatusCode status) { | 593 void SyncEngine::DidResolveConflict(SyncStatusCode status) { |
|
nhiroki
2014/01/30 04:24:35
How about having "DCHECK(!should_check_conflict_);
nhiroki
2014/01/30 04:53:27
Hmm... this seems overkill...? Anyway, your change
| |
| 593 if (status == SYNC_STATUS_NO_CONFLICT) | 594 if (status == SYNC_STATUS_OK) |
| 594 should_check_conflict_ = false; | 595 should_check_conflict_ = true; |
| 595 } | 596 } |
| 596 | 597 |
| 597 void SyncEngine::DidFetchChanges(SyncStatusCode status) { | 598 void SyncEngine::DidFetchChanges(SyncStatusCode status) { |
| 598 if (status == SYNC_STATUS_OK) | 599 if (status == SYNC_STATUS_OK) |
| 599 should_check_conflict_ = true; | 600 should_check_conflict_ = true; |
| 600 listing_remote_changes_ = false; | 601 listing_remote_changes_ = false; |
| 601 } | 602 } |
| 602 | 603 |
| 603 void SyncEngine::UpdateServiceStateFromSyncStatusCode( | 604 void SyncEngine::UpdateServiceStateFromSyncStatusCode( |
| 604 SyncStatusCode status, | 605 SyncStatusCode status, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; | 699 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; |
| 699 if (is_app_enabled && !is_app_root_tracker_enabled) | 700 if (is_app_enabled && !is_app_root_tracker_enabled) |
| 700 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); | 701 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); |
| 701 else if (!is_app_enabled && is_app_root_tracker_enabled) | 702 else if (!is_app_enabled && is_app_root_tracker_enabled) |
| 702 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); | 703 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); |
| 703 } | 704 } |
| 704 } | 705 } |
| 705 | 706 |
| 706 } // namespace drive_backend | 707 } // namespace drive_backend |
| 707 } // namespace sync_file_system | 708 } // namespace sync_file_system |
| OLD | NEW |