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

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

Issue 2339033003: bluetooth: Perform an LE scan only (Closed)
Patch Set: Add decision to doc Created 4 years, 3 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 | third_party/WebKit/Source/modules/bluetooth/README.md » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/bluetooth/bluetooth_device_chooser_controller.h" 5 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <unordered_set> 9 #include <unordered_set>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 std::unique_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter( 143 std::unique_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter(
144 const mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>& filters) { 144 const mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>& filters) {
145 std::unordered_set<BluetoothUUID, device::BluetoothUUIDHash> services; 145 std::unordered_set<BluetoothUUID, device::BluetoothUUIDHash> services;
146 for (const auto& filter : filters) { 146 for (const auto& filter : filters) {
147 for (const base::Optional<BluetoothUUID>& service : filter->services) { 147 for (const base::Optional<BluetoothUUID>& service : filter->services) {
148 services.insert(service.value()); 148 services.insert(service.value());
149 } 149 }
150 } 150 }
151 // There isn't much support for GATT over BR/EDR from neither platforms nor
152 // devices so performing a Dual scan will find devices that the API is not
153 // able to interact with. To avoid wasting power and confusing users with
154 // devices they are not able to interact with, we only perform an LE Scan.
151 auto discovery_filter = base::MakeUnique<device::BluetoothDiscoveryFilter>( 155 auto discovery_filter = base::MakeUnique<device::BluetoothDiscoveryFilter>(
152 device::BLUETOOTH_TRANSPORT_DUAL); 156 device::BLUETOOTH_TRANSPORT_LE);
153 for (const BluetoothUUID& service : services) { 157 for (const BluetoothUUID& service : services) {
154 discovery_filter->AddUUID(service); 158 discovery_filter->AddUUID(service);
155 } 159 }
156 return discovery_filter; 160 return discovery_filter;
157 } 161 }
158 162
159 void StopDiscoverySession( 163 void StopDiscoverySession(
160 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { 164 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) {
161 // Nothing goes wrong if the discovery session fails to stop, and we don't 165 // Nothing goes wrong if the discovery session fails to stop, and we don't
162 // need to wait for it before letting the user's script proceed, so we ignore 166 // need to wait for it before letting the user's script proceed, so we ignore
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 513
510 void BluetoothDeviceChooserController::PostErrorCallback( 514 void BluetoothDeviceChooserController::PostErrorCallback(
511 blink::mojom::WebBluetoothError error) { 515 blink::mojom::WebBluetoothError error) {
512 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 516 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
513 FROM_HERE, base::Bind(error_callback_, error))) { 517 FROM_HERE, base::Bind(error_callback_, error))) {
514 LOG(WARNING) << "No TaskRunner."; 518 LOG(WARNING) << "No TaskRunner.";
515 } 519 }
516 } 520 }
517 521
518 } // namespace content 522 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/bluetooth/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698