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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 795003003: Make ProfileSyncService's WeakPtrFactory the last member (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use scoped_ptr Created 6 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/profile_sync_service.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/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 86eb9167673fc5bb8fe33793cb4801050e5441f6..6e4bc2f228b885fcc542a7e2f9e26d377d80af1e 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -231,34 +231,34 @@ ProfileSyncService::ProfileSyncService(
configure_status_(DataTypeManager::UNKNOWN),
oauth2_token_service_(oauth2_token_service),
request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
- weak_factory_(this),
- startup_controller_weak_factory_(this),
connection_status_(syncer::CONNECTION_NOT_ATTEMPTED),
last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
network_resources_(new syncer::HttpBridgeNetworkResources),
- startup_controller_(
- start_behavior,
- oauth2_token_service,
- &sync_prefs_,
- signin_.get(),
- base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
- startup_controller_weak_factory_.GetWeakPtr(),
- SYNC)),
- backup_rollback_controller_(
- &sync_prefs_,
- signin_.get(),
- base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
- startup_controller_weak_factory_.GetWeakPtr(),
- BACKUP),
- base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
- startup_controller_weak_factory_.GetWeakPtr(),
- ROLLBACK)),
backend_mode_(IDLE),
need_backup_(false),
backup_finished_(false),
clear_browsing_data_(base::Bind(&ClearBrowsingData)),
- browsing_data_remover_observer_(NULL) {
+ browsing_data_remover_observer_(NULL),
+ weak_factory_(this),
+ startup_controller_weak_factory_(this) {
DCHECK(profile);
+ startup_controller_.reset(new browser_sync::StartupController(
+ start_behavior,
+ oauth2_token_service,
+ &sync_prefs_,
+ signin_.get(),
+ base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
+ startup_controller_weak_factory_.GetWeakPtr(),
+ SYNC)));
+ backup_rollback_controller_.reset(new browser_sync::BackupRollbackController(
+ &sync_prefs_,
+ signin_.get(),
+ base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
+ startup_controller_weak_factory_.GetWeakPtr(),
+ BACKUP),
+ base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
+ startup_controller_weak_factory_.GetWeakPtr(),
+ ROLLBACK)));
syncer::SyncableService::StartSyncFlare flare(
sync_start_util::GetFlareForSyncableService(profile->GetPath()));
scoped_ptr<browser_sync::LocalSessionEventRouter> router(
@@ -341,7 +341,7 @@ void ProfileSyncService::Initialize() {
sync_prefs_.GetFirstSyncTime().is_null();
// Try to resume rollback if it didn't finish in last session.
- running_rollback = backup_rollback_controller_.StartRollback();
+ running_rollback = backup_rollback_controller_->StartRollback();
} else {
need_backup_ = false;
}
@@ -354,8 +354,8 @@ void ProfileSyncService::Initialize() {
DCHECK(!running_rollback);
#endif
- startup_controller_.Reset(GetRegisteredDataTypes());
- startup_controller_.TryStart();
+ startup_controller_->Reset(GetRegisteredDataTypes());
+ startup_controller_->TryStart();
}
void ProfileSyncService::TrySyncDatatypePrefRecovery() {
@@ -603,7 +603,7 @@ void ProfileSyncService::OnDataTypeRequestsSyncStartup(
return;
}
- startup_controller_.OnDataTypeRequestsSyncStartup(type);
+ startup_controller_->OnDataTypeRequestsSyncStartup(type);
}
void ProfileSyncService::StartUpSlowBackendComponents(
@@ -636,7 +636,7 @@ void ProfileSyncService::StartUpSlowBackendComponents(
if (mode == SYNC && NeedBackup() && !backup_finished_) {
if (backend_mode_ != BACKUP)
- backup_rollback_controller_.StartBackup();
+ backup_rollback_controller_->StartBackup();
return;
}
@@ -716,7 +716,7 @@ void ProfileSyncService::OnGetTokenSuccess(
if (HasSyncingBackend())
backend_->UpdateCredentials(GetCredentials());
else
- startup_controller_.TryStart();
+ startup_controller_->TryStart();
}
void ProfileSyncService::OnGetTokenFailure(
@@ -792,7 +792,7 @@ void ProfileSyncService::OnRefreshTokensLoaded() {
if (HasSyncingBackend()) {
RequestAccessToken();
} else {
- startup_controller_.TryStart();
+ startup_controller_->TryStart();
}
}
@@ -861,7 +861,7 @@ void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) {
weak_factory_.InvalidateWeakPtrs();
if (backend_mode_ == SYNC)
- startup_controller_.Reset(GetRegisteredDataTypes());
+ startup_controller_->Reset(GetRegisteredDataTypes());
// Don't let backup block sync regardless backup succeeded or not.
if (backend_mode_ == BACKUP)
@@ -1002,7 +1002,7 @@ void ProfileSyncService::UpdateBackendInitUMA(bool success) {
base::Time on_backend_initialized_time = base::Time::Now();
base::TimeDelta delta = on_backend_initialized_time -
- startup_controller_.start_backend_time();
+ startup_controller_->start_backend_time();
if (is_first_time_sync_configure_) {
UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeFirstTime", delta);
} else {
@@ -1042,7 +1042,7 @@ void ProfileSyncService::PostBackendInitialization() {
UpdateLastSyncedTime();
}
- if (startup_controller_.auto_start_enabled() && !FirstSetupInProgress()) {
+ if (startup_controller_->auto_start_enabled() && !FirstSetupInProgress()) {
// Backend is initialized but we're not in sync setup, so this must be an
// autostart - mark our sync setup as completed and we'll start syncing
// below.
@@ -1400,7 +1400,7 @@ void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
// TODO(lipalani) : if setup in progress we want to display these
// actions in the popup. The current experience might not be optimal for
// the user. We just dismiss the dialog.
- if (startup_controller_.setup_in_progress()) {
+ if (startup_controller_->setup_in_progress()) {
StopSyncingPermanently();
expect_sync_configuration_aborted_ = true;
}
@@ -1411,21 +1411,21 @@ void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
ERROR_REASON_ACTIONABLE_ERROR);
break;
case syncer::DISABLE_SYNC_AND_ROLLBACK:
- backup_rollback_controller_.OnRollbackReceived();
+ backup_rollback_controller_->OnRollbackReceived();
// Fall through to shutdown backend and sign user out.
case syncer::DISABLE_SYNC_ON_CLIENT:
StopSyncingPermanently();
#if !defined(OS_CHROMEOS)
// On desktop Chrome, sign out the user after a dashboard clear.
// Skip sign out on ChromeOS/Android.
- if (!startup_controller_.auto_start_enabled()) {
+ if (!startup_controller_->auto_start_enabled()) {
SigninManagerFactory::GetForProfile(profile_)->SignOut(
signin_metrics::SERVER_FORCED_DISABLE);
}
#endif
break;
case syncer::ROLLBACK_DONE:
- backup_rollback_controller_.OnRollbackDone();
+ backup_rollback_controller_->OnRollbackDone();
break;
case syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT:
// Sync disabled by domain admin. we should stop syncing until next
@@ -1440,7 +1440,7 @@ void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
if (error.action == syncer::DISABLE_SYNC_ON_CLIENT ||
(error.action == syncer::DISABLE_SYNC_AND_ROLLBACK &&
- !backup_rollback_controller_.StartRollback())) {
+ !backup_rollback_controller_->StartRollback())) {
// Clean up backup data for sign-out only or when rollback is disabled.
CleanUpBackup();
} else if (error.action == syncer::ROLLBACK_DONE) {
@@ -1615,15 +1615,15 @@ std::string ProfileSyncService::QuerySyncStatusSummaryString() {
}
std::string ProfileSyncService::GetBackendInitializationStateString() const {
- return startup_controller_.GetBackendInitializationStateString();
+ return startup_controller_->GetBackendInitializationStateString();
}
bool ProfileSyncService::auto_start_enabled() const {
- return startup_controller_.auto_start_enabled();
+ return startup_controller_->auto_start_enabled();
}
bool ProfileSyncService::setup_in_progress() const {
- return startup_controller_.setup_in_progress();
+ return startup_controller_->setup_in_progress();
}
bool ProfileSyncService::QueryDetailedSyncStatus(
@@ -1644,15 +1644,15 @@ const AuthError& ProfileSyncService::GetAuthError() const {
}
bool ProfileSyncService::FirstSetupInProgress() const {
- return !HasSyncSetupCompleted() && startup_controller_.setup_in_progress();
+ return !HasSyncSetupCompleted() && startup_controller_->setup_in_progress();
}
void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) {
// This method is a no-op if |setup_in_progress_| remains unchanged.
- if (startup_controller_.setup_in_progress() == setup_in_progress)
+ if (startup_controller_->setup_in_progress() == setup_in_progress)
return;
- startup_controller_.set_setup_in_progress(setup_in_progress);
+ startup_controller_->set_setup_in_progress(setup_in_progress);
if (!setup_in_progress && backend_initialized())
ReconfigureDatatypeManager();
NotifyObservers();
@@ -1919,7 +1919,7 @@ void ProfileSyncService::ConfigureDataTypeManager() {
// start syncing data until the user is done configuring encryption options,
// etc. ReconfigureDatatypeManager() will get called again once the UI calls
// SetSetupInProgress(false).
- if (backend_mode_ == SYNC && startup_controller_.setup_in_progress())
+ if (backend_mode_ == SYNC && startup_controller_->setup_in_progress())
return;
bool restart = false;
@@ -2240,7 +2240,7 @@ void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) {
DisableForUser();
} else {
// Sync is no longer disabled by policy. Try starting it up if appropriate.
- startup_controller_.TryStart();
+ startup_controller_->TryStart();
}
}
@@ -2482,7 +2482,7 @@ void ProfileSyncService::UnsuppressAndStart() {
DCHECK(profile_);
sync_prefs_.SetStartSuppressed(false);
DCHECK(!signin_.get() || signin_->GetOriginal()->IsAuthenticated());
- startup_controller_.TryStart();
+ startup_controller_->TryStart();
}
void ProfileSyncService::AcknowledgeSyncedTypes() {
@@ -2705,8 +2705,8 @@ void ProfileSyncService::CheckSyncBackupCallback(base::Time backup_time) {
}
void ProfileSyncService::TryStartSyncAfterBackup() {
- startup_controller_.Reset(GetRegisteredDataTypes());
- startup_controller_.TryStart();
+ startup_controller_->Reset(GetRegisteredDataTypes());
+ startup_controller_->TryStart();
}
void ProfileSyncService::CleanUpBackup() {
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698