Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: chrome/browser/sync_file_system/drive_backend/sync_engine.cc

Issue 98043004: [SyncFS] Run ConflictResolver only when it is needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test expectation Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/sync_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_backend/sync_engine.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
index 28409096277ecbc19248cffc323b8a4af2130cd0..6ee4af66b4cf996286713bd910814536ed2ac69a 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
@@ -396,6 +396,7 @@ SyncEngine::SyncEngine(
extension_service_(extension_service),
remote_change_processor_(NULL),
service_state_(REMOTE_SERVICE_TEMPORARY_UNAVAILABLE),
+ should_check_conflict_(true),
should_check_remote_change_(true),
sync_enabled_(false),
conflict_resolution_policy_(CONFLICT_RESOLUTION_POLICY_LAST_WRITE_WIN),
@@ -434,6 +435,8 @@ void SyncEngine::DidProcessRemoteChange(RemoteToLocalSyncer* syncer,
SYNC_DIRECTION_REMOTE_TO_LOCAL));
}
+ if (status == SYNC_STATUS_OK)
+ should_check_conflict_ = true;
callback.Run(status, syncer->url());
}
@@ -469,6 +472,8 @@ void SyncEngine::DidApplyLocalChange(LocalToRemoteSyncer* syncer,
if (status == SYNC_STATUS_NO_CHANGE_TO_SYNC)
metadata_database_->PromoteLowerPriorityTrackersToNormal();
+ if (status == SYNC_STATUS_OK)
+ should_check_conflict_ = true;
callback.Run(status);
}
@@ -481,23 +486,35 @@ void SyncEngine::MaybeStartFetchChanges() {
base::TimeTicks now = base::TimeTicks::Now();
if (!should_check_remote_change_ && now < time_to_check_changes_) {
- if (!metadata_database_->HasDirtyTracker()) {
+ if (!metadata_database_->HasDirtyTracker() && should_check_conflict_) {
task_manager_->ScheduleSyncTaskIfIdle(
scoped_ptr<SyncTask>(new ConflictResolver(this)),
- SyncStatusCallback());
+ base::Bind(&SyncEngine::DidResolveConflict,
+ weak_ptr_factory_.GetWeakPtr()));
}
return;
}
if (task_manager_->ScheduleSyncTaskIfIdle(
scoped_ptr<SyncTask>(new ListChangesTask(this)),
- SyncStatusCallback())) {
+ base::Bind(&SyncEngine::DidFetchChanges,
+ weak_ptr_factory_.GetWeakPtr()))) {
should_check_remote_change_ = false;
time_to_check_changes_ =
now + base::TimeDelta::FromSeconds(kListChangesRetryDelaySeconds);
}
}
+void SyncEngine::DidResolveConflict(SyncStatusCode status) {
+ if (status == SYNC_STATUS_NO_CONFLICT)
+ should_check_conflict_ = false;
+}
+
+void SyncEngine::DidFetchChanges(SyncStatusCode status) {
+ if (status == SYNC_STATUS_OK)
+ should_check_conflict_ = true;
+}
+
void SyncEngine::UpdateServiceStateFromSyncStatusCode(
SyncStatusCode status,
bool used_network) {
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/sync_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698