Commit f50a50a7 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Remove SyncService::TransportState::WAITING_FOR_START_REQUEST

After https://crrev.com/c/1430089, this state is not meaningful
anymore. Yay, one less!

Semi-relatedly, this CL also moves some NotifyObservers() calls, to
avoid notifying while we're in an intermediate (and thus potentially
invalid) state.

Bug: 839834, 935908
Change-Id: I6093ba3bd44452990ba9b0b8926b3c6e308c90ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1481418Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638482}
parent 82c0cea0
...@@ -443,8 +443,8 @@ TEST_F(PeopleHandlerTest, ...@@ -443,8 +443,8 @@ TEST_F(PeopleHandlerTest,
.WillByDefault(Return(true)); .WillByDefault(Return(true));
// Sync engine is stopped initially, and will start up. // Sync engine is stopped initially, and will start up.
ON_CALL(*mock_pss_, GetTransportState()) ON_CALL(*mock_pss_, GetTransportState())
.WillByDefault(Return( .WillByDefault(
syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST)); Return(syncer::SyncService::TransportState::START_DEFERRED));
EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true)); EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
SetDefaultExpectationsForConfigPage(); SetDefaultExpectationsForConfigPage();
......
...@@ -538,8 +538,8 @@ void ProfileSyncService::StartUpSlowEngineComponents() { ...@@ -538,8 +538,8 @@ void ProfileSyncService::StartUpSlowEngineComponents() {
void ProfileSyncService::Shutdown() { void ProfileSyncService::Shutdown() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ShutdownImpl(syncer::BROWSER_SHUTDOWN);
NotifyShutdown(); NotifyShutdown();
ShutdownImpl(syncer::BROWSER_SHUTDOWN);
// All observers must be gone now: All KeyedServices should have unregistered // All observers must be gone now: All KeyedServices should have unregistered
// their observers already before, in their own Shutdown(), and all others // their observers already before, in their own Shutdown(), and all others
...@@ -701,9 +701,12 @@ syncer::SyncService::TransportState ProfileSyncService::GetTransportState() ...@@ -701,9 +701,12 @@ syncer::SyncService::TransportState ProfileSyncService::GetTransportState()
if (!engine_initialized_) { if (!engine_initialized_) {
switch (startup_controller_->GetState()) { switch (startup_controller_->GetState()) {
// TODO(crbug.com/935523): If the engine is allowed to start, then we
// should generally have kicked off the startup process already, so
// NOT_STARTED should be impossible. But we can temporarily be in this
// state between shutting down and starting up again (e.g. during the
// NotifyObservers() call in ShutdownImpl()).
case syncer::StartupController::State::NOT_STARTED: case syncer::StartupController::State::NOT_STARTED:
DCHECK(!engine_);
return TransportState::WAITING_FOR_START_REQUEST;
case syncer::StartupController::State::STARTING_DEFERRED: case syncer::StartupController::State::STARTING_DEFERRED:
DCHECK(!engine_); DCHECK(!engine_);
return TransportState::START_DEFERRED; return TransportState::START_DEFERRED;
...@@ -1523,8 +1526,6 @@ void ProfileSyncService::OnFirstSetupCompletePrefChange( ...@@ -1523,8 +1526,6 @@ void ProfileSyncService::OnFirstSetupCompletePrefChange(
void ProfileSyncService::OnSyncRequestedPrefChange(bool is_sync_requested) { void ProfileSyncService::OnSyncRequestedPrefChange(bool is_sync_requested) {
if (is_sync_requested) { if (is_sync_requested) {
NotifyObservers();
// If the Sync engine was already initialized (probably running in transport // If the Sync engine was already initialized (probably running in transport
// mode), just reconfigure. // mode), just reconfigure.
if (engine_initialized_) { if (engine_initialized_) {
...@@ -1534,6 +1535,8 @@ void ProfileSyncService::OnSyncRequestedPrefChange(bool is_sync_requested) { ...@@ -1534,6 +1535,8 @@ void ProfileSyncService::OnSyncRequestedPrefChange(bool is_sync_requested) {
// reasons remaining, in which case this will effectively do nothing. // reasons remaining, in which case this will effectively do nothing.
startup_controller_->TryStart(/*force_immediate=*/true); startup_controller_->TryStart(/*force_immediate=*/true);
} }
NotifyObservers();
} else { } else {
// This will notify the observers. // This will notify the observers.
if (is_stopping_and_clearing_) { if (is_stopping_and_clearing_) {
......
...@@ -194,10 +194,8 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { ...@@ -194,10 +194,8 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
SimulateTestUserSignin(); SimulateTestUserSignin();
// Now we're signed in, so the engine can start. There's already a setup in // Now we're signed in, so the engine can start. Engine initialization is
// progress, so we don't go into the WAITING_FOR_START_REQUEST state. Engine // immediate in this test, so we bypass the INITIALIZING state.
// initialization is immediate in this test, so we also bypass the
// INITIALIZING state.
EXPECT_TRUE(sync_service()->IsEngineInitialized()); EXPECT_TRUE(sync_service()->IsEngineInitialized());
EXPECT_EQ(syncer::SyncService::DISABLE_REASON_NONE, EXPECT_EQ(syncer::SyncService::DISABLE_REASON_NONE,
sync_service()->GetDisableReasons()); sync_service()->GetDisableReasons());
......
...@@ -206,8 +206,6 @@ std::string GetTransportStateString(syncer::SyncService::TransportState state) { ...@@ -206,8 +206,6 @@ std::string GetTransportStateString(syncer::SyncService::TransportState state) {
switch (state) { switch (state) {
case syncer::SyncService::TransportState::DISABLED: case syncer::SyncService::TransportState::DISABLED:
return "Disabled"; return "Disabled";
case syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST:
return "Waiting for start request";
case syncer::SyncService::TransportState::START_DEFERRED: case syncer::SyncService::TransportState::START_DEFERRED:
return "Start deferred"; return "Start deferred";
case syncer::SyncService::TransportState::INITIALIZING: case syncer::SyncService::TransportState::INITIALIZING:
......
...@@ -30,7 +30,6 @@ bool SyncService::CanSyncFeatureStart() const { ...@@ -30,7 +30,6 @@ bool SyncService::CanSyncFeatureStart() const {
bool SyncService::IsEngineInitialized() const { bool SyncService::IsEngineInitialized() const {
switch (GetTransportState()) { switch (GetTransportState()) {
case TransportState::DISABLED: case TransportState::DISABLED:
case TransportState::WAITING_FOR_START_REQUEST:
case TransportState::START_DEFERRED: case TransportState::START_DEFERRED:
case TransportState::INITIALIZING: case TransportState::INITIALIZING:
return false; return false;
...@@ -49,7 +48,6 @@ bool SyncService::IsSyncFeatureActive() const { ...@@ -49,7 +48,6 @@ bool SyncService::IsSyncFeatureActive() const {
} }
switch (GetTransportState()) { switch (GetTransportState()) {
case TransportState::DISABLED: case TransportState::DISABLED:
case TransportState::WAITING_FOR_START_REQUEST:
case TransportState::START_DEFERRED: case TransportState::START_DEFERRED:
case TransportState::INITIALIZING: case TransportState::INITIALIZING:
case TransportState::PENDING_DESIRED_CONFIGURATION: case TransportState::PENDING_DESIRED_CONFIGURATION:
......
...@@ -85,15 +85,6 @@ class SyncService : public KeyedService { ...@@ -85,15 +85,6 @@ class SyncService : public KeyedService {
// Sync is inactive, e.g. due to enterprise policy, or simply because there // Sync is inactive, e.g. due to enterprise policy, or simply because there
// is no authenticated user. // is no authenticated user.
DISABLED, DISABLED,
// Sync can start in principle, but nothing has prodded it to actually do it
// yet. Note that during subsequent browser startups, Sync starts
// automatically, i.e. no prod is necessary, but during the first start Sync
// does need a kick. This usually happens via starting (not finishing!) the
// initial setup, or via a call to SyncUserSettings::SetSyncRequested.
// TODO(crbug.com/839834): Check whether this state is necessary, or if Sync
// can just always start up if all conditions are fulfilled (that's what
// happens in practice anyway).
WAITING_FOR_START_REQUEST,
// Sync's startup was deferred, so that it doesn't slow down browser // Sync's startup was deferred, so that it doesn't slow down browser
// startup. Once the deferral time (usually 10s) expires, or something // startup. Once the deferral time (usually 10s) expires, or something
// requests immediate startup, Sync will actually start. // requests immediate startup, Sync will actually start.
......
...@@ -45,7 +45,6 @@ UploadState GetUploadToGoogleState(const SyncService* sync_service, ...@@ -45,7 +45,6 @@ UploadState GetUploadToGoogleState(const SyncService* sync_service,
case SyncService::TransportState::DISABLED: case SyncService::TransportState::DISABLED:
return UploadState::NOT_ACTIVE; return UploadState::NOT_ACTIVE;
case SyncService::TransportState::WAITING_FOR_START_REQUEST:
case SyncService::TransportState::START_DEFERRED: case SyncService::TransportState::START_DEFERRED:
case SyncService::TransportState::INITIALIZING: case SyncService::TransportState::INITIALIZING:
case SyncService::TransportState::PENDING_DESIRED_CONFIGURATION: case SyncService::TransportState::PENDING_DESIRED_CONFIGURATION:
......
...@@ -30,7 +30,7 @@ TEST(SyncServiceUtilsTest, UploadToGoogleDisabledIfSyncNotAllowed) { ...@@ -30,7 +30,7 @@ TEST(SyncServiceUtilsTest, UploadToGoogleDisabledIfSyncNotAllowed) {
// disabled anymore (though not necessarily active yet). // disabled anymore (though not necessarily active yet).
service.SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE); service.SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE);
service.SetTransportState( service.SetTransportState(
syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST); syncer::SyncService::TransportState::START_DEFERRED);
EXPECT_NE(UploadState::NOT_ACTIVE, EXPECT_NE(UploadState::NOT_ACTIVE,
GetUploadToGoogleState(&service, syncer::BOOKMARKS)); GetUploadToGoogleState(&service, syncer::BOOKMARKS));
...@@ -41,7 +41,7 @@ TEST(SyncServiceUtilsTest, ...@@ -41,7 +41,7 @@ TEST(SyncServiceUtilsTest,
TestSyncService service; TestSyncService service;
service.SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE); service.SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE);
service.SetTransportState( service.SetTransportState(
syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST); syncer::SyncService::TransportState::START_DEFERRED);
service.SetPreferredDataTypes(ProtocolTypes()); service.SetPreferredDataTypes(ProtocolTypes());
service.SetActiveDataTypes(ProtocolTypes()); service.SetActiveDataTypes(ProtocolTypes());
service.SetEmptyLastCycleSnapshot(); service.SetEmptyLastCycleSnapshot();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment