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

Side by Side Diff: device/bluetooth/bluetooth_device_experimental_chromeos.cc

Issue 13872017: Bluetooth: gather usage metrics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK_EQ - compile error hidden by previous WebKit issues 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_device_experimental_chromeos.h" 5 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h"
10 #include "base/strings/string_number_conversions.h"
8 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" 12 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
10 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" 13 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h"
11 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" 14 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h"
12 #include "chromeos/dbus/experimental_bluetooth_device_client.h" 15 #include "chromeos/dbus/experimental_bluetooth_device_client.h"
13 #include "chromeos/dbus/experimental_bluetooth_input_client.h" 16 #include "chromeos/dbus/experimental_bluetooth_input_client.h"
14 #include "dbus/bus.h" 17 #include "dbus/bus.h"
15 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" 18 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h"
16 #include "device/bluetooth/bluetooth_socket.h" 19 #include "device/bluetooth/bluetooth_socket.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
18 21
19 using device::BluetoothDevice; 22 using device::BluetoothDevice;
20 23
21 namespace { 24 namespace {
22 25
23 // The agent path is relatively meaningless since BlueZ only supports one 26 // The agent path is relatively meaningless since BlueZ only supports one
24 // at time and will fail in an attempt to register another with "Already Exists" 27 // at time and will fail in an attempt to register another with "Already Exists"
25 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). 28 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS).
26 const char kAgentPath[] = "/org/chromium/bluetooth_agent"; 29 const char kAgentPath[] = "/org/chromium/bluetooth_agent";
27 30
31 // Histogram enumerations for pairing methods.
32 enum UMAPairingMethod {
33 UMA_PAIRING_METHOD_NONE,
34 UMA_PAIRING_METHOD_REQUEST_PINCODE,
35 UMA_PAIRING_METHOD_REQUEST_PASSKEY,
36 UMA_PAIRING_METHOD_DISPLAY_PINCODE,
37 UMA_PAIRING_METHOD_DISPLAY_PASSKEY,
38 UMA_PAIRING_METHOD_CONFIRM_PASSKEY,
39 // NOTE: Add new pairing methods immediately above this line. Make sure to
40 // update the enum list in tools/histogram/histograms.xml accordinly.
41 UMA_PAIRING_METHOD_COUNT
42 };
43
44 // Histogram enumerations for pairing results.
45 enum UMAPairingResult {
46 UMA_PAIRING_RESULT_SUCCESS,
47 UMA_PAIRING_RESULT_INPROGRESS,
48 UMA_PAIRING_RESULT_FAILED,
49 UMA_PAIRING_RESULT_AUTH_FAILED,
50 UMA_PAIRING_RESULT_AUTH_CANCELED,
51 UMA_PAIRING_RESULT_AUTH_REJECTED,
52 UMA_PAIRING_RESULT_AUTH_TIMEOUT,
53 UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE,
54 UMA_PAIRING_RESULT_UNKNOWN_ERROR,
55 // NOTE: Add new pairing results immediately above this line. Make sure to
56 // update the enum list in tools/histogram/histograms.xml accordinly.
57 UMA_PAIRING_RESULT_COUNT
58 };
59
60 void ParseModalias(const dbus::ObjectPath& object_path,
satorux1 2013/04/23 21:23:15 function comment is missing. uint16 parameters see
keybuk 2013/04/23 21:34:40 they are optional
61 uint16 *vendor_id,
62 uint16 *product_id,
63 uint16 *device_id) {
64 chromeos::ExperimentalBluetoothDeviceClient::Properties* properties =
65 chromeos::DBusThreadManager::Get()->
66 GetExperimentalBluetoothDeviceClient()->GetProperties(object_path);
67 DCHECK(properties);
68
69 std::string modalias = properties->modalias.value();
70 if (StartsWithASCII(modalias, "usb:", false) && modalias.length() == 19) {
71 // usb:vXXXXpXXXXdXXXX
72 if (modalias[4] == 'v' && vendor_id != NULL) {
73 uint64 component = 0;
74 base::HexStringToUInt64(modalias.substr(5, 4), &component);
75 *vendor_id = component;
76 }
77
78 if (modalias[9] == 'p' && product_id != NULL) {
79 uint64 component = 0;
80 base::HexStringToUInt64(modalias.substr(10, 4), &component);
81 *product_id = component;
82 }
83
84 if (modalias[14] == 'd' && device_id != NULL) {
85 uint64 component = 0;
86 base::HexStringToUInt64(modalias.substr(15, 4), &component);
87 *device_id = component;
88 }
89 }
90 }
91
28 } // namespace 92 } // namespace
29 93
30 namespace chromeos { 94 namespace chromeos {
31 95
32 BluetoothDeviceExperimentalChromeOS::BluetoothDeviceExperimentalChromeOS( 96 BluetoothDeviceExperimentalChromeOS::BluetoothDeviceExperimentalChromeOS(
33 BluetoothAdapterExperimentalChromeOS* adapter, 97 BluetoothAdapterExperimentalChromeOS* adapter,
34 const dbus::ObjectPath& object_path) 98 const dbus::ObjectPath& object_path)
35 : adapter_(adapter), 99 : adapter_(adapter),
36 object_path_(object_path), 100 object_path_(object_path),
37 num_connecting_calls_(0), 101 num_connecting_calls_(0),
38 pairing_delegate_(NULL), 102 pairing_delegate_(NULL),
103 pairing_delegate_used_(false),
39 weak_ptr_factory_(this) { 104 weak_ptr_factory_(this) {
40 } 105 }
41 106
42 BluetoothDeviceExperimentalChromeOS::~BluetoothDeviceExperimentalChromeOS() { 107 BluetoothDeviceExperimentalChromeOS::~BluetoothDeviceExperimentalChromeOS() {
43 } 108 }
44 109
45 uint32 BluetoothDeviceExperimentalChromeOS::GetBluetoothClass() const { 110 uint32 BluetoothDeviceExperimentalChromeOS::GetBluetoothClass() const {
46 ExperimentalBluetoothDeviceClient::Properties* properties = 111 ExperimentalBluetoothDeviceClient::Properties* properties =
47 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> 112 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()->
48 GetProperties(object_path_); 113 GetProperties(object_path_);
(...skipping 13 matching lines...) Expand all
62 127
63 std::string BluetoothDeviceExperimentalChromeOS::GetAddress() const { 128 std::string BluetoothDeviceExperimentalChromeOS::GetAddress() const {
64 ExperimentalBluetoothDeviceClient::Properties* properties = 129 ExperimentalBluetoothDeviceClient::Properties* properties =
65 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> 130 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()->
66 GetProperties(object_path_); 131 GetProperties(object_path_);
67 DCHECK(properties); 132 DCHECK(properties);
68 133
69 return properties->address.value(); 134 return properties->address.value();
70 } 135 }
71 136
137 uint16 BluetoothDeviceExperimentalChromeOS::GetVendorID() const {
138 uint16 vendor_id = 0;
139 ParseModalias(object_path_, &vendor_id, NULL, NULL);
140 return vendor_id;
141 }
142
143 uint16 BluetoothDeviceExperimentalChromeOS::GetProductID() const {
144 uint16 product_id = 0;
145 ParseModalias(object_path_, NULL, &product_id, NULL);
146 return product_id;
147 }
148
149 uint16 BluetoothDeviceExperimentalChromeOS::GetDeviceID() const {
150 uint16 device_id = 0;
151 ParseModalias(object_path_, NULL, NULL, &device_id);
152 return device_id;
153 }
154
72 bool BluetoothDeviceExperimentalChromeOS::IsPaired() const { 155 bool BluetoothDeviceExperimentalChromeOS::IsPaired() const {
73 ExperimentalBluetoothDeviceClient::Properties* properties = 156 ExperimentalBluetoothDeviceClient::Properties* properties =
74 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> 157 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()->
75 GetProperties(object_path_); 158 GetProperties(object_path_);
76 DCHECK(properties); 159 DCHECK(properties);
77 160
78 // Trusted devices are devices that don't support pairing but that the 161 // Trusted devices are devices that don't support pairing but that the
79 // user has explicitly connected; it makes no sense for UI purposes to 162 // user has explicitly connected; it makes no sense for UI purposes to
80 // treat them differently from each other. 163 // treat them differently from each other.
81 return properties->paired.value() || properties->trusted.value(); 164 return properties->paired.value() || properties->trusted.value();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 237
155 if (IsPaired() || IsConnected() || !pairing_delegate || !IsPairable()) { 238 if (IsPaired() || IsConnected() || !pairing_delegate || !IsPairable()) {
156 // No need to pair, or unable to, skip straight to connection. 239 // No need to pair, or unable to, skip straight to connection.
157 ConnectInternal(callback, error_callback); 240 ConnectInternal(callback, error_callback);
158 } else { 241 } else {
159 // Initiate high-security connection with pairing. 242 // Initiate high-security connection with pairing.
160 DCHECK(!pairing_delegate_); 243 DCHECK(!pairing_delegate_);
161 DCHECK(agent_.get() == NULL); 244 DCHECK(agent_.get() == NULL);
162 245
163 pairing_delegate_ = pairing_delegate; 246 pairing_delegate_ = pairing_delegate;
247 pairing_delegate_used_ = false;
164 248
165 // The agent path is relatively meaningless since BlueZ only supports 249 // The agent path is relatively meaningless since BlueZ only supports
166 // one per application at a time. 250 // one per application at a time.
167 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); 251 dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus();
168 agent_.reset(ExperimentalBluetoothAgentServiceProvider::Create( 252 agent_.reset(ExperimentalBluetoothAgentServiceProvider::Create(
169 system_bus, dbus::ObjectPath(kAgentPath), this)); 253 system_bus, dbus::ObjectPath(kAgentPath), this));
170 DCHECK(agent_.get()); 254 DCHECK(agent_.get());
171 255
172 VLOG(1) << object_path_.value() << ": Registering agent for pairing"; 256 VLOG(1) << object_path_.value() << ": Registering agent for pairing";
173 DBusThreadManager::Get()->GetExperimentalBluetoothAgentManagerClient()-> 257 DBusThreadManager::Get()->GetExperimentalBluetoothAgentManagerClient()->
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 UnregisterAgent(); 386 UnregisterAgent();
303 } 387 }
304 388
305 void BluetoothDeviceExperimentalChromeOS::RequestPinCode( 389 void BluetoothDeviceExperimentalChromeOS::RequestPinCode(
306 const dbus::ObjectPath& device_path, 390 const dbus::ObjectPath& device_path,
307 const PinCodeCallback& callback) { 391 const PinCodeCallback& callback) {
308 DCHECK(agent_.get()); 392 DCHECK(agent_.get());
309 DCHECK(device_path == object_path_); 393 DCHECK(device_path == object_path_);
310 VLOG(1) << object_path_.value() << ": RequestPinCode"; 394 VLOG(1) << object_path_.value() << ": RequestPinCode";
311 395
396 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
397 UMA_PAIRING_METHOD_REQUEST_PINCODE,
398 UMA_PAIRING_METHOD_COUNT);
399
312 DCHECK(pairing_delegate_); 400 DCHECK(pairing_delegate_);
313 DCHECK(pincode_callback_.is_null()); 401 DCHECK(pincode_callback_.is_null());
314 pincode_callback_ = callback; 402 pincode_callback_ = callback;
315 pairing_delegate_->RequestPinCode(this); 403 pairing_delegate_->RequestPinCode(this);
316 } 404 }
317 405
318 void BluetoothDeviceExperimentalChromeOS::DisplayPinCode( 406 void BluetoothDeviceExperimentalChromeOS::DisplayPinCode(
319 const dbus::ObjectPath& device_path, 407 const dbus::ObjectPath& device_path,
320 const std::string& pincode) { 408 const std::string& pincode) {
321 DCHECK(agent_.get()); 409 DCHECK(agent_.get());
322 DCHECK(device_path == object_path_); 410 DCHECK(device_path == object_path_);
323 VLOG(1) << object_path_.value() << ": DisplayPinCode: " << pincode; 411 VLOG(1) << object_path_.value() << ": DisplayPinCode: " << pincode;
324 412
413 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
414 UMA_PAIRING_METHOD_DISPLAY_PINCODE,
415 UMA_PAIRING_METHOD_COUNT);
416
325 DCHECK(pairing_delegate_); 417 DCHECK(pairing_delegate_);
326 pairing_delegate_->DisplayPinCode(this, pincode); 418 pairing_delegate_->DisplayPinCode(this, pincode);
327 } 419 }
328 420
329 void BluetoothDeviceExperimentalChromeOS::RequestPasskey( 421 void BluetoothDeviceExperimentalChromeOS::RequestPasskey(
330 const dbus::ObjectPath& device_path, 422 const dbus::ObjectPath& device_path,
331 const PasskeyCallback& callback) { 423 const PasskeyCallback& callback) {
332 DCHECK(agent_.get()); 424 DCHECK(agent_.get());
333 DCHECK(device_path == object_path_); 425 DCHECK(device_path == object_path_);
334 VLOG(1) << object_path_.value() << ": RequestPasskey"; 426 VLOG(1) << object_path_.value() << ": RequestPasskey";
335 427
428 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
429 UMA_PAIRING_METHOD_REQUEST_PASSKEY,
430 UMA_PAIRING_METHOD_COUNT);
431
336 DCHECK(pairing_delegate_); 432 DCHECK(pairing_delegate_);
337 DCHECK(passkey_callback_.is_null()); 433 DCHECK(passkey_callback_.is_null());
338 passkey_callback_ = callback; 434 passkey_callback_ = callback;
339 pairing_delegate_->RequestPasskey(this); 435 pairing_delegate_->RequestPasskey(this);
340 } 436 }
341 437
342 void BluetoothDeviceExperimentalChromeOS::DisplayPasskey( 438 void BluetoothDeviceExperimentalChromeOS::DisplayPasskey(
343 const dbus::ObjectPath& device_path, 439 const dbus::ObjectPath& device_path,
344 uint32 passkey, int16 entered) { 440 uint32 passkey, int16 entered) {
345 DCHECK(agent_.get()); 441 DCHECK(agent_.get());
346 DCHECK(device_path == object_path_); 442 DCHECK(device_path == object_path_);
347 VLOG(1) << object_path_.value() << ": DisplayPasskey: " << passkey 443 VLOG(1) << object_path_.value() << ": DisplayPasskey: " << passkey
348 << " (" << entered << " entered)"; 444 << " (" << entered << " entered)";
349 445
446 if (entered == 0)
447 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
448 UMA_PAIRING_METHOD_DISPLAY_PASSKEY,
449 UMA_PAIRING_METHOD_COUNT);
450
350 DCHECK(pairing_delegate_); 451 DCHECK(pairing_delegate_);
351 if (entered == 0) 452 if (entered == 0)
352 pairing_delegate_->DisplayPasskey(this, passkey); 453 pairing_delegate_->DisplayPasskey(this, passkey);
353 pairing_delegate_->KeysEntered(this, entered); 454 pairing_delegate_->KeysEntered(this, entered);
354 } 455 }
355 456
356 void BluetoothDeviceExperimentalChromeOS::RequestConfirmation( 457 void BluetoothDeviceExperimentalChromeOS::RequestConfirmation(
357 const dbus::ObjectPath& device_path, 458 const dbus::ObjectPath& device_path,
358 uint32 passkey, 459 uint32 passkey,
359 const ConfirmationCallback& callback) { 460 const ConfirmationCallback& callback) {
360 DCHECK(agent_.get()); 461 DCHECK(agent_.get());
361 DCHECK(device_path == object_path_); 462 DCHECK(device_path == object_path_);
362 VLOG(1) << object_path_.value() << ": RequestConfirmation: " << passkey; 463 VLOG(1) << object_path_.value() << ": RequestConfirmation: " << passkey;
363 464
465 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
466 UMA_PAIRING_METHOD_CONFIRM_PASSKEY,
467 UMA_PAIRING_METHOD_COUNT);
468
364 DCHECK(pairing_delegate_); 469 DCHECK(pairing_delegate_);
365 DCHECK(confirmation_callback_.is_null()); 470 DCHECK(confirmation_callback_.is_null());
366 confirmation_callback_ = callback; 471 confirmation_callback_ = callback;
367 pairing_delegate_->ConfirmPasskey(this, passkey); 472 pairing_delegate_->ConfirmPasskey(this, passkey);
368 } 473 }
369 474
370 void BluetoothDeviceExperimentalChromeOS::RequestAuthorization( 475 void BluetoothDeviceExperimentalChromeOS::RequestAuthorization(
371 const dbus::ObjectPath& device_path, 476 const dbus::ObjectPath& device_path,
372 const ConfirmationCallback& callback) { 477 const ConfirmationCallback& callback) {
373 // TODO(keybuk): implement 478 // TODO(keybuk): implement
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // Determine the error code from error_name. 542 // Determine the error code from error_name.
438 ConnectErrorCode error_code = ERROR_UNKNOWN; 543 ConnectErrorCode error_code = ERROR_UNKNOWN;
439 if (error_name == bluetooth_adapter::kErrorFailed) { 544 if (error_name == bluetooth_adapter::kErrorFailed) {
440 error_code = ERROR_FAILED; 545 error_code = ERROR_FAILED;
441 } else if (error_name == bluetooth_adapter::kErrorInProgress) { 546 } else if (error_name == bluetooth_adapter::kErrorInProgress) {
442 error_code = ERROR_INPROGRESS; 547 error_code = ERROR_INPROGRESS;
443 } else if (error_name == bluetooth_adapter::kErrorNotSupported) { 548 } else if (error_name == bluetooth_adapter::kErrorNotSupported) {
444 error_code = ERROR_UNSUPPORTED_DEVICE; 549 error_code = ERROR_UNSUPPORTED_DEVICE;
445 } 550 }
446 551
552 RecordPairingResult(false, error_code);
447 error_callback.Run(error_code); 553 error_callback.Run(error_code);
448 } 554 }
449 555
450 void BluetoothDeviceExperimentalChromeOS::OnRegisterAgent( 556 void BluetoothDeviceExperimentalChromeOS::OnRegisterAgent(
451 const base::Closure& callback, 557 const base::Closure& callback,
452 const ConnectErrorCallback& error_callback) { 558 const ConnectErrorCallback& error_callback) {
453 VLOG(1) << object_path_.value() << ": Agent registered, now pairing"; 559 VLOG(1) << object_path_.value() << ": Agent registered, now pairing";
454 560
455 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> 561 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()->
456 Pair(object_path_, 562 Pair(object_path_,
(...skipping 20 matching lines...) Expand all
477 VLOG(1) << object_path_.value() << ": " << num_connecting_calls_ 583 VLOG(1) << object_path_.value() << ": " << num_connecting_calls_
478 << " still in progress"; 584 << " still in progress";
479 585
480 UnregisterAgent(); 586 UnregisterAgent();
481 587
482 // Determine the error code from error_name. 588 // Determine the error code from error_name.
483 ConnectErrorCode error_code = ERROR_UNKNOWN; 589 ConnectErrorCode error_code = ERROR_UNKNOWN;
484 if (error_name == bluetooth_adapter::kErrorAlreadyExists) 590 if (error_name == bluetooth_adapter::kErrorAlreadyExists)
485 error_code = ERROR_INPROGRESS; 591 error_code = ERROR_INPROGRESS;
486 592
593 RecordPairingResult(false, error_code);
487 error_callback.Run(error_code); 594 error_callback.Run(error_code);
488 } 595 }
489 596
490 void BluetoothDeviceExperimentalChromeOS::OnPair( 597 void BluetoothDeviceExperimentalChromeOS::OnPair(
491 const base::Closure& callback, 598 const base::Closure& callback,
492 const ConnectErrorCallback& error_callback) { 599 const ConnectErrorCallback& error_callback) {
493 VLOG(1) << object_path_.value() << ": Paired"; 600 VLOG(1) << object_path_.value() << ": Paired";
601
602 if (!pairing_delegate_used_)
603 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
604 UMA_PAIRING_METHOD_NONE,
605 UMA_PAIRING_METHOD_COUNT);
494 UnregisterAgent(); 606 UnregisterAgent();
495 SetTrusted(); 607 SetTrusted();
496 ConnectInternal(callback, error_callback); 608 ConnectInternal(callback, error_callback);
497 } 609 }
498 610
499 void BluetoothDeviceExperimentalChromeOS::OnPairError( 611 void BluetoothDeviceExperimentalChromeOS::OnPairError(
500 const ConnectErrorCallback& error_callback, 612 const ConnectErrorCallback& error_callback,
501 const std::string& error_name, 613 const std::string& error_name,
502 const std::string& error_message) { 614 const std::string& error_message) {
503 if (--num_connecting_calls_ == 0) 615 if (--num_connecting_calls_ == 0)
(...skipping 14 matching lines...) Expand all
518 } else if (error_name == bluetooth_adapter::kErrorAuthenticationFailed) { 630 } else if (error_name == bluetooth_adapter::kErrorAuthenticationFailed) {
519 error_code = ERROR_AUTH_FAILED; 631 error_code = ERROR_AUTH_FAILED;
520 } else if (error_name == bluetooth_adapter::kErrorAuthenticationCanceled) { 632 } else if (error_name == bluetooth_adapter::kErrorAuthenticationCanceled) {
521 error_code = ERROR_AUTH_CANCELED; 633 error_code = ERROR_AUTH_CANCELED;
522 } else if (error_name == bluetooth_adapter::kErrorAuthenticationRejected) { 634 } else if (error_name == bluetooth_adapter::kErrorAuthenticationRejected) {
523 error_code = ERROR_AUTH_REJECTED; 635 error_code = ERROR_AUTH_REJECTED;
524 } else if (error_name == bluetooth_adapter::kErrorAuthenticationTimeout) { 636 } else if (error_name == bluetooth_adapter::kErrorAuthenticationTimeout) {
525 error_code = ERROR_AUTH_TIMEOUT; 637 error_code = ERROR_AUTH_TIMEOUT;
526 } 638 }
527 639
640 RecordPairingResult(false, error_code);
528 error_callback.Run(error_code); 641 error_callback.Run(error_code);
529 } 642 }
530 643
531 void BluetoothDeviceExperimentalChromeOS::OnCancelPairingError( 644 void BluetoothDeviceExperimentalChromeOS::OnCancelPairingError(
532 const std::string& error_name, 645 const std::string& error_name,
533 const std::string& error_message) { 646 const std::string& error_message) {
534 LOG(WARNING) << object_path_.value() << ": Failed to cancel pairing: " 647 LOG(WARNING) << object_path_.value() << ": Failed to cancel pairing: "
535 << error_name << ": " << error_message; 648 << error_name << ": " << error_message;
536 } 649 }
537 650
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 740
628 if (!confirmation_callback_.is_null()) { 741 if (!confirmation_callback_.is_null()) {
629 confirmation_callback_.Run(status); 742 confirmation_callback_.Run(status);
630 confirmation_callback_.Reset(); 743 confirmation_callback_.Reset();
631 callback_run = true; 744 callback_run = true;
632 } 745 }
633 746
634 return callback_run; 747 return callback_run;
635 } 748 }
636 749
750 void BluetoothDeviceExperimentalChromeOS::RecordPairingResult(
751 bool success,
752 ConnectErrorCode error_code) {
753 UMAPairingResult pairing_result;
754 if (success) {
755 pairing_result = UMA_PAIRING_RESULT_SUCCESS;
756 } else {
757 switch (error_code) {
satorux1 2013/04/23 21:23:15 Converting ConnectErrorCode to UMAPairingResult lo
Ilya Sherman 2013/04/23 21:32:26 The really important thing is that enums used with
keybuk 2013/04/23 21:34:40 They're not consistent ... UMAPairingResult has a
758 case ERROR_INPROGRESS:
759 pairing_result = UMA_PAIRING_RESULT_INPROGRESS;
760 break;
761 case ERROR_FAILED:
762 pairing_result = UMA_PAIRING_RESULT_FAILED;
763 break;
764 case ERROR_AUTH_FAILED:
765 pairing_result = UMA_PAIRING_RESULT_AUTH_FAILED;
766 break;
767 case ERROR_AUTH_CANCELED:
768 pairing_result = UMA_PAIRING_RESULT_AUTH_CANCELED;
769 break;
770 case ERROR_AUTH_REJECTED:
771 pairing_result = UMA_PAIRING_RESULT_AUTH_REJECTED;
772 break;
773 case ERROR_AUTH_TIMEOUT:
774 pairing_result = UMA_PAIRING_RESULT_AUTH_TIMEOUT;
775 break;
776 case ERROR_UNSUPPORTED_DEVICE:
777 pairing_result = UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE;
778 break;
779 default:
780 pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR;
781 }
782 }
783
784 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult",
785 pairing_result,
786 UMA_PAIRING_RESULT_COUNT);
787 }
788
637 } // namespace chromeos 789 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_experimental_chromeos.h ('k') | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698