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

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: 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
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 error_callback_.Run(blink::mojom::WebBluetoothError::CHOOSER_CANCELLED);
Jeffrey Yasskin 2016/06/10 00:49:22 DCHECK(!error_callback_.is_null())? It'll crash in
ortuno 2016/06/10 18:10:07 Done.
224 }
225 }
222 226
223 void BluetoothDeviceChooserController::GetDevice( 227 void BluetoothDeviceChooserController::GetDevice(
224 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, 228 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options,
225 const SuccessCallback& success_callback, 229 const SuccessCallback& success_callback,
226 const ErrorCallback& error_callback) { 230 const ErrorCallback& error_callback) {
227 DCHECK_CURRENTLY_ON(BrowserThread::UI); 231 DCHECK_CURRENTLY_ON(BrowserThread::UI);
228 232
229 // GetDevice should only be called once. 233 // GetDevice should only be called once.
230 DCHECK(success_callback_.is_null()); 234 DCHECK(success_callback_.is_null());
231 DCHECK(error_callback_.is_null()); 235 DCHECK(error_callback_.is_null());
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 483
480 void BluetoothDeviceChooserController::PostErrorCallback( 484 void BluetoothDeviceChooserController::PostErrorCallback(
481 blink::mojom::WebBluetoothError error) { 485 blink::mojom::WebBluetoothError error) {
482 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 486 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
483 FROM_HERE, base::Bind(error_callback_, error))) { 487 FROM_HERE, base::Bind(error_callback_, error))) {
484 LOG(WARNING) << "No TaskRunner."; 488 LOG(WARNING) << "No TaskRunner.";
485 } 489 }
486 } 490 }
487 491
488 } // namespace content 492 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698