| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/metrics/metrics_log.h" | 5 #include "components/metrics/metrics_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Returns the date at which the current metrics client ID was created as | 57 // Returns the date at which the current metrics client ID was created as |
| 58 // a string containing seconds since the epoch, or "0" if none was found. | 58 // a string containing seconds since the epoch, or "0" if none was found. |
| 59 std::string GetMetricsEnabledDate(PrefService* pref) { | 59 std::string GetMetricsEnabledDate(PrefService* pref) { |
| 60 if (!pref) { | 60 if (!pref) { |
| 61 NOTREACHED(); | 61 NOTREACHED(); |
| 62 return "0"; | 62 return "0"; |
| 63 } | 63 } |
| 64 | 64 |
| 65 return pref->GetString(metrics::prefs::kMetricsReportingEnabledTimestamp); | 65 return pref->GetString(prefs::kMetricsReportingEnabledTimestamp); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Computes a SHA-1 hash of |data| and returns it as a hex string. | 68 // Computes a SHA-1 hash of |data| and returns it as a hex string. |
| 69 std::string ComputeSHA1(const std::string& data) { | 69 std::string ComputeSHA1(const std::string& data) { |
| 70 const std::string sha1 = base::SHA1HashString(data); | 70 const std::string sha1 = base::SHA1HashString(data); |
| 71 return base::HexEncode(sha1.data(), sha1.size()); | 71 return base::HexEncode(sha1.data(), sha1.size()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids, | 74 void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids, |
| 75 SystemProfileProto* system_profile) { | 75 SystemProfileProto* system_profile) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 // timestamps. | 87 // timestamps. |
| 88 int64 RoundSecondsToHour(int64 time_in_seconds) { | 88 int64 RoundSecondsToHour(int64 time_in_seconds) { |
| 89 return 3600 * (time_in_seconds / 3600); | 89 return 3600 * (time_in_seconds / 3600); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace | 92 } // namespace |
| 93 | 93 |
| 94 MetricsLog::MetricsLog(const std::string& client_id, | 94 MetricsLog::MetricsLog(const std::string& client_id, |
| 95 int session_id, | 95 int session_id, |
| 96 LogType log_type, | 96 LogType log_type, |
| 97 metrics::MetricsServiceClient* client, | 97 MetricsServiceClient* client, |
| 98 PrefService* local_state) | 98 PrefService* local_state) |
| 99 : closed_(false), | 99 : closed_(false), |
| 100 log_type_(log_type), | 100 log_type_(log_type), |
| 101 client_(client), | 101 client_(client), |
| 102 creation_time_(base::TimeTicks::Now()), | 102 creation_time_(base::TimeTicks::Now()), |
| 103 local_state_(local_state) { | 103 local_state_(local_state) { |
| 104 if (IsTestingID(client_id)) | 104 if (IsTestingID(client_id)) |
| 105 uma_proto_.set_client_id(0); | 105 uma_proto_.set_client_id(0); |
| 106 else | 106 else |
| 107 uma_proto_.set_client_id(Hash(client_id)); | 107 uma_proto_.set_client_id(Hash(client_id)); |
| 108 | 108 |
| 109 uma_proto_.set_session_id(session_id); | 109 uma_proto_.set_session_id(session_id); |
| 110 | 110 |
| 111 const int32 product = client_->GetProduct(); |
| 112 // Only set the product if it differs from the default value. |
| 113 if (product != uma_proto_.product()) |
| 114 uma_proto_.set_product(product); |
| 115 |
| 111 SystemProfileProto* system_profile = uma_proto_.mutable_system_profile(); | 116 SystemProfileProto* system_profile = uma_proto_.mutable_system_profile(); |
| 112 system_profile->set_build_timestamp(GetBuildTime()); | 117 system_profile->set_build_timestamp(GetBuildTime()); |
| 113 system_profile->set_app_version(client_->GetVersionString()); | 118 system_profile->set_app_version(client_->GetVersionString()); |
| 114 system_profile->set_channel(client_->GetChannel()); | 119 system_profile->set_channel(client_->GetChannel()); |
| 115 } | 120 } |
| 116 | 121 |
| 117 MetricsLog::~MetricsLog() { | 122 MetricsLog::~MetricsLog() { |
| 118 } | 123 } |
| 119 | 124 |
| 120 // static | 125 // static |
| 121 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { | 126 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { |
| 122 registry->RegisterIntegerPref(metrics::prefs::kStabilityLaunchCount, 0); | 127 registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
| 123 registry->RegisterIntegerPref(metrics::prefs::kStabilityCrashCount, 0); | 128 registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); |
| 129 registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0); |
| 130 registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0); |
| 124 registry->RegisterIntegerPref( | 131 registry->RegisterIntegerPref( |
| 125 metrics::prefs::kStabilityIncompleteSessionEndCount, 0); | 132 prefs::kStabilityBreakpadRegistrationSuccess, 0); |
| 126 registry->RegisterIntegerPref( | 133 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); |
| 127 metrics::prefs::kStabilityBreakpadRegistrationFail, 0); | 134 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); |
| 128 registry->RegisterIntegerPref( | 135 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, |
| 129 metrics::prefs::kStabilityBreakpadRegistrationSuccess, 0); | |
| 130 registry->RegisterIntegerPref(metrics::prefs::kStabilityDebuggerPresent, 0); | |
| 131 registry->RegisterIntegerPref(metrics::prefs::kStabilityDebuggerNotPresent, | |
| 132 0); | |
| 133 registry->RegisterStringPref(metrics::prefs::kStabilitySavedSystemProfile, | |
| 134 std::string()); | 136 std::string()); |
| 135 registry->RegisterStringPref(metrics::prefs::kStabilitySavedSystemProfileHash, | 137 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, |
| 136 std::string()); | 138 std::string()); |
| 137 } | 139 } |
| 138 | 140 |
| 139 // static | 141 // static |
| 140 uint64 MetricsLog::Hash(const std::string& value) { | 142 uint64 MetricsLog::Hash(const std::string& value) { |
| 141 uint64 hash = metrics::HashMetricName(value); | 143 uint64 hash = HashMetricName(value); |
| 142 | 144 |
| 143 // The following log is VERY helpful when folks add some named histogram into | 145 // The following log is VERY helpful when folks add some named histogram into |
| 144 // the code, but forgot to update the descriptive list of histograms. When | 146 // the code, but forgot to update the descriptive list of histograms. When |
| 145 // that happens, all we get to see (server side) is a hash of the histogram | 147 // that happens, all we get to see (server side) is a hash of the histogram |
| 146 // name. We can then use this logging to find out what histogram name was | 148 // name. We can then use this logging to find out what histogram name was |
| 147 // being hashed to a given MD5 value by just running the version of Chromium | 149 // being hashed to a given MD5 value by just running the version of Chromium |
| 148 // in question with --enable-logging. | 150 // in question with --enable-logging. |
| 149 DVLOG(1) << "Metrics: Hash numeric [" << value << "]=[" << hash << "]"; | 151 DVLOG(1) << "Metrics: Hash numeric [" << value << "]=[" << hash << "]"; |
| 150 | 152 |
| 151 return hash; | 153 return hash; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 if (i + 1 < histogram_proto->bucket_size() && | 208 if (i + 1 < histogram_proto->bucket_size() && |
| 207 bucket->max() == histogram_proto->bucket(i + 1).min()) { | 209 bucket->max() == histogram_proto->bucket(i + 1).min()) { |
| 208 bucket->clear_max(); | 210 bucket->clear_max(); |
| 209 } else if (bucket->max() == bucket->min() + 1) { | 211 } else if (bucket->max() == bucket->min() + 1) { |
| 210 bucket->clear_min(); | 212 bucket->clear_min(); |
| 211 } | 213 } |
| 212 } | 214 } |
| 213 } | 215 } |
| 214 | 216 |
| 215 void MetricsLog::RecordStabilityMetrics( | 217 void MetricsLog::RecordStabilityMetrics( |
| 216 const std::vector<metrics::MetricsProvider*>& metrics_providers, | 218 const std::vector<MetricsProvider*>& metrics_providers, |
| 217 base::TimeDelta incremental_uptime, | 219 base::TimeDelta incremental_uptime, |
| 218 base::TimeDelta uptime) { | 220 base::TimeDelta uptime) { |
| 219 DCHECK(!closed_); | 221 DCHECK(!closed_); |
| 220 DCHECK(HasEnvironment()); | 222 DCHECK(HasEnvironment()); |
| 221 DCHECK(!HasStabilityMetrics()); | 223 DCHECK(!HasStabilityMetrics()); |
| 222 | 224 |
| 223 PrefService* pref = local_state_; | 225 PrefService* pref = local_state_; |
| 224 DCHECK(pref); | 226 DCHECK(pref); |
| 225 | 227 |
| 226 // Get stability attributes out of Local State, zeroing out stored values. | 228 // Get stability attributes out of Local State, zeroing out stored values. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 237 | 239 |
| 238 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 240 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 239 for (size_t i = 0; i < metrics_providers.size(); ++i) | 241 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 240 metrics_providers[i]->ProvideStabilityMetrics(system_profile); | 242 metrics_providers[i]->ProvideStabilityMetrics(system_profile); |
| 241 | 243 |
| 242 // Omit some stats unless this is the initial stability log. | 244 // Omit some stats unless this is the initial stability log. |
| 243 if (log_type() != INITIAL_STABILITY_LOG) | 245 if (log_type() != INITIAL_STABILITY_LOG) |
| 244 return; | 246 return; |
| 245 | 247 |
| 246 int incomplete_shutdown_count = | 248 int incomplete_shutdown_count = |
| 247 pref->GetInteger(metrics::prefs::kStabilityIncompleteSessionEndCount); | 249 pref->GetInteger(prefs::kStabilityIncompleteSessionEndCount); |
| 248 pref->SetInteger(metrics::prefs::kStabilityIncompleteSessionEndCount, 0); | 250 pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); |
| 249 int breakpad_registration_success_count = | 251 int breakpad_registration_success_count = |
| 250 pref->GetInteger(metrics::prefs::kStabilityBreakpadRegistrationSuccess); | 252 pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess); |
| 251 pref->SetInteger(metrics::prefs::kStabilityBreakpadRegistrationSuccess, 0); | 253 pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); |
| 252 int breakpad_registration_failure_count = | 254 int breakpad_registration_failure_count = |
| 253 pref->GetInteger(metrics::prefs::kStabilityBreakpadRegistrationFail); | 255 pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail); |
| 254 pref->SetInteger(metrics::prefs::kStabilityBreakpadRegistrationFail, 0); | 256 pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); |
| 255 int debugger_present_count = | 257 int debugger_present_count = |
| 256 pref->GetInteger(metrics::prefs::kStabilityDebuggerPresent); | 258 pref->GetInteger(prefs::kStabilityDebuggerPresent); |
| 257 pref->SetInteger(metrics::prefs::kStabilityDebuggerPresent, 0); | 259 pref->SetInteger(prefs::kStabilityDebuggerPresent, 0); |
| 258 int debugger_not_present_count = | 260 int debugger_not_present_count = |
| 259 pref->GetInteger(metrics::prefs::kStabilityDebuggerNotPresent); | 261 pref->GetInteger(prefs::kStabilityDebuggerNotPresent); |
| 260 pref->SetInteger(metrics::prefs::kStabilityDebuggerNotPresent, 0); | 262 pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); |
| 261 | 263 |
| 262 // TODO(jar): The following are all optional, so we *could* optimize them for | 264 // TODO(jar): The following are all optional, so we *could* optimize them for |
| 263 // values of zero (and not include them). | 265 // values of zero (and not include them). |
| 264 SystemProfileProto::Stability* stability = | 266 SystemProfileProto::Stability* stability = |
| 265 system_profile->mutable_stability(); | 267 system_profile->mutable_stability(); |
| 266 stability->set_incomplete_shutdown_count(incomplete_shutdown_count); | 268 stability->set_incomplete_shutdown_count(incomplete_shutdown_count); |
| 267 stability->set_breakpad_registration_success_count( | 269 stability->set_breakpad_registration_success_count( |
| 268 breakpad_registration_success_count); | 270 breakpad_registration_success_count); |
| 269 stability->set_breakpad_registration_failure_count( | 271 stability->set_breakpad_registration_failure_count( |
| 270 breakpad_registration_failure_count); | 272 breakpad_registration_failure_count); |
| 271 stability->set_debugger_present_count(debugger_present_count); | 273 stability->set_debugger_present_count(debugger_present_count); |
| 272 stability->set_debugger_not_present_count(debugger_not_present_count); | 274 stability->set_debugger_not_present_count(debugger_not_present_count); |
| 273 } | 275 } |
| 274 | 276 |
| 275 void MetricsLog::RecordGeneralMetrics( | 277 void MetricsLog::RecordGeneralMetrics( |
| 276 const std::vector<metrics::MetricsProvider*>& metrics_providers) { | 278 const std::vector<MetricsProvider*>& metrics_providers) { |
| 277 for (size_t i = 0; i < metrics_providers.size(); ++i) | 279 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 278 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); | 280 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); |
| 279 } | 281 } |
| 280 | 282 |
| 281 void MetricsLog::GetFieldTrialIds( | 283 void MetricsLog::GetFieldTrialIds( |
| 282 std::vector<ActiveGroupId>* field_trial_ids) const { | 284 std::vector<ActiveGroupId>* field_trial_ids) const { |
| 283 variations::GetFieldTrialActiveGroupIds(field_trial_ids); | 285 variations::GetFieldTrialActiveGroupIds(field_trial_ids); |
| 284 } | 286 } |
| 285 | 287 |
| 286 bool MetricsLog::HasEnvironment() const { | 288 bool MetricsLog::HasEnvironment() const { |
| 287 return uma_proto()->system_profile().has_uma_enabled_date(); | 289 return uma_proto()->system_profile().has_uma_enabled_date(); |
| 288 } | 290 } |
| 289 | 291 |
| 290 bool MetricsLog::HasStabilityMetrics() const { | 292 bool MetricsLog::HasStabilityMetrics() const { |
| 291 return uma_proto()->system_profile().stability().has_launch_count(); | 293 return uma_proto()->system_profile().stability().has_launch_count(); |
| 292 } | 294 } |
| 293 | 295 |
| 294 // The server refuses data that doesn't have certain values. crashcount and | 296 // The server refuses data that doesn't have certain values. crashcount and |
| 295 // launchcount are currently "required" in the "stability" group. | 297 // launchcount are currently "required" in the "stability" group. |
| 296 // TODO(isherman): Stop writing these attributes specially once the migration to | 298 // TODO(isherman): Stop writing these attributes specially once the migration to |
| 297 // protobufs is complete. | 299 // protobufs is complete. |
| 298 void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) { | 300 void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) { |
| 299 int launch_count = pref->GetInteger(metrics::prefs::kStabilityLaunchCount); | 301 int launch_count = pref->GetInteger(prefs::kStabilityLaunchCount); |
| 300 pref->SetInteger(metrics::prefs::kStabilityLaunchCount, 0); | 302 pref->SetInteger(prefs::kStabilityLaunchCount, 0); |
| 301 int crash_count = pref->GetInteger(metrics::prefs::kStabilityCrashCount); | 303 int crash_count = pref->GetInteger(prefs::kStabilityCrashCount); |
| 302 pref->SetInteger(metrics::prefs::kStabilityCrashCount, 0); | 304 pref->SetInteger(prefs::kStabilityCrashCount, 0); |
| 303 | 305 |
| 304 SystemProfileProto::Stability* stability = | 306 SystemProfileProto::Stability* stability = |
| 305 uma_proto()->mutable_system_profile()->mutable_stability(); | 307 uma_proto()->mutable_system_profile()->mutable_stability(); |
| 306 stability->set_launch_count(launch_count); | 308 stability->set_launch_count(launch_count); |
| 307 stability->set_crash_count(crash_count); | 309 stability->set_crash_count(crash_count); |
| 308 } | 310 } |
| 309 | 311 |
| 310 void MetricsLog::WriteRealtimeStabilityAttributes( | 312 void MetricsLog::WriteRealtimeStabilityAttributes( |
| 311 PrefService* pref, | 313 PrefService* pref, |
| 312 base::TimeDelta incremental_uptime, | 314 base::TimeDelta incremental_uptime, |
| 313 base::TimeDelta uptime) { | 315 base::TimeDelta uptime) { |
| 314 // Update the stats which are critical for real-time stability monitoring. | 316 // Update the stats which are critical for real-time stability monitoring. |
| 315 // Since these are "optional," only list ones that are non-zero, as the counts | 317 // Since these are "optional," only list ones that are non-zero, as the counts |
| 316 // are aggregated (summed) server side. | 318 // are aggregated (summed) server side. |
| 317 | 319 |
| 318 SystemProfileProto::Stability* stability = | 320 SystemProfileProto::Stability* stability = |
| 319 uma_proto()->mutable_system_profile()->mutable_stability(); | 321 uma_proto()->mutable_system_profile()->mutable_stability(); |
| 320 | 322 |
| 321 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); | 323 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); |
| 322 if (incremental_uptime_sec) | 324 if (incremental_uptime_sec) |
| 323 stability->set_incremental_uptime_sec(incremental_uptime_sec); | 325 stability->set_incremental_uptime_sec(incremental_uptime_sec); |
| 324 const uint64 uptime_sec = uptime.InSeconds(); | 326 const uint64 uptime_sec = uptime.InSeconds(); |
| 325 if (uptime_sec) | 327 if (uptime_sec) |
| 326 stability->set_uptime_sec(uptime_sec); | 328 stability->set_uptime_sec(uptime_sec); |
| 327 } | 329 } |
| 328 | 330 |
| 329 void MetricsLog::RecordEnvironment( | 331 void MetricsLog::RecordEnvironment( |
| 330 const std::vector<metrics::MetricsProvider*>& metrics_providers, | 332 const std::vector<MetricsProvider*>& metrics_providers, |
| 331 const std::vector<variations::ActiveGroupId>& synthetic_trials, | 333 const std::vector<variations::ActiveGroupId>& synthetic_trials, |
| 332 int64 install_date) { | 334 int64 install_date) { |
| 333 DCHECK(!HasEnvironment()); | 335 DCHECK(!HasEnvironment()); |
| 334 | 336 |
| 335 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 337 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 336 | 338 |
| 337 std::string brand_code; | 339 std::string brand_code; |
| 338 if (client_->GetBrand(&brand_code)) | 340 if (client_->GetBrand(&brand_code)) |
| 339 system_profile->set_brand_code(brand_code); | 341 system_profile->set_brand_code(brand_code); |
| 340 | 342 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 WriteFieldTrials(synthetic_trials, system_profile); | 393 WriteFieldTrials(synthetic_trials, system_profile); |
| 392 | 394 |
| 393 for (size_t i = 0; i < metrics_providers.size(); ++i) | 395 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 394 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); | 396 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); |
| 395 | 397 |
| 396 std::string serialied_system_profile; | 398 std::string serialied_system_profile; |
| 397 std::string base64_system_profile; | 399 std::string base64_system_profile; |
| 398 if (system_profile->SerializeToString(&serialied_system_profile)) { | 400 if (system_profile->SerializeToString(&serialied_system_profile)) { |
| 399 base::Base64Encode(serialied_system_profile, &base64_system_profile); | 401 base::Base64Encode(serialied_system_profile, &base64_system_profile); |
| 400 PrefService* local_state = local_state_; | 402 PrefService* local_state = local_state_; |
| 401 local_state->SetString(metrics::prefs::kStabilitySavedSystemProfile, | 403 local_state->SetString(prefs::kStabilitySavedSystemProfile, |
| 402 base64_system_profile); | 404 base64_system_profile); |
| 403 local_state->SetString(metrics::prefs::kStabilitySavedSystemProfileHash, | 405 local_state->SetString(prefs::kStabilitySavedSystemProfileHash, |
| 404 ComputeSHA1(serialied_system_profile)); | 406 ComputeSHA1(serialied_system_profile)); |
| 405 } | 407 } |
| 406 } | 408 } |
| 407 | 409 |
| 408 bool MetricsLog::LoadSavedEnvironmentFromPrefs() { | 410 bool MetricsLog::LoadSavedEnvironmentFromPrefs() { |
| 409 PrefService* local_state = local_state_; | 411 PrefService* local_state = local_state_; |
| 410 const std::string base64_system_profile = | 412 const std::string base64_system_profile = |
| 411 local_state->GetString(metrics::prefs::kStabilitySavedSystemProfile); | 413 local_state->GetString(prefs::kStabilitySavedSystemProfile); |
| 412 if (base64_system_profile.empty()) | 414 if (base64_system_profile.empty()) |
| 413 return false; | 415 return false; |
| 414 | 416 |
| 415 const std::string system_profile_hash = | 417 const std::string system_profile_hash = |
| 416 local_state->GetString(metrics::prefs::kStabilitySavedSystemProfileHash); | 418 local_state->GetString(prefs::kStabilitySavedSystemProfileHash); |
| 417 local_state->ClearPref(metrics::prefs::kStabilitySavedSystemProfile); | 419 local_state->ClearPref(prefs::kStabilitySavedSystemProfile); |
| 418 local_state->ClearPref(metrics::prefs::kStabilitySavedSystemProfileHash); | 420 local_state->ClearPref(prefs::kStabilitySavedSystemProfileHash); |
| 419 | 421 |
| 420 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 422 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 421 std::string serialied_system_profile; | 423 std::string serialied_system_profile; |
| 422 return base::Base64Decode(base64_system_profile, &serialied_system_profile) && | 424 return base::Base64Decode(base64_system_profile, &serialied_system_profile) && |
| 423 ComputeSHA1(serialied_system_profile) == system_profile_hash && | 425 ComputeSHA1(serialied_system_profile) == system_profile_hash && |
| 424 system_profile->ParseFromString(serialied_system_profile); | 426 system_profile->ParseFromString(serialied_system_profile); |
| 425 } | 427 } |
| 426 | 428 |
| 427 void MetricsLog::CloseLog() { | 429 void MetricsLog::CloseLog() { |
| 428 DCHECK(!closed_); | 430 DCHECK(!closed_); |
| 429 closed_ = true; | 431 closed_ = true; |
| 430 } | 432 } |
| 431 | 433 |
| 432 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 434 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
| 433 DCHECK(closed_); | 435 DCHECK(closed_); |
| 434 uma_proto_.SerializeToString(encoded_log); | 436 uma_proto_.SerializeToString(encoded_log); |
| 435 } | 437 } |
| 436 | 438 |
| 437 } // namespace metrics | 439 } // namespace metrics |
| OLD | NEW |