| 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 2ac3deed199641b1b73d1e363b6f6284ebfac33c..4b2f6afdb1f21c5066c0ec8be7e1ed010adaafd3 100644
|
| --- a/chrome/browser/sync/profile_sync_service.cc
|
| +++ b/chrome/browser/sync/profile_sync_service.cc
|
| @@ -365,6 +365,8 @@ void ProfileSyncService::Initialize() {
|
| DCHECK(!running_rollback);
|
| #endif
|
|
|
| + memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind(
|
| + &ProfileSyncService::OnMemoryPressure, weak_factory_.GetWeakPtr())));
|
| startup_controller_->Reset(GetRegisteredDataTypes());
|
| startup_controller_->TryStart();
|
| }
|
| @@ -702,6 +704,8 @@ void ProfileSyncService::StartUpSlowBackendComponents(
|
| InitializeBackend(ShouldDeleteSyncFolder());
|
|
|
| UpdateFirstSyncTimePref();
|
| +
|
| + CheckPreviousShutdownMemoryWarning();
|
| }
|
|
|
| void ProfileSyncService::OnGetTokenSuccess(
|
| @@ -912,6 +916,8 @@ void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) {
|
| UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone());
|
|
|
| NotifyObservers();
|
| +
|
| + sync_prefs_.SetCurrentShutdown(false);
|
| }
|
|
|
| void ProfileSyncService::DisableForUser() {
|
| @@ -2720,3 +2726,28 @@ void ProfileSyncService::RemoveClientFromServer() const {
|
| access_token_, cache_guid, birthday);
|
| }
|
| }
|
| +
|
| +void ProfileSyncService::OnMemoryPressure(
|
| + base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
|
| + if (memory_pressure_level ==
|
| + base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
|
| + sync_prefs_.SetMemoryPressure(sync_prefs_.GetMemoryPressure() + 1);
|
| + }
|
| +}
|
| +
|
| +void ProfileSyncService::CheckPreviousShutdownMemoryWarning() {
|
| + int warning_received = sync_prefs_.GetMemoryPressure();
|
| +
|
| + if (-1 != warning_received) {
|
| + // -1 means it is new client
|
| + if (sync_prefs_.IsPreviousCrashed()) {
|
| + UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCrash",
|
| + warning_received);
|
| + } else {
|
| + UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningwithoutCrash",
|
| + warning_received);
|
| + }
|
| + }
|
| + sync_prefs_.SetMemoryPressure(0);
|
| + sync_prefs_.SetCurrentShutdown(true);
|
| +}
|
|
|