Index: chrome/browser/metrics/metrics_log.cc |
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc |
index cc231453429d609070f972753845b4f4e97a7be5..028d4c7e8761f640f98d1b7621a10cbd6cf3043f 100644 |
--- a/chrome/browser/metrics/metrics_log.cc |
+++ b/chrome/browser/metrics/metrics_log.cc |
@@ -46,9 +46,6 @@ |
#include "content/public/browser/gpu_data_manager.h" |
#include "content/public/common/content_client.h" |
#include "content/public/common/webplugininfo.h" |
-#include "device/bluetooth/bluetooth_adapter.h" |
-#include "device/bluetooth/bluetooth_adapter_factory.h" |
-#include "device/bluetooth/bluetooth_device.h" |
#include "gpu/config/gpu_info.h" |
#include "ui/gfx/screen.h" |
#include "url/gurl.h" |
@@ -64,19 +61,13 @@ |
extern "C" IMAGE_DOS_HEADER __ImageBase; |
#endif |
-#if defined(OS_CHROMEOS) |
-#include "chrome/browser/chromeos/login/user_manager.h" |
-#endif |
- |
using content::GpuDataManager; |
using metrics::OmniboxEventProto; |
-using metrics::PerfDataProto; |
using metrics::ProfilerEventProto; |
using metrics::SystemProfileProto; |
using tracked_objects::ProcessDataSnapshot; |
typedef chrome_variations::ActiveGroupId ActiveGroupId; |
typedef SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo; |
-typedef SystemProfileProto::Hardware::Bluetooth::PairedDevice PairedDevice; |
namespace { |
@@ -343,45 +334,6 @@ void WriteScreenDPIInformationProto(SystemProfileProto::Hardware* hardware) { |
#endif // defined(OS_WIN) |
-#if defined(OS_CHROMEOS) |
-PairedDevice::Type AsBluetoothDeviceType( |
- enum device::BluetoothDevice::DeviceType device_type) { |
- switch (device_type) { |
- case device::BluetoothDevice::DEVICE_UNKNOWN: |
- return PairedDevice::DEVICE_UNKNOWN; |
- case device::BluetoothDevice::DEVICE_COMPUTER: |
- return PairedDevice::DEVICE_COMPUTER; |
- case device::BluetoothDevice::DEVICE_PHONE: |
- return PairedDevice::DEVICE_PHONE; |
- case device::BluetoothDevice::DEVICE_MODEM: |
- return PairedDevice::DEVICE_MODEM; |
- case device::BluetoothDevice::DEVICE_AUDIO: |
- return PairedDevice::DEVICE_AUDIO; |
- case device::BluetoothDevice::DEVICE_CAR_AUDIO: |
- return PairedDevice::DEVICE_CAR_AUDIO; |
- case device::BluetoothDevice::DEVICE_VIDEO: |
- return PairedDevice::DEVICE_VIDEO; |
- case device::BluetoothDevice::DEVICE_PERIPHERAL: |
- return PairedDevice::DEVICE_PERIPHERAL; |
- case device::BluetoothDevice::DEVICE_JOYSTICK: |
- return PairedDevice::DEVICE_JOYSTICK; |
- case device::BluetoothDevice::DEVICE_GAMEPAD: |
- return PairedDevice::DEVICE_GAMEPAD; |
- case device::BluetoothDevice::DEVICE_KEYBOARD: |
- return PairedDevice::DEVICE_KEYBOARD; |
- case device::BluetoothDevice::DEVICE_MOUSE: |
- return PairedDevice::DEVICE_MOUSE; |
- case device::BluetoothDevice::DEVICE_TABLET: |
- return PairedDevice::DEVICE_TABLET; |
- case device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO: |
- return PairedDevice::DEVICE_KEYBOARD_MOUSE_COMBO; |
- } |
- |
- NOTREACHED(); |
- return PairedDevice::DEVICE_UNKNOWN; |
-} |
-#endif // defined(OS_CHROMEOS) |
- |
// Round a timestamp measured in seconds since epoch to one with a granularity |
// of an hour. This can be used before uploaded potentially sensitive |
// timestamps. |
@@ -402,8 +354,8 @@ MetricsLog::MetricsLog(const std::string& client_id, int session_id) |
: MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()), |
creation_time_(base::TimeTicks::Now()) { |
#if defined(OS_CHROMEOS) |
- UpdateMultiProfileUserCount(); |
-#endif |
+ metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); |
+#endif // OS_CHROMEOS |
} |
MetricsLog::~MetricsLog() {} |
@@ -653,23 +605,7 @@ void MetricsLog::WriteRealtimeStabilityAttributes( |
} |
#if defined(OS_CHROMEOS) |
- count = pref->GetInteger(prefs::kStabilityOtherUserCrashCount); |
- if (count) { |
- stability->set_other_user_crash_count(count); |
- pref->SetInteger(prefs::kStabilityOtherUserCrashCount, 0); |
- } |
- |
- count = pref->GetInteger(prefs::kStabilityKernelCrashCount); |
- if (count) { |
- stability->set_kernel_crash_count(count); |
- pref->SetInteger(prefs::kStabilityKernelCrashCount, 0); |
- } |
- |
- count = pref->GetInteger(prefs::kStabilitySystemUncleanShutdownCount); |
- if (count) { |
- stability->set_unclean_system_shutdown_count(count); |
- pref->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 0); |
- } |
+ metrics_log_chromeos_->WriteRealtimeStabilityAttributes(pref, stability); |
#endif // OS_CHROMEOS |
const uint64 uptime_sec = incremental_uptime.InSeconds(); |
@@ -795,15 +731,6 @@ void MetricsLog::RecordEnvironment( |
WriteFieldTrials(field_trial_ids, system_profile); |
WriteFieldTrials(synthetic_trials, system_profile); |
-#if defined(OS_CHROMEOS) |
- PerfDataProto perf_data_proto; |
- if (perf_provider_.GetPerfData(&perf_data_proto)) |
- uma_proto()->add_perf_data()->Swap(&perf_data_proto); |
- |
- WriteBluetoothProto(hardware); |
- UpdateMultiProfileUserCount(); |
-#endif |
- |
std::string serialied_system_profile; |
std::string base64_system_profile; |
if (system_profile->SerializeToString(&serialied_system_profile)) { |
@@ -814,6 +741,10 @@ void MetricsLog::RecordEnvironment( |
local_state->SetString(prefs::kStabilitySavedSystemProfileHash, |
ComputeSHA1(serialied_system_profile)); |
} |
+ |
+#if defined(OS_CHROMEOS) |
+ metrics_log_chromeos_->LogChromeOSMetrics(uma_proto()); |
Alexei Svitkine (slow)
2014/01/30 16:30:45
Please move this to where the old code was (above)
tdresser
2014/01/30 18:04:25
Done.
|
+#endif // OS_CHROMEOS |
} |
bool MetricsLog::LoadSavedEnvironmentFromPrefs() { |
@@ -942,73 +873,3 @@ void MetricsLog::WriteGoogleUpdateProto( |
} |
#endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
} |
- |
-void MetricsLog::SetBluetoothAdapter( |
- scoped_refptr<device::BluetoothAdapter> adapter) { |
- adapter_ = adapter; |
-} |
- |
-void MetricsLog::WriteBluetoothProto( |
- SystemProfileProto::Hardware* hardware) { |
-#if defined(OS_CHROMEOS) |
- // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that |
- // changes this will fail at the DCHECK(). |
- device::BluetoothAdapterFactory::GetAdapter( |
- base::Bind(&MetricsLog::SetBluetoothAdapter, |
- base::Unretained(this))); |
- DCHECK(adapter_.get()); |
- |
- SystemProfileProto::Hardware::Bluetooth* bluetooth = |
- hardware->mutable_bluetooth(); |
- |
- bluetooth->set_is_present(adapter_->IsPresent()); |
- bluetooth->set_is_enabled(adapter_->IsPowered()); |
- |
- device::BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
- for (device::BluetoothAdapter::DeviceList::iterator iter = |
- devices.begin(); iter != devices.end(); ++iter) { |
- PairedDevice* paired_device = bluetooth->add_paired_device(); |
- |
- device::BluetoothDevice* device = *iter; |
- paired_device->set_bluetooth_class(device->GetBluetoothClass()); |
- paired_device->set_type(AsBluetoothDeviceType(device->GetDeviceType())); |
- |
- // address is xx:xx:xx:xx:xx:xx, extract the first three components and |
- // pack into a uint32 |
- std::string address = device->GetAddress(); |
- if (address.size() > 9 && |
- address[2] == ':' && address[5] == ':' && address[8] == ':') { |
- std::string vendor_prefix_str; |
- uint64 vendor_prefix; |
- |
- base::RemoveChars(address.substr(0, 9), ":", &vendor_prefix_str); |
- DCHECK_EQ(6U, vendor_prefix_str.size()); |
- base::HexStringToUInt64(vendor_prefix_str, &vendor_prefix); |
- |
- paired_device->set_vendor_prefix(vendor_prefix); |
- } |
- |
- paired_device->set_vendor_id(device->GetVendorID()); |
- paired_device->set_product_id(device->GetProductID()); |
- paired_device->set_device_id(device->GetDeviceID()); |
- } |
-#endif // defined(OS_CHROMEOS) |
-} |
- |
-#if defined(OS_CHROMEOS) |
-void MetricsLog::UpdateMultiProfileUserCount() { |
- if (chromeos::UserManager::IsInitialized() && |
- chromeos::UserManager::Get()->IsMultipleProfilesAllowed()) { |
- uint32 user_count = chromeos::UserManager::Get() |
- ->GetLoggedInUsers().size(); |
- SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
- |
- // We invalidate the user count if it changed while the log was open. |
- if (system_profile->has_multi_profile_user_count() && |
- user_count != system_profile->multi_profile_user_count()) |
- user_count = 0; |
- |
- system_profile->set_multi_profile_user_count(user_count); |
- } |
-} |
-#endif |