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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 else | 116 else |
117 uma_proto_.set_client_id(Hash(client_id)); | 117 uma_proto_.set_client_id(Hash(client_id)); |
118 | 118 |
119 uma_proto_.set_session_id(session_id); | 119 uma_proto_.set_session_id(session_id); |
120 | 120 |
121 const int32_t product = client_->GetProduct(); | 121 const int32_t product = client_->GetProduct(); |
122 // Only set the product if it differs from the default value. | 122 // Only set the product if it differs from the default value. |
123 if (product != uma_proto_.product()) | 123 if (product != uma_proto_.product()) |
124 uma_proto_.set_product(product); | 124 uma_proto_.set_product(product); |
125 | 125 |
126 RecordCoreSystemProfile(client_, uma_proto_.mutable_system_profile()); | 126 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 127 RecordCoreSystemProfile(client_, system_profile); |
| 128 if (log_type_ == ONGOING_LOG) { |
| 129 GlobalPersistentSystemProfile::GetInstance()->SetSystemProfile( |
| 130 *system_profile, /*complete=*/false); |
| 131 } |
127 } | 132 } |
128 | 133 |
129 MetricsLog::~MetricsLog() { | 134 MetricsLog::~MetricsLog() { |
130 } | 135 } |
131 | 136 |
132 // static | 137 // static |
133 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { | 138 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { |
134 EnvironmentRecorder::RegisterPrefs(registry); | 139 EnvironmentRecorder::RegisterPrefs(registry); |
135 } | 140 } |
136 | 141 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 WriteFieldTrials(field_trial_ids, system_profile); | 336 WriteFieldTrials(field_trial_ids, system_profile); |
332 WriteFieldTrials(synthetic_trials, system_profile); | 337 WriteFieldTrials(synthetic_trials, system_profile); |
333 | 338 |
334 for (size_t i = 0; i < metrics_providers.size(); ++i) | 339 for (size_t i = 0; i < metrics_providers.size(); ++i) |
335 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); | 340 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); |
336 | 341 |
337 EnvironmentRecorder recorder(local_state_); | 342 EnvironmentRecorder recorder(local_state_); |
338 std::string serialized_proto = | 343 std::string serialized_proto = |
339 recorder.SerializeAndRecordEnvironmentToPrefs(*system_profile); | 344 recorder.SerializeAndRecordEnvironmentToPrefs(*system_profile); |
340 | 345 |
341 GlobalPersistentSystemProfile::GetInstance()->SetSystemProfile( | 346 if (log_type_ == ONGOING_LOG) { |
342 serialized_proto); | 347 GlobalPersistentSystemProfile::GetInstance()->SetSystemProfile( |
| 348 serialized_proto, /*complete=*/true); |
| 349 } |
343 | 350 |
344 return serialized_proto; | 351 return serialized_proto; |
345 } | 352 } |
346 | 353 |
347 bool MetricsLog::LoadIndependentMetrics(MetricsProvider* metrics_provider) { | 354 bool MetricsLog::LoadIndependentMetrics(MetricsProvider* metrics_provider) { |
348 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 355 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
349 IndependentFlattener flattener(this); | 356 IndependentFlattener flattener(this); |
350 base::HistogramSnapshotManager snapshot_manager(&flattener); | 357 base::HistogramSnapshotManager snapshot_manager(&flattener); |
351 | 358 |
352 return metrics_provider->ProvideIndependentMetrics(system_profile, | 359 return metrics_provider->ProvideIndependentMetrics(system_profile, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 uma_proto_.omnibox_event_size() - internal::kOmniboxEventLimit); | 395 uma_proto_.omnibox_event_size() - internal::kOmniboxEventLimit); |
389 } | 396 } |
390 } | 397 } |
391 | 398 |
392 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 399 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
393 DCHECK(closed_); | 400 DCHECK(closed_); |
394 uma_proto_.SerializeToString(encoded_log); | 401 uma_proto_.SerializeToString(encoded_log); |
395 } | 402 } |
396 | 403 |
397 } // namespace metrics | 404 } // namespace metrics |
OLD | NEW |