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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 NOTREACHED(); | 192 NOTREACHED(); |
193 return UMARequestDeviceOutcome::SUCCESS; | 193 return UMARequestDeviceOutcome::SUCCESS; |
194 } | 194 } |
195 | 195 |
196 } // namespace | 196 } // namespace |
197 | 197 |
198 BluetoothDeviceChooserController::BluetoothDeviceChooserController( | 198 BluetoothDeviceChooserController::BluetoothDeviceChooserController( |
199 WebBluetoothServiceImpl* web_bluetooth_service, | 199 WebBluetoothServiceImpl* web_bluetooth_service, |
200 RenderFrameHost* render_frame_host, | 200 RenderFrameHost* render_frame_host, |
201 device::BluetoothAdapter* adapter, | 201 device::BluetoothAdapter* adapter) |
202 base::TimeDelta scan_duration) | |
203 : adapter_(adapter), | 202 : adapter_(adapter), |
204 web_bluetooth_service_(web_bluetooth_service), | 203 web_bluetooth_service_(web_bluetooth_service), |
205 render_frame_host_(render_frame_host), | 204 render_frame_host_(render_frame_host), |
206 web_contents_(WebContents::FromRenderFrameHost(render_frame_host_)), | 205 web_contents_(WebContents::FromRenderFrameHost(render_frame_host_)), |
207 discovery_session_timer_( | 206 discovery_session_timer_( |
208 FROM_HERE, | 207 FROM_HERE, |
209 // TODO(jyasskin): Add a way for tests to control the dialog | 208 // TODO(jyasskin): Add a way for tests to control the dialog |
210 // directly, and change this to a reasonable discovery timeout. | 209 // directly, and change this to a reasonable discovery timeout. |
211 scan_duration, | 210 GetContentClient()->browser()->GetBluetoothScanDuration(), |
212 base::Bind(&BluetoothDeviceChooserController::StopDeviceDiscovery, | 211 base::Bind(&BluetoothDeviceChooserController::StopDeviceDiscovery, |
213 // base::Timer guarantees it won't call back after its | 212 // base::Timer guarantees it won't call back after its |
214 // destructor starts. | 213 // destructor starts. |
215 base::Unretained(this)), | 214 base::Unretained(this)), |
216 /*is_repeating=*/false), | 215 /*is_repeating=*/false), |
217 weak_ptr_factory_(this) { | 216 weak_ptr_factory_(this) { |
218 CHECK(adapter_); | 217 CHECK(adapter_); |
219 } | 218 } |
220 | 219 |
221 BluetoothDeviceChooserController::~BluetoothDeviceChooserController() {} | 220 BluetoothDeviceChooserController::~BluetoothDeviceChooserController() {} |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 478 |
480 void BluetoothDeviceChooserController::PostErrorCallback( | 479 void BluetoothDeviceChooserController::PostErrorCallback( |
481 blink::mojom::WebBluetoothError error) { | 480 blink::mojom::WebBluetoothError error) { |
482 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( | 481 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( |
483 FROM_HERE, base::Bind(error_callback_, error))) { | 482 FROM_HERE, base::Bind(error_callback_, error))) { |
484 LOG(WARNING) << "No TaskRunner."; | 483 LOG(WARNING) << "No TaskRunner."; |
485 } | 484 } |
486 } | 485 } |
487 | 486 |
488 } // namespace content | 487 } // namespace content |
OLD | NEW |