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

Side by Side Diff: device/bluetooth/bluetooth_adapter_chromeos.cc

Issue 1054743003: Add CPP API for BLE advertisments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "device/bluetooth/bluetooth_adapter_chromeos.h" 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "chromeos/dbus/bluetooth_adapter_client.h" 17 #include "chromeos/dbus/bluetooth_adapter_client.h"
18 #include "chromeos/dbus/bluetooth_agent_manager_client.h" 18 #include "chromeos/dbus/bluetooth_agent_manager_client.h"
19 #include "chromeos/dbus/bluetooth_agent_service_provider.h" 19 #include "chromeos/dbus/bluetooth_agent_service_provider.h"
20 #include "chromeos/dbus/bluetooth_device_client.h" 20 #include "chromeos/dbus/bluetooth_device_client.h"
21 #include "chromeos/dbus/bluetooth_input_client.h" 21 #include "chromeos/dbus/bluetooth_input_client.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 22 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" 23 #include "device/bluetooth/bluetooth_adapter_profile_chromeos.h"
24 #include "device/bluetooth/bluetooth_advertisement_chromeos.h"
24 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" 25 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h"
25 #include "device/bluetooth/bluetooth_device.h" 26 #include "device/bluetooth/bluetooth_device.h"
26 #include "device/bluetooth/bluetooth_device_chromeos.h" 27 #include "device/bluetooth/bluetooth_device_chromeos.h"
27 #include "device/bluetooth/bluetooth_pairing_chromeos.h" 28 #include "device/bluetooth/bluetooth_pairing_chromeos.h"
28 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" 29 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h"
29 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" 30 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h"
30 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" 31 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h"
31 #include "device/bluetooth/bluetooth_socket_chromeos.h" 32 #include "device/bluetooth/bluetooth_socket_chromeos.h"
32 #include "device/bluetooth/bluetooth_socket_thread.h" 33 #include "device/bluetooth/bluetooth_socket_thread.h"
33 #include "device/bluetooth/bluetooth_uuid.h" 34 #include "device/bluetooth/bluetooth_uuid.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 324 }
324 scoped_refptr<BluetoothAudioSinkChromeOS> audio_sink( 325 scoped_refptr<BluetoothAudioSinkChromeOS> audio_sink(
325 new BluetoothAudioSinkChromeOS(this)); 326 new BluetoothAudioSinkChromeOS(this));
326 audio_sink->Register( 327 audio_sink->Register(
327 options, base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink, 328 options, base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink,
328 weak_ptr_factory_.GetWeakPtr(), callback, 329 weak_ptr_factory_.GetWeakPtr(), callback,
329 error_callback, audio_sink), 330 error_callback, audio_sink),
330 error_callback); 331 error_callback);
331 } 332 }
332 333
334 void BluetoothAdapterChromeOS::RegisterAdvertisement(
335 scoped_ptr<device::BluetoothAdvertisement::Data> advertisement_data,
336 const CreateAdvertisementCallback& callback,
337 const CreateAdvertisementErrorCallback& error_callback) {
338 scoped_refptr<BluetoothAdvertisementChromeOS> advertisement(
339 new BluetoothAdvertisementChromeOS(advertisement_data.Pass(), this));
340 advertisement->Register(base::Bind(callback, advertisement), error_callback);
341 }
342
333 void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( 343 void BluetoothAdapterChromeOS::RemovePairingDelegateInternal(
334 BluetoothDevice::PairingDelegate* pairing_delegate) { 344 BluetoothDevice::PairingDelegate* pairing_delegate) {
335 // Before removing a pairing delegate make sure that there aren't any devices 345 // Before removing a pairing delegate make sure that there aren't any devices
336 // currently using it; if there are, clear the pairing context which will 346 // currently using it; if there are, clear the pairing context which will
337 // make any responses no-ops. 347 // make any responses no-ops.
338 for (DevicesMap::iterator iter = devices_.begin(); 348 for (DevicesMap::iterator iter = devices_.begin();
339 iter != devices_.end(); ++iter) { 349 iter != devices_.end(); ++iter) {
340 BluetoothDeviceChromeOS* device_chromeos = 350 BluetoothDeviceChromeOS* device_chromeos =
341 static_cast<BluetoothDeviceChromeOS*>(iter->second); 351 static_cast<BluetoothDeviceChromeOS*>(iter->second);
342 352
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1287
1278 // If the queued request resulted in a pending call, then let it 1288 // If the queued request resulted in a pending call, then let it
1279 // asynchonously process the remaining queued requests once the pending 1289 // asynchonously process the remaining queued requests once the pending
1280 // call returns. 1290 // call returns.
1281 if (discovery_request_pending_) 1291 if (discovery_request_pending_)
1282 return; 1292 return;
1283 } 1293 }
1284 } 1294 }
1285 1295
1286 } // namespace chromeos 1296 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698