summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/bluetooth_advertisement_chromeos.h
blob: aeb59b7c17d96e3557812db1c323de079835a434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_

#include "base/macros.h"
#include "chromeos/dbus/bluetooth_le_advertisement_service_provider.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_advertisement.h"
#include "device/bluetooth/bluetooth_export.h"

namespace chromeos {

class BluetoothLEAdvertisementServiceProvider;
class BluetoothAdapterChromeOS;

// The BluetoothAdvertisementChromeOS class implements BluetoothAdvertisement
// for the Chrome OS platform.
class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS
    : public device::BluetoothAdvertisement,
      public BluetoothLEAdvertisementServiceProvider::Delegate {
 public:
  BluetoothAdvertisementChromeOS(
      scoped_ptr<device::BluetoothAdvertisement::Data> data,
      scoped_refptr<BluetoothAdapterChromeOS> adapter);

  // BluetoothAdvertisement overrides:
  void Unregister(const SuccessCallback& success_callback,
                  const ErrorCallback& error_callback) override;

  // BluetoothLEAdvertisementServiceProvider::Delegate overrides:
  void Released() override;

  void Register(
      const base::Closure& success_callback,
      const device::BluetoothAdapter::CreateAdvertisementErrorCallback&
          error_callback);

  // Used from tests to be able to trigger events on the fake advertisement
  // provider.
  BluetoothLEAdvertisementServiceProvider* provider() {
    return provider_.get();
  }

 private:
  ~BluetoothAdvertisementChromeOS() override;

  // Adapter this advertisement is advertising on.
  scoped_refptr<BluetoothAdapterChromeOS> adapter_;
  scoped_ptr<BluetoothLEAdvertisementServiceProvider> provider_;

  DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementChromeOS);
};

}  // namespace chromeos

#endif  // DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_