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

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

Issue 2506163002: Increase Web Bluetooth device scanning duration (Closed)
Patch Set: increase Web Bluetooth device scanning duration Created 4 years, 1 month 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace content { 48 namespace content {
49 49
50 bool BluetoothDeviceChooserController::use_test_scan_duration_ = false; 50 bool BluetoothDeviceChooserController::use_test_scan_duration_ = false;
51 51
52 namespace { 52 namespace {
53 constexpr size_t kMaxLengthForDeviceName = 53 constexpr size_t kMaxLengthForDeviceName =
54 29; // max length of device name in filter. 54 29; // max length of device name in filter.
55 55
56 // The duration of a Bluetooth Scan in seconds. 56 // The duration of a Bluetooth Scan in seconds.
57 constexpr int kScanDuration = 10; 57 constexpr int kScanDuration = 60;
58 constexpr int kTestScanDuration = 0; 58 constexpr int kTestScanDuration = 0;
59 59
60 void LogRequestDeviceOptions( 60 void LogRequestDeviceOptions(
61 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) { 61 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
62 VLOG(1) << "requestDevice called with the following filters: "; 62 VLOG(1) << "requestDevice called with the following filters: ";
63 int i = 0; 63 int i = 0;
64 for (const auto& filter : options->filters) { 64 for (const auto& filter : options->filters) {
65 VLOG(1) << "Filter #" << ++i; 65 VLOG(1) << "Filter #" << ++i;
66 if (!filter->name.is_null()) 66 if (!filter->name.is_null())
67 VLOG(1) << "Name: " << filter->name; 67 VLOG(1) << "Name: " << filter->name;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return UMARequestDeviceOutcome::ADAPTER_OFF_HELP_LINK_PRESSED; 190 return UMARequestDeviceOutcome::ADAPTER_OFF_HELP_LINK_PRESSED;
191 case BluetoothChooser::Event::SHOW_NEED_LOCATION_HELP: 191 case BluetoothChooser::Event::SHOW_NEED_LOCATION_HELP:
192 return UMARequestDeviceOutcome::NEED_LOCATION_HELP_LINK_PRESSED; 192 return UMARequestDeviceOutcome::NEED_LOCATION_HELP_LINK_PRESSED;
193 case BluetoothChooser::Event::SELECTED: 193 case BluetoothChooser::Event::SELECTED:
194 // We can't know if we are going to send a success message yet because 194 // We can't know if we are going to send a success message yet because
195 // the device could have vanished. This event should be histogramed 195 // the device could have vanished. This event should be histogramed
196 // manually after checking if the device is still around. 196 // manually after checking if the device is still around.
197 NOTREACHED(); 197 NOTREACHED();
198 return UMARequestDeviceOutcome::SUCCESS; 198 return UMARequestDeviceOutcome::SUCCESS;
199 case BluetoothChooser::Event::RESCAN: 199 case BluetoothChooser::Event::RESCAN:
200 // Rescanning doesn't result in a IPC message for the request being sent 200 return UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_RESCAN;
201 // so no need to histogram it.
202 NOTREACHED();
203 return UMARequestDeviceOutcome::SUCCESS;
204 } 201 }
205 NOTREACHED(); 202 NOTREACHED();
206 return UMARequestDeviceOutcome::SUCCESS; 203 return UMARequestDeviceOutcome::SUCCESS;
207 } 204 }
208 205
209 } // namespace 206 } // namespace
210 207
211 BluetoothDeviceChooserController::BluetoothDeviceChooserController( 208 BluetoothDeviceChooserController::BluetoothDeviceChooserController(
212 WebBluetoothServiceImpl* web_bluetooth_service, 209 WebBluetoothServiceImpl* web_bluetooth_service,
213 RenderFrameHost* render_frame_host, 210 RenderFrameHost* render_frame_host,
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 476
480 void BluetoothDeviceChooserController::OnBluetoothChooserEvent( 477 void BluetoothDeviceChooserController::OnBluetoothChooserEvent(
481 BluetoothChooser::Event event, 478 BluetoothChooser::Event event,
482 const std::string& device_address) { 479 const std::string& device_address) {
483 DCHECK_CURRENTLY_ON(BrowserThread::UI); 480 DCHECK_CURRENTLY_ON(BrowserThread::UI);
484 // Shouldn't recieve an event from a closed chooser. 481 // Shouldn't recieve an event from a closed chooser.
485 DCHECK(chooser_.get()); 482 DCHECK(chooser_.get());
486 483
487 switch (event) { 484 switch (event) {
488 case BluetoothChooser::Event::RESCAN: 485 case BluetoothChooser::Event::RESCAN:
486 RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event));
489 PopulateConnectedDevices(); 487 PopulateConnectedDevices();
490 DCHECK(chooser_); 488 DCHECK(chooser_);
491 StartDeviceDiscovery(); 489 StartDeviceDiscovery();
492 // No need to close the chooser so we return. 490 // No need to close the chooser so we return.
493 return; 491 return;
494 case BluetoothChooser::Event::DENIED_PERMISSION: 492 case BluetoothChooser::Event::DENIED_PERMISSION:
495 RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event)); 493 RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event));
496 PostErrorCallback(blink::mojom::WebBluetoothResult:: 494 PostErrorCallback(blink::mojom::WebBluetoothResult::
497 CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN); 495 CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN);
498 break; 496 break;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 533
536 void BluetoothDeviceChooserController::PostErrorCallback( 534 void BluetoothDeviceChooserController::PostErrorCallback(
537 blink::mojom::WebBluetoothResult error) { 535 blink::mojom::WebBluetoothResult error) {
538 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 536 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
539 FROM_HERE, base::Bind(error_callback_, error))) { 537 FROM_HERE, base::Bind(error_callback_, error))) {
540 LOG(WARNING) << "No TaskRunner."; 538 LOG(WARNING) << "No TaskRunner.";
541 } 539 }
542 } 540 }
543 541
544 } // namespace content 542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698