Index: sync/engine/syncer.cc |
diff --git a/sync/engine/syncer.cc b/sync/engine/syncer.cc |
index cc379d9d82baaabe5d29787713d191bd9d347f4d..9f2c378b5cc42391d14b3c7f7a5f8be09758f227 100644 |
--- a/sync/engine/syncer.cc |
+++ b/sync/engine/syncer.cc |
@@ -12,17 +12,16 @@ |
#include "build/build_config.h" |
#include "sync/engine/apply_control_data_updates.h" |
#include "sync/engine/apply_updates_and_resolve_conflicts_command.h" |
-#include "sync/engine/build_commit_command.h" |
#include "sync/engine/commit.h" |
#include "sync/engine/conflict_resolver.h" |
#include "sync/engine/download.h" |
#include "sync/engine/net/server_connection_manager.h" |
-#include "sync/engine/process_commit_response_command.h" |
#include "sync/engine/syncer_types.h" |
#include "sync/internal_api/public/base/cancelation_signal.h" |
#include "sync/internal_api/public/base/unique_position.h" |
#include "sync/internal_api/public/util/syncer_error.h" |
#include "sync/sessions/nudge_tracker.h" |
+#include "sync/syncable/directory.h" |
#include "sync/syncable/mutable_entry.h" |
#include "sync/syncable/syncable-inl.h" |
@@ -73,7 +72,7 @@ bool Syncer::NormalSyncShare(ModelTypeSet request_types, |
} |
VLOG(1) << "Committing from types " << ModelTypeSetToString(request_types); |
- SyncerError commit_result = BuildAndPostCommits(request_types, this, session); |
+ SyncerError commit_result = BuildAndPostCommits(request_types, session); |
session->mutable_status_controller()->set_commit_result(commit_result); |
return HandleCycleEnd(session, nudge_tracker.updates_source()); |
@@ -144,6 +143,37 @@ bool Syncer::DownloadAndApplyUpdates( |
return true; |
} |
+SyncerError Syncer::BuildAndPostCommits(ModelTypeSet requested_types, |
+ sessions::SyncSession* session) { |
+ // The ExitRequested() check is unnecessary, since we should start getting |
+ // errors from the ServerConnectionManager if an exist has been requested. |
+ // However, it doesn't hurt to check it anyway. |
+ while (!ExitRequested()) { |
+ scoped_ptr<Commit> commit( |
+ Commit::Init( |
+ requested_types, |
+ session->context()->max_commit_batch_size(), |
+ session->context()->account_name(), |
+ session->context()->directory()->cache_guid(), |
+ session->context()->commit_contributor_map(), |
+ session->context()->extensions_activity())); |
+ if (!commit) { |
+ break; |
+ } |
+ |
+ SyncerError error = commit->PostAndProcessResponse( |
+ session, |
+ session->mutable_status_controller(), |
+ session->context()->extensions_activity()); |
+ commit->CleanUp(); |
+ if (error != SYNCER_OK) { |
+ return error; |
+ } |
+ } |
+ |
+ return SYNCER_OK; |
+} |
+ |
void Syncer::HandleCycleBegin(SyncSession* session) { |
session->mutable_status_controller()->UpdateStartTime(); |
session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN); |