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

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

Issue 1136763004: Add UMA data for memory pressure warning received for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | 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 2ac3deed199641b1b73d1e363b6f6284ebfac33c..5f0bffdfe62fe01a6561b70f1de690c6068bc1a9 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 as a clean shutdown(without crash).
+ 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 set to true during a clean shutdown, so crash or something else will
+ // remain this as false.
+ sync_prefs_.SetCleanShutdown(false);
+}
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698