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

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

Issue 2030973002: bluetooth: Handle two consecutives requestDevice calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Improve comment Created 4 years, 6 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 | content/browser/bluetooth/web_bluetooth_service_impl.cc » ('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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 scan_duration, 211 scan_duration,
212 base::Bind(&BluetoothDeviceChooserController::StopDeviceDiscovery, 212 base::Bind(&BluetoothDeviceChooserController::StopDeviceDiscovery,
213 // base::Timer guarantees it won't call back after its 213 // base::Timer guarantees it won't call back after its
214 // destructor starts. 214 // destructor starts.
215 base::Unretained(this)), 215 base::Unretained(this)),
216 /*is_repeating=*/false), 216 /*is_repeating=*/false),
217 weak_ptr_factory_(this) { 217 weak_ptr_factory_(this) {
218 CHECK(adapter_); 218 CHECK(adapter_);
219 } 219 }
220 220
221 BluetoothDeviceChooserController::~BluetoothDeviceChooserController() {} 221 BluetoothDeviceChooserController::~BluetoothDeviceChooserController() {
222 if (chooser_) {
223 DCHECK(!error_callback_.is_null());
224 error_callback_.Run(blink::mojom::WebBluetoothError::CHOOSER_CANCELLED);
225 }
226 }
222 227
223 void BluetoothDeviceChooserController::GetDevice( 228 void BluetoothDeviceChooserController::GetDevice(
224 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, 229 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options,
225 const SuccessCallback& success_callback, 230 const SuccessCallback& success_callback,
226 const ErrorCallback& error_callback) { 231 const ErrorCallback& error_callback) {
227 DCHECK_CURRENTLY_ON(BrowserThread::UI); 232 DCHECK_CURRENTLY_ON(BrowserThread::UI);
228 233
229 // GetDevice should only be called once. 234 // GetDevice should only be called once.
230 DCHECK(success_callback_.is_null()); 235 DCHECK(success_callback_.is_null());
231 DCHECK(error_callback_.is_null()); 236 DCHECK(error_callback_.is_null());
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 484
480 void BluetoothDeviceChooserController::PostErrorCallback( 485 void BluetoothDeviceChooserController::PostErrorCallback(
481 blink::mojom::WebBluetoothError error) { 486 blink::mojom::WebBluetoothError error) {
482 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 487 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
483 FROM_HERE, base::Bind(error_callback_, error))) { 488 FROM_HERE, base::Bind(error_callback_, error))) {
484 LOG(WARNING) << "No TaskRunner."; 489 LOG(WARNING) << "No TaskRunner.";
485 } 490 }
486 } 491 }
487 492
488 } // namespace content 493 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/bluetooth/web_bluetooth_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698