| Index: components/browser_sync/profile_sync_service.cc
|
| diff --git a/components/browser_sync/profile_sync_service.cc b/components/browser_sync/profile_sync_service.cc
|
| index f949818c3d78d204f6c6877e4fddec3923367257..6b510ee794bc3ffd6697b0dfaccf06562c66ee12 100644
|
| --- a/components/browser_sync/profile_sync_service.cc
|
| +++ b/components/browser_sync/profile_sync_service.cc
|
| @@ -232,7 +232,7 @@ ProfileSyncService::ProfileSyncService(InitParams init_params)
|
| last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
|
| gaia_cookie_manager_service_(init_params.gaia_cookie_manager_service),
|
| network_resources_(new syncer::HttpBridgeNetworkResources),
|
| - start_behavior_(init_params.start_behavior),
|
| + start_behavior_(AUTO_START /*init_params.start_behavior*/),
|
| directory_path_(
|
| base_directory_.Append(base::FilePath(kSyncDataFolderName))),
|
| catch_up_configure_in_progress_(false),
|
| @@ -262,10 +262,13 @@ ProfileSyncService::~ProfileSyncService() {
|
| }
|
|
|
| bool ProfileSyncService::CanSyncStart() const {
|
| - return IsSyncAllowed() && IsSyncRequested() && IsSignedIn();
|
| + // ### Only if needed.
|
| + return IsSyncAllowed() && IsSyncRequested();// && IsSignedIn();
|
| }
|
|
|
| void ProfileSyncService::Initialize() {
|
| + LOG(ERROR) << "@@@@ INIT CALLED";
|
| + //sync_prefs_.SetFirstSetupComplete();
|
| sync_client_->Initialize();
|
|
|
| // We don't pass StartupController an Unretained reference to future-proof
|
| @@ -318,8 +321,10 @@ void ProfileSyncService::Initialize() {
|
| sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes(
|
| this, register_platform_types_callback);
|
|
|
| - if (gaia_cookie_manager_service_)
|
| - gaia_cookie_manager_service_->AddObserver(this);
|
| +
|
| + // ### We have to change this to only do it if needed.
|
| + // if (gaia_cookie_manager_service_)
|
| + // gaia_cookie_manager_service_->AddObserver(this);
|
|
|
| // We clear this here (vs Shutdown) because we want to remember that an error
|
| // happened on shutdown so we can display details (message, location) about it
|
| @@ -328,10 +333,11 @@ void ProfileSyncService::Initialize() {
|
|
|
| sync_prefs_.AddSyncPrefObserver(this);
|
|
|
| + // Only for UMA purposes :(
|
| SyncInitialState sync_state = CAN_START;
|
| - if (!IsSignedIn()) {
|
| + /*if (!IsSignedIn()) {
|
| sync_state = NOT_SIGNED_IN;
|
| - } else if (IsManaged()) {
|
| + } else*/ if (IsManaged()) {
|
| sync_state = IS_MANAGED;
|
| } else if (!IsSyncAllowedByPlatform()) {
|
| // This case should currently never be hit, as Android's master sync isn't
|
| @@ -356,12 +362,14 @@ void ProfileSyncService::Initialize() {
|
| return;
|
| }
|
|
|
| - RegisterAuthNotifications();
|
| + // ### We should do this only if needed.
|
| + // RegisterAuthNotifications();
|
|
|
| - if (!IsSignedIn()) {
|
| - // Clean up in case of previous crash during signout.
|
| - StopImpl(CLEAR_DATA);
|
| - }
|
| + // ### We should do this only if needed.
|
| + // if (!IsSignedIn()) {
|
| + // // Clean up in case of previous crash during signout.
|
| + // StopImpl(CLEAR_DATA);
|
| + // }
|
|
|
| #if defined(OS_CHROMEOS)
|
| std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken();
|
| @@ -383,8 +391,8 @@ void ProfileSyncService::Initialize() {
|
| sync_enabled_weak_factory_.GetWeakPtr())));
|
| startup_controller_->Reset(GetRegisteredDataTypes());
|
|
|
| - // Auto-start means means the first time the profile starts up, sync should
|
| - // start up immediately.
|
| + // Auto-start means the first time the profile starts up, sync should start up
|
| + // immediately.
|
| if (start_behavior_ == AUTO_START && IsSyncRequested() &&
|
| !IsFirstSetupComplete()) {
|
| startup_controller_->TryStartImmediately();
|
| @@ -505,12 +513,15 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
|
| NOTREACHED();
|
| return;
|
| }
|
| + LOG(ERROR) << "@@@ ProfileSyncService::InitializeBackend";
|
|
|
| - SyncCredentials credentials = GetCredentials();
|
| + // ### Only do this if needed.
|
| + SyncCredentials credentials;// = GetCredentials();
|
|
|
| if (delete_stale_data)
|
| ClearStaleErrors();
|
|
|
| + // ### Only do this if needed.
|
| SyncBackendHost::HttpPostProviderFactoryGetter
|
| http_post_provider_factory_getter =
|
| base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory,
|
| @@ -967,6 +978,7 @@ void ProfileSyncService::PostBackendInitialization() {
|
| }
|
|
|
| NotifyObservers();
|
| + RequestStart();
|
| }
|
|
|
| void ProfileSyncService::OnBackendInitialized(
|
| @@ -976,6 +988,7 @@ void ProfileSyncService::OnBackendInitialized(
|
| const std::string& cache_guid,
|
| bool success) {
|
| UpdateBackendInitUMA(success);
|
| + LOG(ERROR) << "@@@@ ProfileSyncService::OnBackendInitialized is " << success;
|
|
|
| if (!success) {
|
| // Something went unexpectedly wrong. Play it safe: stop syncing at once
|
| @@ -1402,6 +1415,7 @@ void ProfileSyncService::OnConfigureDone(
|
| return;
|
| }
|
|
|
| + LOG(ERROR) << "@@@ Start syncing";
|
| StartSyncingWithServer();
|
| }
|
|
|
| @@ -1515,13 +1529,16 @@ void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) {
|
|
|
| bool ProfileSyncService::IsSignedIn() const {
|
| // Sync is logged in if there is a non-empty effective account id.
|
| - return !signin_->GetAccountIdToUse().empty();
|
| + NOTREACHED() << "@@@ WHy do you even ask";
|
| + return true;
|
| + //return !signin_->GetAccountIdToUse().empty();
|
| }
|
|
|
| bool ProfileSyncService::CanBackendStart() const {
|
| - return CanSyncStart() && oauth2_token_service_ &&
|
| + // ### Only if needed.
|
| + return CanSyncStart() /*&& oauth2_token_service_ &&
|
| oauth2_token_service_->RefreshTokenIsAvailable(
|
| - signin_->GetAccountIdToUse());
|
| + signin_->GetAccountIdToUse())*/;
|
| }
|
|
|
| bool ProfileSyncService::IsBackendInitialized() const {
|
| @@ -2304,6 +2321,7 @@ SigninManagerBase* ProfileSyncService::signin() const {
|
| }
|
|
|
| void ProfileSyncService::RequestStart() {
|
| + LOG(ERROR) << "@@@@ Requesting start";
|
| if (!IsSyncAllowed()) {
|
| // Sync cannot be requested if it's not allowed.
|
| return;
|
| @@ -2406,9 +2424,10 @@ bool ProfileSyncService::HasSyncingBackend() const {
|
| }
|
|
|
| void ProfileSyncService::UpdateFirstSyncTimePref() {
|
| - if (!IsSignedIn()) {
|
| + // ### Only if needed.
|
| + /*if (!IsSignedIn()) {
|
| sync_prefs_.ClearFirstSyncTime();
|
| - } else if (sync_prefs_.GetFirstSyncTime().is_null()) {
|
| + } else*/ if (sync_prefs_.GetFirstSyncTime().is_null()) {
|
| // Set if not set before and it's syncing now.
|
| sync_prefs_.SetFirstSyncTime(base::Time::Now());
|
| }
|
|
|