Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: chrome/browser/metrics/metrics_log.cc

Issue 13872017: Bluetooth: gather usage metrics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further review comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/common/metrics/proto/system_profile.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_log.cc
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index ec39326a7784b74f401734e5e355c8cc2f10b78a..d410363efdb812b507199432f7a2595b8771f7eb 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
@@ -44,6 +45,9 @@
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_client.h"
#include "content/public/common/gpu_info.h"
+#include "device/bluetooth/bluetooth_adapter.h"
+#include "device/bluetooth/bluetooth_adapter_factory.h"
+#include "device/bluetooth/bluetooth_device.h"
#include "googleurl/src/gurl.h"
#include "ui/gfx/screen.h"
#include "webkit/plugins/webplugininfo.h"
@@ -69,6 +73,7 @@ using metrics::SystemProfileProto;
using tracked_objects::ProcessDataSnapshot;
typedef chrome_variations::ActiveGroupId ActiveGroupId;
typedef SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo;
+typedef SystemProfileProto::Hardware::Bluetooth::PairedDevice PairedDevice;
namespace {
@@ -303,6 +308,45 @@ 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)
+
} // namespace
GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {}
@@ -313,7 +357,8 @@ static base::LazyInstance<std::string>::Leaky
g_version_extension = LAZY_INSTANCE_INITIALIZER;
MetricsLog::MetricsLog(const std::string& client_id, int session_id)
- : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {}
+ : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()),
+ weak_ptr_factory_(this) {}
MetricsLog::~MetricsLog() {}
@@ -877,6 +922,12 @@ void MetricsLog::RecordEnvironmentProto(
PerfDataProto perf_data_proto;
if (perf_provider_.GetPerfData(&perf_data_proto))
uma_proto()->add_perf_data()->Swap(&perf_data_proto);
+
+ device::BluetoothAdapterFactory::GetAdapter(
+ base::Bind(&MetricsLog::SetBluetoothAdapter,
Ilya Sherman 2013/04/23 01:01:55 Looks like the body for this method is missing.
keybuk 2013/04/23 01:17:54 oops, editor rebellion Done.
+ weak_ptr_factory_.GetWeakPtr()));
+ if (adapter_.get())
Ilya Sherman 2013/04/23 01:01:55 Per IM conversation, it sounds like this is expect
keybuk 2013/04/23 01:17:54 Done.
+ WriteBluetoothProto(hardware);
#endif
}
@@ -1087,3 +1138,42 @@ void MetricsLog::WriteGoogleUpdateProto(
}
#endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)
}
+
+void MetricsLog::WriteBluetoothProto(
+ SystemProfileProto::Hardware* hardware) {
+#if defined(OS_CHROMEOS)
+ 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.length() > 9 &&
+ address[2] == ':' && address[5] == ':' && address[8] == ':') {
+ std::string vendor_prefix_str;
+ uint64 vendor_prefix;
+
+ RemoveChars(address.substr(0, 9), ":", &vendor_prefix_str);
Ilya Sherman 2013/04/23 01:01:55 nit: Just to be extra sure, could you add a DCHECK
keybuk 2013/04/23 01:17:54 Done.
+ 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)
+}
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/common/metrics/proto/system_profile.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698