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 22 matching lines...) Expand all Loading... |
33 #include "components/metrics/proto/histogram_event.pb.h" | 33 #include "components/metrics/proto/histogram_event.pb.h" |
34 #include "components/metrics/proto/system_profile.pb.h" | 34 #include "components/metrics/proto/system_profile.pb.h" |
35 #include "components/metrics/proto/user_action_event.pb.h" | 35 #include "components/metrics/proto/user_action_event.pb.h" |
36 #include "components/variations/active_field_trials.h" | 36 #include "components/variations/active_field_trials.h" |
37 | 37 |
38 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
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" | |
44 | |
45 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 43 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
46 extern "C" IMAGE_DOS_HEADER __ImageBase; | 44 extern "C" IMAGE_DOS_HEADER __ImageBase; |
47 #endif | 45 #endif |
48 | 46 |
49 using base::SampleCountIterator; | 47 using base::SampleCountIterator; |
50 typedef variations::ActiveGroupId ActiveGroupId; | 48 typedef variations::ActiveGroupId ActiveGroupId; |
51 | 49 |
52 namespace metrics { | 50 namespace metrics { |
53 | 51 |
54 namespace { | 52 namespace { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 hardware->set_hardware_class(base::SysInfo::HardwareModelName()); | 320 hardware->set_hardware_class(base::SysInfo::HardwareModelName()); |
323 | 321 |
324 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); | 322 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); |
325 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); | 323 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); |
326 #if defined(OS_WIN) | 324 #if defined(OS_WIN) |
327 hardware->set_dll_base(reinterpret_cast<uint64_t>(&__ImageBase)); | 325 hardware->set_dll_base(reinterpret_cast<uint64_t>(&__ImageBase)); |
328 #endif | 326 #endif |
329 | 327 |
330 SystemProfileProto::OS* os = system_profile->mutable_os(); | 328 SystemProfileProto::OS* os = system_profile->mutable_os(); |
331 std::string os_name = base::SysInfo::OperatingSystemName(); | 329 std::string os_name = base::SysInfo::OperatingSystemName(); |
332 #if defined(OS_WIN) | |
333 // TODO(mad): This only checks whether the main process is a Metro process at | |
334 // upload time; not whether the collected metrics were all gathered from | |
335 // Metro. This is ok as an approximation for now, since users will rarely be | |
336 // switching from Metro to Desktop mode; but we should re-evaluate whether we | |
337 // can distinguish metrics more cleanly in the future: http://crbug.com/140568 | |
338 if (base::win::IsMetroProcess()) | |
339 os_name += " (Metro)"; | |
340 #endif | |
341 os->set_name(os_name); | 330 os->set_name(os_name); |
342 os->set_version(base::SysInfo::OperatingSystemVersion()); | 331 os->set_version(base::SysInfo::OperatingSystemVersion()); |
343 #if defined(OS_ANDROID) | 332 #if defined(OS_ANDROID) |
344 os->set_fingerprint( | 333 os->set_fingerprint( |
345 base::android::BuildInfo::GetInstance()->android_build_fp()); | 334 base::android::BuildInfo::GetInstance()->android_build_fp()); |
346 #endif | 335 #endif |
347 | 336 |
348 base::CPU cpu_info; | 337 base::CPU cpu_info; |
349 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); | 338 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); |
350 cpu->set_vendor_name(cpu_info.vendor_name()); | 339 cpu->set_vendor_name(cpu_info.vendor_name()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 DCHECK(!closed_); | 383 DCHECK(!closed_); |
395 closed_ = true; | 384 closed_ = true; |
396 } | 385 } |
397 | 386 |
398 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 387 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
399 DCHECK(closed_); | 388 DCHECK(closed_); |
400 uma_proto_.SerializeToString(encoded_log); | 389 uma_proto_.SerializeToString(encoded_log); |
401 } | 390 } |
402 | 391 |
403 } // namespace metrics | 392 } // namespace metrics |
OLD | NEW |