| Index: components/sync/engine_impl/syncer.cc
|
| diff --git a/components/sync/engine_impl/syncer.cc b/components/sync/engine_impl/syncer.cc
|
| index dda2783e50b9c296e1dda592d64516de81fc93fe..bc8672f6b0af75103ed05bb115e50d468e2fb878 100644
|
| --- a/components/sync/engine_impl/syncer.cc
|
| +++ b/components/sync/engine_impl/syncer.cc
|
| @@ -21,11 +21,11 @@
|
| #include "components/sync/engine_impl/commit.h"
|
| #include "components/sync/engine_impl/commit_processor.h"
|
| #include "components/sync/engine_impl/conflict_resolver.h"
|
| +#include "components/sync/engine_impl/cycle/nudge_tracker.h"
|
| #include "components/sync/engine_impl/get_updates_delegate.h"
|
| #include "components/sync/engine_impl/get_updates_processor.h"
|
| #include "components/sync/engine_impl/net/server_connection_manager.h"
|
| #include "components/sync/engine_impl/syncer_types.h"
|
| -#include "components/sync/sessions_impl/nudge_tracker.h"
|
| #include "components/sync/syncable/directory.h"
|
| #include "components/sync/syncable/mutable_entry.h"
|
| #include "components/sync/syncable/syncable-inl.h"
|
| @@ -44,10 +44,6 @@ static const bool kCreateMobileBookmarksFolder = true;
|
| static const bool kCreateMobileBookmarksFolder = false;
|
| #endif
|
|
|
| -using sessions::StatusController;
|
| -using sessions::SyncSession;
|
| -using sessions::NudgeTracker;
|
| -
|
| Syncer::Syncer(syncer::CancelationSignal* cancelation_signal)
|
| : cancelation_signal_(cancelation_signal), is_syncing_(false) {}
|
|
|
| @@ -63,70 +59,69 @@ bool Syncer::IsSyncing() const {
|
|
|
| bool Syncer::NormalSyncShare(ModelTypeSet request_types,
|
| NudgeTracker* nudge_tracker,
|
| - SyncSession* session) {
|
| + SyncCycle* cycle) {
|
| base::AutoReset<bool> is_syncing(&is_syncing_, true);
|
| - HandleCycleBegin(session);
|
| + HandleCycleBegin(cycle);
|
| if (nudge_tracker->IsGetUpdatesRequired() ||
|
| - session->context()->ShouldFetchUpdatesBeforeCommit()) {
|
| + cycle->context()->ShouldFetchUpdatesBeforeCommit()) {
|
| VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types);
|
| NormalGetUpdatesDelegate normal_delegate(*nudge_tracker);
|
| GetUpdatesProcessor get_updates_processor(
|
| - session->context()->model_type_registry()->update_handler_map(),
|
| + cycle->context()->model_type_registry()->update_handler_map(),
|
| normal_delegate);
|
| - if (!DownloadAndApplyUpdates(&request_types, session,
|
| - &get_updates_processor,
|
| + if (!DownloadAndApplyUpdates(&request_types, cycle, &get_updates_processor,
|
| kCreateMobileBookmarksFolder)) {
|
| - return HandleCycleEnd(session, nudge_tracker->GetLegacySource());
|
| + return HandleCycleEnd(cycle, nudge_tracker->GetLegacySource());
|
| }
|
| }
|
|
|
| VLOG(1) << "Committing from types " << ModelTypeSetToString(request_types);
|
| CommitProcessor commit_processor(
|
| - session->context()->model_type_registry()->commit_contributor_map());
|
| + cycle->context()->model_type_registry()->commit_contributor_map());
|
| SyncerError commit_result = BuildAndPostCommits(request_types, nudge_tracker,
|
| - session, &commit_processor);
|
| - session->mutable_status_controller()->set_commit_result(commit_result);
|
| + cycle, &commit_processor);
|
| + cycle->mutable_status_controller()->set_commit_result(commit_result);
|
|
|
| - return HandleCycleEnd(session, nudge_tracker->GetLegacySource());
|
| + return HandleCycleEnd(cycle, nudge_tracker->GetLegacySource());
|
| }
|
|
|
| bool Syncer::ConfigureSyncShare(
|
| ModelTypeSet request_types,
|
| sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
|
| - SyncSession* session) {
|
| + SyncCycle* cycle) {
|
| base::AutoReset<bool> is_syncing(&is_syncing_, true);
|
| VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types);
|
| - HandleCycleBegin(session);
|
| + HandleCycleBegin(cycle);
|
| ConfigureGetUpdatesDelegate configure_delegate(source);
|
| GetUpdatesProcessor get_updates_processor(
|
| - session->context()->model_type_registry()->update_handler_map(),
|
| + cycle->context()->model_type_registry()->update_handler_map(),
|
| configure_delegate);
|
| - DownloadAndApplyUpdates(&request_types, session, &get_updates_processor,
|
| + DownloadAndApplyUpdates(&request_types, cycle, &get_updates_processor,
|
| kCreateMobileBookmarksFolder);
|
| - return HandleCycleEnd(session, source);
|
| + return HandleCycleEnd(cycle, source);
|
| }
|
|
|
| -bool Syncer::PollSyncShare(ModelTypeSet request_types, SyncSession* session) {
|
| +bool Syncer::PollSyncShare(ModelTypeSet request_types, SyncCycle* cycle) {
|
| base::AutoReset<bool> is_syncing(&is_syncing_, true);
|
| VLOG(1) << "Polling types " << ModelTypeSetToString(request_types);
|
| - HandleCycleBegin(session);
|
| + HandleCycleBegin(cycle);
|
| PollGetUpdatesDelegate poll_delegate;
|
| GetUpdatesProcessor get_updates_processor(
|
| - session->context()->model_type_registry()->update_handler_map(),
|
| + cycle->context()->model_type_registry()->update_handler_map(),
|
| poll_delegate);
|
| - DownloadAndApplyUpdates(&request_types, session, &get_updates_processor,
|
| + DownloadAndApplyUpdates(&request_types, cycle, &get_updates_processor,
|
| kCreateMobileBookmarksFolder);
|
| - return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::PERIODIC);
|
| + return HandleCycleEnd(cycle, sync_pb::GetUpdatesCallerInfo::PERIODIC);
|
| }
|
|
|
| bool Syncer::DownloadAndApplyUpdates(ModelTypeSet* request_types,
|
| - SyncSession* session,
|
| + SyncCycle* cycle,
|
| GetUpdatesProcessor* get_updates_processor,
|
| bool create_mobile_bookmarks_folder) {
|
| SyncerError download_result = UNSET;
|
| do {
|
| download_result = get_updates_processor->DownloadUpdates(
|
| - request_types, session, create_mobile_bookmarks_folder);
|
| + request_types, cycle, create_mobile_bookmarks_folder);
|
| } while (download_result == SERVER_MORE_TO_DOWNLOAD);
|
|
|
| // Exit without applying if we're shutting down or an error was detected.
|
| @@ -139,17 +134,17 @@ bool Syncer::DownloadAndApplyUpdates(ModelTypeSet* request_types,
|
| TRACE_EVENT0("sync", "ApplyUpdates");
|
|
|
| // Control type updates always get applied first.
|
| - ApplyControlDataUpdates(session->context()->directory());
|
| + ApplyControlDataUpdates(cycle->context()->directory());
|
|
|
| // Apply upates to the other types. May or may not involve cross-thread
|
| // traffic, depending on the underlying update handlers and the GU type's
|
| // delegate.
|
| get_updates_processor->ApplyUpdates(*request_types,
|
| - session->mutable_status_controller());
|
| + cycle->mutable_status_controller());
|
|
|
| - session->context()->set_hierarchy_conflict_detected(
|
| - session->status_controller().num_hierarchy_conflicts() > 0);
|
| - session->SendEventNotification(SyncCycleEvent::STATUS_CHANGED);
|
| + cycle->context()->set_hierarchy_conflict_detected(
|
| + cycle->status_controller().num_hierarchy_conflicts() > 0);
|
| + cycle->SendEventNotification(SyncCycleEvent::STATUS_CHANGED);
|
| }
|
|
|
| if (ExitRequested())
|
| @@ -158,28 +153,28 @@ bool Syncer::DownloadAndApplyUpdates(ModelTypeSet* request_types,
|
| }
|
|
|
| SyncerError Syncer::BuildAndPostCommits(ModelTypeSet requested_types,
|
| - sessions::NudgeTracker* nudge_tracker,
|
| - sessions::SyncSession* session,
|
| + NudgeTracker* nudge_tracker,
|
| + SyncCycle* cycle,
|
| CommitProcessor* commit_processor) {
|
| // 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()) {
|
| std::unique_ptr<Commit> commit(
|
| - Commit::Init(requested_types, session->context()->GetEnabledTypes(),
|
| - session->context()->max_commit_batch_size(),
|
| - session->context()->account_name(),
|
| - session->context()->directory()->cache_guid(),
|
| - session->context()->cookie_jar_mismatch(),
|
| - session->context()->cookie_jar_empty(), commit_processor,
|
| - session->context()->extensions_activity()));
|
| + Commit::Init(requested_types, cycle->context()->GetEnabledTypes(),
|
| + cycle->context()->max_commit_batch_size(),
|
| + cycle->context()->account_name(),
|
| + cycle->context()->directory()->cache_guid(),
|
| + cycle->context()->cookie_jar_mismatch(),
|
| + cycle->context()->cookie_jar_empty(), commit_processor,
|
| + cycle->context()->extensions_activity()));
|
| if (!commit) {
|
| break;
|
| }
|
|
|
| SyncerError error = commit->PostAndProcessResponse(
|
| - nudge_tracker, session, session->mutable_status_controller(),
|
| - session->context()->extensions_activity());
|
| + nudge_tracker, cycle, cycle->mutable_status_controller(),
|
| + cycle->context()->extensions_activity());
|
| commit->CleanUp();
|
| if (error != SYNCER_OK) {
|
| return error;
|
| @@ -189,31 +184,31 @@ SyncerError Syncer::BuildAndPostCommits(ModelTypeSet requested_types,
|
| return SYNCER_OK;
|
| }
|
|
|
| -void Syncer::HandleCycleBegin(SyncSession* session) {
|
| - session->mutable_status_controller()->UpdateStartTime();
|
| - session->SendEventNotification(SyncCycleEvent::SYNC_CYCLE_BEGIN);
|
| +void Syncer::HandleCycleBegin(SyncCycle* cycle) {
|
| + cycle->mutable_status_controller()->UpdateStartTime();
|
| + cycle->SendEventNotification(SyncCycleEvent::SYNC_CYCLE_BEGIN);
|
| }
|
|
|
| bool Syncer::HandleCycleEnd(
|
| - SyncSession* session,
|
| + SyncCycle* cycle,
|
| sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) {
|
| if (!ExitRequested()) {
|
| - session->SendSyncCycleEndEventNotification(source);
|
| + cycle->SendSyncCycleEndEventNotification(source);
|
|
|
| - bool success = !sessions::HasSyncerError(
|
| - session->status_controller().model_neutral_state());
|
| + bool success =
|
| + !HasSyncerError(cycle->status_controller().model_neutral_state());
|
| if (success && source == sync_pb::GetUpdatesCallerInfo::PERIODIC)
|
| - session->mutable_status_controller()->UpdatePollTime();
|
| + cycle->mutable_status_controller()->UpdatePollTime();
|
| return success;
|
| } else {
|
| return false;
|
| }
|
| }
|
|
|
| -bool Syncer::PostClearServerData(SyncSession* session) {
|
| - DCHECK(session);
|
| - ClearServerData clear_server_data(session->context()->account_name());
|
| - const SyncerError post_result = clear_server_data.SendRequest(session);
|
| +bool Syncer::PostClearServerData(SyncCycle* cycle) {
|
| + DCHECK(cycle);
|
| + ClearServerData clear_server_data(cycle->context()->account_name());
|
| + const SyncerError post_result = clear_server_data.SendRequest(cycle);
|
| return post_result == SYNCER_OK;
|
| }
|
|
|
|
|