Chromium Code Reviews| 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..b04886ddbb5124836f6ba3647a659df4df74539a 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(); |
| + |
| + RecordPreviousShutdownMemoryWarning(); |
| } |
| void ProfileSyncService::OnGetTokenSuccess( |
| @@ -912,6 +916,9 @@ void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) { |
| UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); |
| NotifyObservers(); |
| + |
| + // Mark this dhutdown cleanly(without crash). |
|
stanisc
2015/05/15 22:06:48
Typo: dhutdown
Gang Wu
2015/05/15 22:22:30
Done.
|
| + sync_prefs_.SetCurrentShutdownCleanly(true); |
| } |
| void ProfileSyncService::DisableForUser() { |
| @@ -2720,3 +2727,29 @@ 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_.SetMemoryPressureWarningCount( |
| + sync_prefs_.GetMemoryPressureWarningCount() + 1); |
| + } |
| +} |
| + |
| +void ProfileSyncService::RecordPreviousShutdownMemoryWarning() { |
|
stanisc
2015/05/15 22:06:48
How about this name: ReportPreviousSessionMemoryWa
Gang Wu
2015/05/15 22:22:30
Done.
|
| + int warning_received = sync_prefs_.GetMemoryPressureWarningCount(); |
| + |
| + if (-1 != warning_received) { |
| + // -1 means it is new client. |
| + if (!sync_prefs_.IsPreviousShutdownCleanly()) { |
| + UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCrash", |
| + warning_received); |
| + } else { |
| + UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningWithoutCrash", |
| + warning_received); |
| + } |
| + } |
| + sync_prefs_.SetMemoryPressureWarningCount(0); |
| + sync_prefs_.SetCurrentShutdownCleanly(false); |
|
stanisc
2015/05/15 22:06:48
Add a comment explaining that this would be set to
Gang Wu
2015/05/15 22:22:30
Done.
|
| +} |