summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_api_advertisement.h
blob: f353e54981d0403cb0eb144671dbadd4b31ccc7a (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
// 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 CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_API_ADVERTISEMENT_H_
#define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_API_ADVERTISEMENT_H_

#include <string>

#include "base/macros.h"
#include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.h"
#include "device/bluetooth/bluetooth_advertisement.h"
#include "extensions/browser/api/api_resource.h"
#include "extensions/browser/api/api_resource_manager.h"

namespace device {
class BluetoothAdvertisement;
}  // namespace device

namespace apibtle = extensions::api::bluetooth_low_energy;

namespace extensions {

// Representation of advertisement instances from the "bluetooth" namespace,
// abstracting the underlying BluetoothAdvertisementXxx class. All methods
// must be called on the |kThreadId| thread.
class BluetoothApiAdvertisement : public ApiResource {
 public:
  BluetoothApiAdvertisement(const std::string& owner_extension_id,
                            scoped_refptr<device::BluetoothAdvertisement>);
  ~BluetoothApiAdvertisement() override;

  device::BluetoothAdvertisement* advertisement() {
    return advertisement_.get();
  }

  // Implementations of |BluetoothAdvertisement| require being called on the
  // UI thread.
  static const content::BrowserThread::ID kThreadId =
      content::BrowserThread::UI;

 private:
  friend class ApiResourceManager<BluetoothApiAdvertisement>;

  static const char* service_name() {
    return "BluetoothApiAdvertisementManager";
  }

  // The underlying advertisement instance.
  scoped_refptr<device::BluetoothAdvertisement> advertisement_;

  DISALLOW_COPY_AND_ASSIGN(BluetoothApiAdvertisement);
};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_API_ADVERTISEMENT_H_