| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |