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

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

Issue 2353133005: Add the chrome.bluetoothLowEnergy.setAdvertisingInterval API. (Closed)
Patch Set: . Created 4 years, 2 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/containers/scoped_ptr_hash_map.h" 18 #include "base/containers/scoped_ptr_hash_map.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/time/time.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "device/bluetooth/bluetooth_advertisement.h" 23 #include "device/bluetooth/bluetooth_advertisement.h"
23 #include "device/bluetooth/bluetooth_audio_sink.h" 24 #include "device/bluetooth/bluetooth_audio_sink.h"
24 #include "device/bluetooth/bluetooth_device.h" 25 #include "device/bluetooth/bluetooth_device.h"
25 #include "device/bluetooth/bluetooth_export.h" 26 #include "device/bluetooth/bluetooth_export.h"
26 27
27 namespace device { 28 namespace device {
28 29
29 class BluetoothAdvertisement; 30 class BluetoothAdvertisement;
30 class BluetoothDiscoveryFilter; 31 class BluetoothDiscoveryFilter;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 using ConstDeviceList = std::vector<const BluetoothDevice*>; 238 using ConstDeviceList = std::vector<const BluetoothDevice*>;
238 using UUIDList = std::vector<BluetoothUUID>; 239 using UUIDList = std::vector<BluetoothUUID>;
239 using CreateServiceCallback = 240 using CreateServiceCallback =
240 base::Callback<void(scoped_refptr<BluetoothSocket>)>; 241 base::Callback<void(scoped_refptr<BluetoothSocket>)>;
241 using CreateServiceErrorCallback = 242 using CreateServiceErrorCallback =
242 base::Callback<void(const std::string& message)>; 243 base::Callback<void(const std::string& message)>;
243 using AcquiredCallback = 244 using AcquiredCallback =
244 base::Callback<void(scoped_refptr<BluetoothAudioSink>)>; 245 base::Callback<void(scoped_refptr<BluetoothAudioSink>)>;
245 using CreateAdvertisementCallback = 246 using CreateAdvertisementCallback =
246 base::Callback<void(scoped_refptr<BluetoothAdvertisement>)>; 247 base::Callback<void(scoped_refptr<BluetoothAdvertisement>)>;
247 using CreateAdvertisementErrorCallback = 248 using AdvertisementErrorCallback =
248 base::Callback<void(BluetoothAdvertisement::ErrorCode)>; 249 base::Callback<void(BluetoothAdvertisement::ErrorCode)>;
249 250
250 // Returns a weak pointer to a new adapter. For platforms with asynchronous 251 // Returns a weak pointer to a new adapter. For platforms with asynchronous
251 // initialization, the returned adapter will run the |init_callback| once 252 // initialization, the returned adapter will run the |init_callback| once
252 // asynchronous initialization is complete. 253 // asynchronous initialization is complete.
253 // Caution: The returned pointer also transfers ownership of the adapter. The 254 // Caution: The returned pointer also transfers ownership of the adapter. The
254 // caller is expected to call |AddRef()| on the returned pointer, typically by 255 // caller is expected to call |AddRef()| on the returned pointer, typically by
255 // storing it into a |scoped_refptr|. 256 // storing it into a |scoped_refptr|.
256 static base::WeakPtr<BluetoothAdapter> CreateAdapter( 257 static base::WeakPtr<BluetoothAdapter> CreateAdapter(
257 const InitCallback& init_callback); 258 const InitCallback& init_callback);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 const AcquiredCallback& callback, 432 const AcquiredCallback& callback,
432 const BluetoothAudioSink::ErrorCallback& error_callback) = 0; 433 const BluetoothAudioSink::ErrorCallback& error_callback) = 0;
433 434
434 // Creates and registers an advertisement for broadcast over the LE channel. 435 // Creates and registers an advertisement for broadcast over the LE channel.
435 // The created advertisement will be returned via the success callback. An 436 // The created advertisement will be returned via the success callback. An
436 // advertisement can unregister itself at any time by calling its unregister 437 // advertisement can unregister itself at any time by calling its unregister
437 // function. 438 // function.
438 virtual void RegisterAdvertisement( 439 virtual void RegisterAdvertisement(
439 std::unique_ptr<BluetoothAdvertisement::Data> advertisement_data, 440 std::unique_ptr<BluetoothAdvertisement::Data> advertisement_data,
440 const CreateAdvertisementCallback& callback, 441 const CreateAdvertisementCallback& callback,
441 const CreateAdvertisementErrorCallback& error_callback) = 0; 442 const AdvertisementErrorCallback& error_callback) = 0;
443
444 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
ortuno 2016/09/22 03:02:25 I think we still want device/bluetooth tests. It d
445 // Sets the interval between two consecutive advertisements. Valid ranges
446 // for the interval are from 20ms to 10.24 seconds, with min <= max.
ortuno 2016/09/22 03:02:25 nit: Could you add the same caveats as the chrome
447 virtual void SetAdvertisingInterval(
ortuno 2016/09/21 23:26:11 Wouldn't this fit better as an argument of Registe
448 const base::TimeDelta& min,
449 const base::TimeDelta& max,
450 const base::Closure& callback,
451 const AdvertisementErrorCallback& error_callback) = 0;
452 #endif
442 453
443 // Returns the local GATT services associated with this adapter with the 454 // Returns the local GATT services associated with this adapter with the
444 // given identifier. Returns NULL if the service doesn't exist. 455 // given identifier. Returns NULL if the service doesn't exist.
445 virtual BluetoothLocalGattService* GetGattService( 456 virtual BluetoothLocalGattService* GetGattService(
446 const std::string& identifier) const = 0; 457 const std::string& identifier) const = 0;
447 458
448 // The following methods are used to send various events to observers. 459 // The following methods are used to send various events to observers.
449 void NotifyAdapterPoweredChanged(bool powered); 460 void NotifyAdapterPoweredChanged(bool powered);
450 void NotifyDeviceChanged(BluetoothDevice* device); 461 void NotifyDeviceChanged(BluetoothDevice* device);
451 462
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 std::set<BluetoothDiscoverySession*> discovery_sessions_; 624 std::set<BluetoothDiscoverySession*> discovery_sessions_;
614 625
615 // Note: This should remain the last member so it'll be destroyed and 626 // Note: This should remain the last member so it'll be destroyed and
616 // invalidate its weak pointers before any other members are destroyed. 627 // invalidate its weak pointers before any other members are destroyed.
617 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; 628 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
618 }; 629 };
619 630
620 } // namespace device 631 } // namespace device
621 632
622 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 633 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698