OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/metrics/metrics_log.h" | 5 #include "chrome/browser/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 |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/cpu.h" | 14 #include "base/cpu.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
18 #include "base/profiler/alternate_timer.h" | 18 #include "base/profiler/alternate_timer.h" |
19 #include "base/sha1.h" | 19 #include "base/sha1.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
24 #include "base/third_party/nspr/prtime.h" | 24 #include "base/third_party/nspr/prtime.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "base/tracked_objects.h" | 26 #include "base/tracked_objects.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/metrics/extension_metrics.h" | |
29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
30 #include "components/metrics/metrics_provider.h" | 29 #include "components/metrics/metrics_provider.h" |
31 #include "components/metrics/metrics_service_client.h" | 30 #include "components/metrics/metrics_service_client.h" |
32 #include "components/metrics/proto/profiler_event.pb.h" | 31 #include "components/metrics/proto/profiler_event.pb.h" |
33 #include "components/metrics/proto/system_profile.pb.h" | 32 #include "components/metrics/proto/system_profile.pb.h" |
34 #include "components/nacl/common/nacl_process_type.h" | 33 #include "components/nacl/common/nacl_process_type.h" |
35 #include "components/variations/active_field_trials.h" | 34 #include "components/variations/active_field_trials.h" |
36 #include "content/public/common/content_client.h" | 35 #include "content/public/common/content_client.h" |
37 #include "url/gurl.h" | 36 #include "url/gurl.h" |
38 | 37 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 184 |
186 MetricsLog::MetricsLog(const std::string& client_id, | 185 MetricsLog::MetricsLog(const std::string& client_id, |
187 int session_id, | 186 int session_id, |
188 LogType log_type, | 187 LogType log_type, |
189 metrics::MetricsServiceClient* client) | 188 metrics::MetricsServiceClient* client) |
190 : MetricsLogBase(client_id, | 189 : MetricsLogBase(client_id, |
191 session_id, | 190 session_id, |
192 log_type, | 191 log_type, |
193 client->GetVersionString()), | 192 client->GetVersionString()), |
194 client_(client), | 193 client_(client), |
195 creation_time_(base::TimeTicks::Now()), | 194 creation_time_(base::TimeTicks::Now()) { |
196 extension_metrics_(uma_proto()->client_id()) { | |
197 uma_proto()->mutable_system_profile()->set_channel(client_->GetChannel()); | 195 uma_proto()->mutable_system_profile()->set_channel(client_->GetChannel()); |
198 | 196 |
199 #if defined(OS_CHROMEOS) | 197 #if defined(OS_CHROMEOS) |
200 metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); | 198 metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); |
201 #endif // OS_CHROMEOS | 199 #endif // OS_CHROMEOS |
202 } | 200 } |
203 | 201 |
204 MetricsLog::~MetricsLog() {} | 202 MetricsLog::~MetricsLog() {} |
205 | 203 |
206 void MetricsLog::RecordStabilityMetrics( | 204 void MetricsLog::RecordStabilityMetrics( |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 #if defined(OS_ANDROID) | 378 #if defined(OS_ANDROID) |
381 os->set_fingerprint( | 379 os->set_fingerprint( |
382 base::android::BuildInfo::GetInstance()->android_build_fp()); | 380 base::android::BuildInfo::GetInstance()->android_build_fp()); |
383 #endif | 381 #endif |
384 | 382 |
385 base::CPU cpu_info; | 383 base::CPU cpu_info; |
386 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); | 384 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); |
387 cpu->set_vendor_name(cpu_info.vendor_name()); | 385 cpu->set_vendor_name(cpu_info.vendor_name()); |
388 cpu->set_signature(cpu_info.signature()); | 386 cpu->set_signature(cpu_info.signature()); |
389 | 387 |
390 extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile()); | |
391 | |
392 std::vector<ActiveGroupId> field_trial_ids; | 388 std::vector<ActiveGroupId> field_trial_ids; |
393 GetFieldTrialIds(&field_trial_ids); | 389 GetFieldTrialIds(&field_trial_ids); |
394 WriteFieldTrials(field_trial_ids, system_profile); | 390 WriteFieldTrials(field_trial_ids, system_profile); |
395 WriteFieldTrials(synthetic_trials, system_profile); | 391 WriteFieldTrials(synthetic_trials, system_profile); |
396 | 392 |
397 #if defined(OS_CHROMEOS) | 393 #if defined(OS_CHROMEOS) |
398 metrics_log_chromeos_->LogChromeOSMetrics(); | 394 metrics_log_chromeos_->LogChromeOSMetrics(); |
399 #endif // OS_CHROMEOS | 395 #endif // OS_CHROMEOS |
400 | 396 |
401 for (size_t i = 0; i < metrics_providers.size(); ++i) | 397 for (size_t i = 0; i < metrics_providers.size(); ++i) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 profile = uma_proto()->add_profiler_event(); | 445 profile = uma_proto()->add_profiler_event(); |
450 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); | 446 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); |
451 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); | 447 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); |
452 } else { | 448 } else { |
453 // For the remaining calls, re-use the existing field. | 449 // For the remaining calls, re-use the existing field. |
454 profile = uma_proto()->mutable_profiler_event(0); | 450 profile = uma_proto()->mutable_profiler_event(0); |
455 } | 451 } |
456 | 452 |
457 WriteProfilerData(process_data, process_type, profile); | 453 WriteProfilerData(process_data, process_type, profile); |
458 } | 454 } |
OLD | NEW |