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..f3a5b7a30a24d368e3db1ca481cd9a1b1332ea29 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(); |
| + |
| + ReportPreviousSessionMemoryWarningCount(); |
| } |
| void ProfileSyncService::OnGetTokenSuccess( |
| @@ -912,6 +916,9 @@ void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) { |
| UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); |
| NotifyObservers(); |
| + |
| + // Mark this shutdown cleanly(without crash). |
|
stanisc
2015/05/15 23:11:04
How about this: mark this as a clean shutdown.
Gang Wu
2015/05/15 23:21:41
Done.
|
| + sync_prefs_.SetCleanShutdown(true); |
| } |
| void ProfileSyncService::DisableForUser() { |
| @@ -2720,3 +2727,31 @@ 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::ReportPreviousSessionMemoryWarningCount() { |
| + int warning_received = sync_prefs_.GetMemoryPressureWarningCount(); |
| + |
| + if (-1 != warning_received) { |
| + // -1 means it is new client. |
| + if (!sync_prefs_.DidSyncShutdownCleanly()) { |
| + UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeUncleanShutdown", |
| + warning_received); |
| + } else { |
| + UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", |
| + warning_received); |
| + } |
| + } |
| + sync_prefs_.SetMemoryPressureWarningCount(0); |
| + // Will to true during a clean shutdown, so crash or something elase will |
|
stanisc
2015/05/15 23:11:04
There are still a couple of typos here. Please rev
Gang Wu
2015/05/15 23:21:41
Done.
|
| + // remain this as false. |
| + sync_prefs_.SetCleanShutdown(false); |
| +} |