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

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1271043002: bluetooth: Add histograms and logging for getPrimaryService() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-uma-connecta-gatt
Patch Set: Merge Created 5 years, 4 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // NETWORK_ERROR Note: 5 // NETWORK_ERROR Note:
6 // When a device can't be found in the BluetoothAdapter, that generally 6 // When a device can't be found in the BluetoothAdapter, that generally
7 // indicates that it's gone out of range. We reject with a NetworkError in that 7 // indicates that it's gone out of range. We reject with a NetworkError in that
8 // case. 8 // case.
9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 std::set<BluetoothUUID> union_of_services(optional_services.begin(), 110 std::set<BluetoothUUID> union_of_services(optional_services.begin(),
111 optional_services.end()); 111 optional_services.end());
112 112
113 for (const content::BluetoothScanFilter& filter : filters) 113 for (const content::BluetoothScanFilter& filter : filters)
114 union_of_services.insert(filter.services.begin(), filter.services.end()); 114 union_of_services.insert(filter.services.begin(), filter.services.end());
115 115
116 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count", 116 UMA_HISTOGRAM_COUNTS_100("Bluetooth.Web.RequestDevice.UnionOfServices.Count",
117 union_of_services.size()); 117 union_of_services.size());
118 } 118 }
119 119
120 enum class UMAGetPrimaryServiceOutcome {
121 SUCCESS,
122 NO_DEVICE,
123 NOT_FOUND,
124 // Note: Add new GetPrimaryService outcomes immediately above this line. Make
125 // sure to update the enum list in tools/metrics/histograms/histograms.xml
126 // accordingly.
127 COUNT
128 };
129
130 void RecordGetPrimaryServiceService(const BluetoothUUID& service) {
131 UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetPrimaryService.Services",
132 HashUUID(service.canonical_value()));
133 }
134
135 void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) {
136 UMA_HISTOGRAM_ENUMERATION(
137 "Bluetooth.Web.GetPrimaryService.Outcome", static_cast<int>(outcome),
138 static_cast<int>(UMAGetPrimaryServiceOutcome::COUNT));
139 }
140
120 enum class UMAConnectGATTOutcome { 141 enum class UMAConnectGATTOutcome {
121 SUCCESS, 142 SUCCESS,
122 NO_DEVICE, 143 NO_DEVICE,
123 UNKNOWN, 144 UNKNOWN,
124 IN_PROGRESS, 145 IN_PROGRESS,
125 FAILED, 146 FAILED,
126 AUTH_FAILED, 147 AUTH_FAILED,
127 AUTH_CANCELED, 148 AUTH_CANCELED,
128 AUTH_REJECTED, 149 AUTH_REJECTED,
129 AUTH_TIMEOUT, 150 AUTH_TIMEOUT,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 device_instance_id, start_time)); 495 device_instance_id, start_time));
475 } 496 }
476 497
477 void BluetoothDispatcherHost::OnGetPrimaryService( 498 void BluetoothDispatcherHost::OnGetPrimaryService(
478 int thread_id, 499 int thread_id,
479 int request_id, 500 int request_id,
480 const std::string& device_instance_id, 501 const std::string& device_instance_id,
481 const std::string& service_uuid) { 502 const std::string& service_uuid) {
482 DCHECK_CURRENTLY_ON(BrowserThread::UI); 503 DCHECK_CURRENTLY_ON(BrowserThread::UI);
483 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE); 504 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE);
505 RecordGetPrimaryServiceService(BluetoothUUID(service_uuid));
484 506
485 // TODO(ortuno): Check if device_instance_id is in "allowed devices" 507 // TODO(ortuno): Check if device_instance_id is in "allowed devices"
486 // https://crbug.com/493459 508 // https://crbug.com/493459
487 // TODO(ortuno): Check if service_uuid is in "allowed services" 509 // TODO(ortuno): Check if service_uuid is in "allowed services"
488 // https://crbug.com/493460 510 // https://crbug.com/493460
489 // For now just wait a fixed time and call OnServiceDiscovered. 511 // For now just wait a fixed time and call OnServiceDiscovered.
490 // TODO(ortuno): Use callback once it's implemented http://crbug.com/484504 512 // TODO(ortuno): Use callback once it's implemented http://crbug.com/484504
491 BrowserThread::PostDelayedTask( 513 BrowserThread::PostDelayedTask(
492 BrowserThread::UI, FROM_HERE, 514 BrowserThread::UI, FROM_HERE,
493 base::Bind(&BluetoothDispatcherHost::OnServicesDiscovered, 515 base::Bind(&BluetoothDispatcherHost::OnServicesDiscovered,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 819
798 void BluetoothDispatcherHost::OnServicesDiscovered( 820 void BluetoothDispatcherHost::OnServicesDiscovered(
799 int thread_id, 821 int thread_id,
800 int request_id, 822 int request_id,
801 const std::string& device_instance_id, 823 const std::string& device_instance_id,
802 const std::string& service_uuid) { 824 const std::string& service_uuid) {
803 DCHECK_CURRENTLY_ON(BrowserThread::UI); 825 DCHECK_CURRENTLY_ON(BrowserThread::UI);
804 826
805 device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id); 827 device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id);
806 if (device == nullptr) { // See "NETWORK_ERROR Note" above. 828 if (device == nullptr) { // See "NETWORK_ERROR Note" above.
829 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NO_DEVICE);
830 VLOG(1) << "Bluetooth Device is no longer in range.";
807 Send(new BluetoothMsg_GetPrimaryServiceError( 831 Send(new BluetoothMsg_GetPrimaryServiceError(
808 thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange)); 832 thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange));
809 return; 833 return;
810 } 834 }
811 for (BluetoothGattService* service : device->GetGattServices()) { 835 for (BluetoothGattService* service : device->GetGattServices()) {
812 if (service->GetUUID().canonical_value() == service_uuid) { 836 if (service->GetUUID().canonical_value() == service_uuid) {
813 // TODO(ortuno): Use generated instance ID instead. 837 // TODO(ortuno): Use generated instance ID instead.
814 // https://crbug.com/495379 838 // https://crbug.com/495379
815 const std::string& service_identifier = service->GetIdentifier(); 839 const std::string& service_identifier = service->GetIdentifier();
816 auto insert_result = service_to_device_.insert( 840 auto insert_result = service_to_device_.insert(
817 make_pair(service_identifier, device_instance_id)); 841 make_pair(service_identifier, device_instance_id));
818 842
819 // If a value is already in map, DCHECK it's valid. 843 // If a value is already in map, DCHECK it's valid.
820 if (!insert_result.second) 844 if (!insert_result.second)
821 DCHECK(insert_result.first->second == device_instance_id); 845 DCHECK(insert_result.first->second == device_instance_id);
822 846
847 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::SUCCESS);
823 Send(new BluetoothMsg_GetPrimaryServiceSuccess(thread_id, request_id, 848 Send(new BluetoothMsg_GetPrimaryServiceSuccess(thread_id, request_id,
824 service_identifier)); 849 service_identifier));
825 return; 850 return;
826 } 851 }
827 } 852 }
853 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NOT_FOUND);
854 VLOG(1) << "No GATT services with UUID: " << service_uuid;
828 Send(new BluetoothMsg_GetPrimaryServiceError( 855 Send(new BluetoothMsg_GetPrimaryServiceError(
829 thread_id, request_id, WebBluetoothError::ServiceNotFound)); 856 thread_id, request_id, WebBluetoothError::ServiceNotFound));
830 } 857 }
831 858
832 void BluetoothDispatcherHost::OnCharacteristicValueRead( 859 void BluetoothDispatcherHost::OnCharacteristicValueRead(
833 int thread_id, 860 int thread_id,
834 int request_id, 861 int request_id,
835 const std::vector<uint8>& value) { 862 const std::vector<uint8>& value) {
836 Send(new BluetoothMsg_ReadCharacteristicValueSuccess(thread_id, request_id, 863 Send(new BluetoothMsg_ReadCharacteristicValueSuccess(thread_id, request_id,
837 value)); 864 value));
(...skipping 14 matching lines...) Expand all
852 879
853 void BluetoothDispatcherHost::OnWriteValueFailed( 880 void BluetoothDispatcherHost::OnWriteValueFailed(
854 int thread_id, 881 int thread_id,
855 int request_id, 882 int request_id,
856 device::BluetoothGattService::GattErrorCode error_code) { 883 device::BluetoothGattService::GattErrorCode error_code) {
857 Send(new BluetoothMsg_WriteCharacteristicValueError( 884 Send(new BluetoothMsg_WriteCharacteristicValueError(
858 thread_id, request_id, TranslateGATTError(error_code))); 885 thread_id, request_id, TranslateGATTError(error_code)));
859 } 886 }
860 887
861 } // namespace content 888 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698