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

Unified Diff: components/metrics/metrics_log.cc

Issue 2294323002: Avoid some pref writes in MetricsLog. Ensure some stability metrics are cleared. (Closed)
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_log.cc
diff --git a/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
index 3d8cc1886a891d566bc3e42237c97ff41b385618..10bfcaef5bcc6aa03defabadd2b92834ed12edc6 100644
--- a/components/metrics/metrics_log.cc
+++ b/components/metrics/metrics_log.cc
@@ -207,32 +207,42 @@ void MetricsLog::RecordStabilityMetrics(
if (log_type() != INITIAL_STABILITY_LOG)
manzagop (departed) 2016/08/31 16:20:47 What is the reason for skipping these stats? Is it
Alexei Svitkine (slow) 2016/08/31 16:40:00 I think the logic was that it was not necessary to
manzagop (departed) 2016/08/31 19:26:52 Ok, removing. Won't cause a storage size increase
return;
+ SystemProfileProto::Stability* stability =
+ system_profile->mutable_stability();
+
+ // TODO(jar): The following are all optional in SystemProfileProto::Stability,
manzagop (departed) 2016/08/31 16:20:47 This todo is still valid because it's about not se
Alexei Svitkine (slow) 2016/08/31 16:40:00 No server-side change is needed, so the TODO can b
manzagop (departed) 2016/08/31 19:26:51 Great! Done.
+ // so we *could* optimize them for values of zero (and not include them).
+
int incomplete_shutdown_count =
pref->GetInteger(prefs::kStabilityIncompleteSessionEndCount);
- pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
+ if (incomplete_shutdown_count)
+ pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
+ stability->set_incomplete_shutdown_count(incomplete_shutdown_count);
+
int breakpad_registration_success_count =
manzagop (departed) 2016/08/31 16:20:47 These last 4 metrics are never cleared. Should the
Alexei Svitkine (slow) 2016/08/31 16:40:00 Yes, I think so. Although, I wonder if anyone eve
manzagop (departed) 2016/08/31 19:26:52 Not feeling comfortable making that call / do the
pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess);
- pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
+ if (breakpad_registration_success_count)
+ pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
+ stability->set_breakpad_registration_success_count(
+ breakpad_registration_success_count);
+
int breakpad_registration_failure_count =
pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail);
- pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
+ if (breakpad_registration_failure_count)
+ pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
+ stability->set_breakpad_registration_failure_count(
+ breakpad_registration_failure_count);
+
int debugger_present_count =
pref->GetInteger(prefs::kStabilityDebuggerPresent);
- pref->SetInteger(prefs::kStabilityDebuggerPresent, 0);
+ if (debugger_present_count)
+ pref->SetInteger(prefs::kStabilityDebuggerPresent, 0);
+ stability->set_debugger_present_count(debugger_present_count);
+
int debugger_not_present_count =
pref->GetInteger(prefs::kStabilityDebuggerNotPresent);
- pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
-
- // TODO(jar): The following are all optional, so we *could* optimize them for
- // values of zero (and not include them).
- SystemProfileProto::Stability* stability =
- system_profile->mutable_stability();
- stability->set_incomplete_shutdown_count(incomplete_shutdown_count);
- stability->set_breakpad_registration_success_count(
- breakpad_registration_success_count);
- stability->set_breakpad_registration_failure_count(
- breakpad_registration_failure_count);
- stability->set_debugger_present_count(debugger_present_count);
+ if (debugger_not_present_count)
+ pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
stability->set_debugger_not_present_count(debugger_not_present_count);
}
@@ -285,9 +295,11 @@ bool MetricsLog::HasStabilityMetrics() const {
// protobufs is complete.
void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
int launch_count = pref->GetInteger(prefs::kStabilityLaunchCount);
- pref->SetInteger(prefs::kStabilityLaunchCount, 0);
+ if (launch_count)
+ pref->SetInteger(prefs::kStabilityLaunchCount, 0);
int crash_count = pref->GetInteger(prefs::kStabilityCrashCount);
- pref->SetInteger(prefs::kStabilityCrashCount, 0);
+ if (crash_count)
+ pref->SetInteger(prefs::kStabilityCrashCount, 0);
SystemProfileProto::Stability* stability =
uma_proto()->mutable_system_profile()->mutable_stability();
@@ -379,15 +391,15 @@ void MetricsLog::RecordEnvironment(
for (size_t i = 0; i < metrics_providers.size(); ++i)
metrics_providers[i]->ProvideSystemProfileMetrics(system_profile);
- std::string serialied_system_profile;
+ std::string serialized_system_profile;
std::string base64_system_profile;
- if (system_profile->SerializeToString(&serialied_system_profile)) {
- base::Base64Encode(serialied_system_profile, &base64_system_profile);
+ if (system_profile->SerializeToString(&serialized_system_profile)) {
+ base::Base64Encode(serialized_system_profile, &base64_system_profile);
PrefService* local_state = local_state_;
local_state->SetString(prefs::kStabilitySavedSystemProfile,
base64_system_profile);
local_state->SetString(prefs::kStabilitySavedSystemProfileHash,
- ComputeSHA1(serialied_system_profile));
+ ComputeSHA1(serialized_system_profile));
}
}
@@ -404,10 +416,11 @@ bool MetricsLog::LoadSavedEnvironmentFromPrefs() {
local_state->ClearPref(prefs::kStabilitySavedSystemProfileHash);
SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
- std::string serialied_system_profile;
- return base::Base64Decode(base64_system_profile, &serialied_system_profile) &&
- ComputeSHA1(serialied_system_profile) == system_profile_hash &&
- system_profile->ParseFromString(serialied_system_profile);
+ std::string serialized_system_profile;
+ return base::Base64Decode(base64_system_profile,
+ &serialized_system_profile) &&
+ ComputeSHA1(serialized_system_profile) == system_profile_hash &&
+ system_profile->ParseFromString(serialized_system_profile);
}
void MetricsLog::CloseLog() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698