| 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 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "base/android/build_info.h" | 39 #include "base/android/build_info.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 #include "base/win/metro.h" | 43 #include "base/win/metro.h" |
| 44 | 44 |
| 45 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 45 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
| 46 extern "C" IMAGE_DOS_HEADER __ImageBase; | 46 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #if defined(OS_CHROMEOS) | |
| 50 #include "chrome/browser/metrics/metrics_log_chromeos.h" | |
| 51 #endif // OS_CHROMEOS | |
| 52 | |
| 53 using metrics::MetricsLogBase; | 49 using metrics::MetricsLogBase; |
| 54 using metrics::ProfilerEventProto; | 50 using metrics::ProfilerEventProto; |
| 55 using metrics::SystemProfileProto; | 51 using metrics::SystemProfileProto; |
| 56 using tracked_objects::ProcessDataSnapshot; | 52 using tracked_objects::ProcessDataSnapshot; |
| 57 typedef variations::ActiveGroupId ActiveGroupId; | 53 typedef variations::ActiveGroupId ActiveGroupId; |
| 58 | 54 |
| 59 namespace { | 55 namespace { |
| 60 | 56 |
| 61 // 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 |
| 62 // 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. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 int session_id, | 182 int session_id, |
| 187 LogType log_type, | 183 LogType log_type, |
| 188 metrics::MetricsServiceClient* client) | 184 metrics::MetricsServiceClient* client) |
| 189 : MetricsLogBase(client_id, | 185 : MetricsLogBase(client_id, |
| 190 session_id, | 186 session_id, |
| 191 log_type, | 187 log_type, |
| 192 client->GetVersionString()), | 188 client->GetVersionString()), |
| 193 client_(client), | 189 client_(client), |
| 194 creation_time_(base::TimeTicks::Now()) { | 190 creation_time_(base::TimeTicks::Now()) { |
| 195 uma_proto()->mutable_system_profile()->set_channel(client_->GetChannel()); | 191 uma_proto()->mutable_system_profile()->set_channel(client_->GetChannel()); |
| 196 | |
| 197 #if defined(OS_CHROMEOS) | |
| 198 metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); | |
| 199 #endif // OS_CHROMEOS | |
| 200 } | 192 } |
| 201 | 193 |
| 202 MetricsLog::~MetricsLog() {} | 194 MetricsLog::~MetricsLog() {} |
| 203 | 195 |
| 204 void MetricsLog::RecordStabilityMetrics( | 196 void MetricsLog::RecordStabilityMetrics( |
| 205 const std::vector<metrics::MetricsProvider*>& metrics_providers, | 197 const std::vector<metrics::MetricsProvider*>& metrics_providers, |
| 206 base::TimeDelta incremental_uptime, | 198 base::TimeDelta incremental_uptime, |
| 207 base::TimeDelta uptime) { | 199 base::TimeDelta uptime) { |
| 208 DCHECK(!locked()); | 200 DCHECK(!locked()); |
| 209 DCHECK(HasEnvironment()); | 201 DCHECK(HasEnvironment()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 302 |
| 311 SystemProfileProto::Stability* stability = | 303 SystemProfileProto::Stability* stability = |
| 312 uma_proto()->mutable_system_profile()->mutable_stability(); | 304 uma_proto()->mutable_system_profile()->mutable_stability(); |
| 313 | 305 |
| 314 int count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); | 306 int count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); |
| 315 if (count) { | 307 if (count) { |
| 316 stability->set_child_process_crash_count(count); | 308 stability->set_child_process_crash_count(count); |
| 317 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); | 309 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); |
| 318 } | 310 } |
| 319 | 311 |
| 320 #if defined(OS_CHROMEOS) | |
| 321 metrics_log_chromeos_->WriteRealtimeStabilityAttributes(pref); | |
| 322 #endif // OS_CHROMEOS | |
| 323 | |
| 324 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); | 312 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); |
| 325 if (incremental_uptime_sec) | 313 if (incremental_uptime_sec) |
| 326 stability->set_incremental_uptime_sec(incremental_uptime_sec); | 314 stability->set_incremental_uptime_sec(incremental_uptime_sec); |
| 327 const uint64 uptime_sec = uptime.InSeconds(); | 315 const uint64 uptime_sec = uptime.InSeconds(); |
| 328 if (uptime_sec) | 316 if (uptime_sec) |
| 329 stability->set_uptime_sec(uptime_sec); | 317 stability->set_uptime_sec(uptime_sec); |
| 330 } | 318 } |
| 331 | 319 |
| 332 void MetricsLog::RecordEnvironment( | 320 void MetricsLog::RecordEnvironment( |
| 333 const std::vector<metrics::MetricsProvider*>& metrics_providers, | 321 const std::vector<metrics::MetricsProvider*>& metrics_providers, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 base::CPU cpu_info; | 371 base::CPU cpu_info; |
| 384 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); | 372 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); |
| 385 cpu->set_vendor_name(cpu_info.vendor_name()); | 373 cpu->set_vendor_name(cpu_info.vendor_name()); |
| 386 cpu->set_signature(cpu_info.signature()); | 374 cpu->set_signature(cpu_info.signature()); |
| 387 | 375 |
| 388 std::vector<ActiveGroupId> field_trial_ids; | 376 std::vector<ActiveGroupId> field_trial_ids; |
| 389 GetFieldTrialIds(&field_trial_ids); | 377 GetFieldTrialIds(&field_trial_ids); |
| 390 WriteFieldTrials(field_trial_ids, system_profile); | 378 WriteFieldTrials(field_trial_ids, system_profile); |
| 391 WriteFieldTrials(synthetic_trials, system_profile); | 379 WriteFieldTrials(synthetic_trials, system_profile); |
| 392 | 380 |
| 393 #if defined(OS_CHROMEOS) | |
| 394 metrics_log_chromeos_->LogChromeOSMetrics(); | |
| 395 #endif // OS_CHROMEOS | |
| 396 | |
| 397 for (size_t i = 0; i < metrics_providers.size(); ++i) | 381 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 398 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); | 382 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); |
| 399 | 383 |
| 400 std::string serialied_system_profile; | 384 std::string serialied_system_profile; |
| 401 std::string base64_system_profile; | 385 std::string base64_system_profile; |
| 402 if (system_profile->SerializeToString(&serialied_system_profile)) { | 386 if (system_profile->SerializeToString(&serialied_system_profile)) { |
| 403 base::Base64Encode(serialied_system_profile, &base64_system_profile); | 387 base::Base64Encode(serialied_system_profile, &base64_system_profile); |
| 404 PrefService* local_state = GetPrefService(); | 388 PrefService* local_state = GetPrefService(); |
| 405 local_state->SetString(prefs::kStabilitySavedSystemProfile, | 389 local_state->SetString(prefs::kStabilitySavedSystemProfile, |
| 406 base64_system_profile); | 390 base64_system_profile); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 profile = uma_proto()->add_profiler_event(); | 429 profile = uma_proto()->add_profiler_event(); |
| 446 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); | 430 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); |
| 447 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); | 431 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); |
| 448 } else { | 432 } else { |
| 449 // For the remaining calls, re-use the existing field. | 433 // For the remaining calls, re-use the existing field. |
| 450 profile = uma_proto()->mutable_profiler_event(0); | 434 profile = uma_proto()->mutable_profiler_event(0); |
| 451 } | 435 } |
| 452 | 436 |
| 453 WriteProfilerData(process_data, process_type, profile); | 437 WriteProfilerData(process_data, process_type, profile); |
| 454 } | 438 } |
| OLD | NEW |