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

Side by Side Diff: device/bluetooth/bluetooth_adapter.h

Issue 1054743003: Add CPP API for BLE advertisments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tentative win fix Created 5 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "device/bluetooth/bluetooth_advertisement.h"
17 #include "device/bluetooth/bluetooth_audio_sink.h" 18 #include "device/bluetooth/bluetooth_audio_sink.h"
18 #include "device/bluetooth/bluetooth_device.h" 19 #include "device/bluetooth/bluetooth_device.h"
19 #include "device/bluetooth/bluetooth_export.h" 20 #include "device/bluetooth/bluetooth_export.h"
20 21
21 namespace device { 22 namespace device {
22 23
24 class BluetoothAdvertisement;
23 class BluetoothDiscoveryFilter; 25 class BluetoothDiscoveryFilter;
24 class BluetoothDiscoverySession; 26 class BluetoothDiscoverySession;
25 class BluetoothGattCharacteristic; 27 class BluetoothGattCharacteristic;
26 class BluetoothGattDescriptor; 28 class BluetoothGattDescriptor;
27 class BluetoothGattService; 29 class BluetoothGattService;
28 class BluetoothSocket; 30 class BluetoothSocket;
29 class BluetoothUUID; 31 class BluetoothUUID;
30 struct BluetoothAdapterDeleter; 32 struct BluetoothAdapterDeleter;
31 33
32 // BluetoothAdapter represents a local Bluetooth adapter which may be used to 34 // BluetoothAdapter represents a local Bluetooth adapter which may be used to
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 typedef base::Callback<void(scoped_ptr<BluetoothDiscoverySession>)> 185 typedef base::Callback<void(scoped_ptr<BluetoothDiscoverySession>)>
184 DiscoverySessionCallback; 186 DiscoverySessionCallback;
185 typedef std::vector<BluetoothDevice*> DeviceList; 187 typedef std::vector<BluetoothDevice*> DeviceList;
186 typedef std::vector<const BluetoothDevice*> ConstDeviceList; 188 typedef std::vector<const BluetoothDevice*> ConstDeviceList;
187 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> 189 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)>
188 CreateServiceCallback; 190 CreateServiceCallback;
189 typedef base::Callback<void(const std::string& message)> 191 typedef base::Callback<void(const std::string& message)>
190 CreateServiceErrorCallback; 192 CreateServiceErrorCallback;
191 typedef base::Callback<void(scoped_refptr<BluetoothAudioSink>)> 193 typedef base::Callback<void(scoped_refptr<BluetoothAudioSink>)>
192 AcquiredCallback; 194 AcquiredCallback;
195 typedef base::Callback<void(scoped_refptr<BluetoothAdvertisement>)>
196 CreateAdvertisementCallback;
197 typedef base::Callback<void(BluetoothAdvertisement::ErrorCode)>
198 CreateAdvertisementErrorCallback;
193 199
194 // Returns a weak pointer to a new adapter. For platforms with asynchronous 200 // Returns a weak pointer to a new adapter. For platforms with asynchronous
195 // initialization, the returned adapter will run the |init_callback| once 201 // initialization, the returned adapter will run the |init_callback| once
196 // asynchronous initialization is complete. 202 // asynchronous initialization is complete.
197 // Caution: The returned pointer also transfers ownership of the adapter. The 203 // Caution: The returned pointer also transfers ownership of the adapter. The
198 // caller is expected to call |AddRef()| on the returned pointer, typically by 204 // caller is expected to call |AddRef()| on the returned pointer, typically by
199 // storing it into a |scoped_refptr|. 205 // storing it into a |scoped_refptr|.
200 static base::WeakPtr<BluetoothAdapter> CreateAdapter( 206 static base::WeakPtr<BluetoothAdapter> CreateAdapter(
201 const InitCallback& init_callback); 207 const InitCallback& init_callback);
202 208
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // Creates and registers a BluetoothAudioSink with |options|. If the fields in 368 // Creates and registers a BluetoothAudioSink with |options|. If the fields in
363 // |options| are not specified, the default values will be used. |callback| 369 // |options| are not specified, the default values will be used. |callback|
364 // will be called on success with a BluetoothAudioSink which is to be owned by 370 // will be called on success with a BluetoothAudioSink which is to be owned by
365 // the caller of this method. |error_callback| will be called on failure with 371 // the caller of this method. |error_callback| will be called on failure with
366 // a message indicating the cause. 372 // a message indicating the cause.
367 virtual void RegisterAudioSink( 373 virtual void RegisterAudioSink(
368 const BluetoothAudioSink::Options& options, 374 const BluetoothAudioSink::Options& options,
369 const AcquiredCallback& callback, 375 const AcquiredCallback& callback,
370 const BluetoothAudioSink::ErrorCallback& error_callback) = 0; 376 const BluetoothAudioSink::ErrorCallback& error_callback) = 0;
371 377
378 // Creates and registers an advertisement for broadcast over the LE channel.
379 // The created advertisement will be returned via the success callback.
380 virtual void RegisterAdvertisement(
381 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
382 const CreateAdvertisementCallback& callback,
383 const CreateAdvertisementErrorCallback& error_callback) = 0;
384
372 protected: 385 protected:
373 friend class base::RefCounted<BluetoothAdapter>; 386 friend class base::RefCounted<BluetoothAdapter>;
374 friend class BluetoothDiscoverySession; 387 friend class BluetoothDiscoverySession;
375 388
376 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; 389 typedef std::map<const std::string, BluetoothDevice*> DevicesMap;
377 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority> 390 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority>
378 PairingDelegatePair; 391 PairingDelegatePair;
379 392
380 BluetoothAdapter(); 393 BluetoothAdapter();
381 virtual ~BluetoothAdapter(); 394 virtual ~BluetoothAdapter();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 std::set<BluetoothDiscoverySession*> discovery_sessions_; 488 std::set<BluetoothDiscoverySession*> discovery_sessions_;
476 489
477 // Note: This should remain the last member so it'll be destroyed and 490 // Note: This should remain the last member so it'll be destroyed and
478 // invalidate its weak pointers before any other members are destroyed. 491 // invalidate its weak pointers before any other members are destroyed.
479 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; 492 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
480 }; 493 };
481 494
482 } // namespace device 495 } // namespace device
483 496
484 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 497 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698