OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" | 5 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" | 13 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" |
13 #include "chromeos/dbus/experimental_bluetooth_device_client.h" | 14 #include "chromeos/dbus/experimental_bluetooth_device_client.h" |
14 #include "device/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
15 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" | 16 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" |
16 | 17 |
17 using device::BluetoothAdapter; | 18 using device::BluetoothAdapter; |
18 using device::BluetoothDevice; | 19 using device::BluetoothDevice; |
19 | 20 |
20 namespace chromeos { | 21 namespace chromeos { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 ExperimentalBluetoothDeviceClient::Properties* properties = | 240 ExperimentalBluetoothDeviceClient::Properties* properties = |
240 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> | 241 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
241 GetProperties(object_path); | 242 GetProperties(object_path); |
242 | 243 |
243 if (property_name == properties->bluetooth_class.name() || | 244 if (property_name == properties->bluetooth_class.name() || |
244 property_name == properties->alias.name() || | 245 property_name == properties->alias.name() || |
245 property_name == properties->paired.name() || | 246 property_name == properties->paired.name() || |
246 property_name == properties->connected.name() || | 247 property_name == properties->connected.name() || |
247 property_name == properties->uuids.name()) | 248 property_name == properties->uuids.name()) |
248 NotifyDeviceChanged(device_chromeos); | 249 NotifyDeviceChanged(device_chromeos); |
| 250 |
| 251 // UMA connection counting |
| 252 if (property_name == properties->connected.name()) { |
| 253 int count = 0; |
| 254 |
| 255 for (DevicesMap::iterator iter = devices_.begin(); |
| 256 iter != devices_.end(); ++iter) { |
| 257 if (iter->second->IsConnected()) |
| 258 ++count; |
| 259 } |
| 260 |
| 261 UMA_HISTOGRAM_COUNTS_100("Bluetooth.ConnectedDeviceCount", count); |
| 262 } |
249 } | 263 } |
250 | 264 |
251 BluetoothDeviceExperimentalChromeOS* | 265 BluetoothDeviceExperimentalChromeOS* |
252 BluetoothAdapterExperimentalChromeOS::GetDeviceWithPath( | 266 BluetoothAdapterExperimentalChromeOS::GetDeviceWithPath( |
253 const dbus::ObjectPath& object_path) { | 267 const dbus::ObjectPath& object_path) { |
254 for (DevicesMap::iterator iter = devices_.begin(); | 268 for (DevicesMap::iterator iter = devices_.begin(); |
255 iter != devices_.end(); ++iter) { | 269 iter != devices_.end(); ++iter) { |
256 BluetoothDeviceExperimentalChromeOS* device_chromeos = | 270 BluetoothDeviceExperimentalChromeOS* device_chromeos = |
257 static_cast<BluetoothDeviceExperimentalChromeOS*>(iter->second); | 271 static_cast<BluetoothDeviceExperimentalChromeOS*>(iter->second); |
258 if (device_chromeos->object_path() == object_path) | 272 if (device_chromeos->object_path() == object_path) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 void BluetoothAdapterExperimentalChromeOS::OnStopDiscoveryError( | 396 void BluetoothAdapterExperimentalChromeOS::OnStopDiscoveryError( |
383 const ErrorCallback& error_callback, | 397 const ErrorCallback& error_callback, |
384 const std::string& error_name, | 398 const std::string& error_name, |
385 const std::string& error_message) { | 399 const std::string& error_message) { |
386 LOG(WARNING) << object_path_.value() << ": Failed to stop discovery: " | 400 LOG(WARNING) << object_path_.value() << ": Failed to stop discovery: " |
387 << error_name << ": " << error_message; | 401 << error_name << ": " << error_message; |
388 error_callback.Run(); | 402 error_callback.Run(); |
389 } | 403 } |
390 | 404 |
391 } // namespace chromeos | 405 } // namespace chromeos |
OLD | NEW |