OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
CONNECTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
CONNECTION_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
CONNECTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
CONNECTION_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "device/bluetooth/bluetooth_gatt_connection.h" | 11 #include "device/bluetooth/bluetooth_gatt_connection.h" |
11 #include "extensions/browser/api/api_resource.h" | 12 #include "extensions/browser/api/api_resource.h" |
12 #include "extensions/browser/api/api_resource_manager.h" | 13 #include "extensions/browser/api/api_resource_manager.h" |
13 | 14 |
14 namespace extensions { | 15 namespace extensions { |
15 | 16 |
16 // An ApiResource wrapper for a device::BluetoothGattConnection. | 17 // An ApiResource wrapper for a device::BluetoothGattConnection. |
17 class BluetoothLowEnergyConnection : public ApiResource { | 18 class BluetoothLowEnergyConnection : public ApiResource { |
18 public: | 19 public: |
19 explicit BluetoothLowEnergyConnection( | 20 explicit BluetoothLowEnergyConnection( |
20 bool persistent, | 21 bool persistent, |
21 const std::string& owner_extension_id, | 22 const std::string& owner_extension_id, |
22 scoped_ptr<device::BluetoothGattConnection> connection); | 23 std::unique_ptr<device::BluetoothGattConnection> connection); |
23 ~BluetoothLowEnergyConnection() override; | 24 ~BluetoothLowEnergyConnection() override; |
24 | 25 |
25 // Returns a pointer to the underlying connection object. | 26 // Returns a pointer to the underlying connection object. |
26 device::BluetoothGattConnection* GetConnection() const; | 27 device::BluetoothGattConnection* GetConnection() const; |
27 | 28 |
28 // ApiResource override. | 29 // ApiResource override. |
29 bool IsPersistent() const override; | 30 bool IsPersistent() const override; |
30 | 31 |
31 // This resource should be managed on the UI thread. | 32 // This resource should be managed on the UI thread. |
32 static const content::BrowserThread::ID kThreadId = | 33 static const content::BrowserThread::ID kThreadId = |
33 content::BrowserThread::UI; | 34 content::BrowserThread::UI; |
34 | 35 |
35 private: | 36 private: |
36 friend class ApiResourceManager<BluetoothLowEnergyConnection>; | 37 friend class ApiResourceManager<BluetoothLowEnergyConnection>; |
37 static const char* service_name() { | 38 static const char* service_name() { |
38 return "BluetoothLowEnergyConnectionManager"; | 39 return "BluetoothLowEnergyConnectionManager"; |
39 } | 40 } |
40 | 41 |
41 // True, if this resource should be persistent. | 42 // True, if this resource should be persistent. |
42 bool persistent_; | 43 bool persistent_; |
43 | 44 |
44 // The connection is owned by this instance and will automatically disconnect | 45 // The connection is owned by this instance and will automatically disconnect |
45 // when deleted. | 46 // when deleted. |
46 scoped_ptr<device::BluetoothGattConnection> connection_; | 47 std::unique_ptr<device::BluetoothGattConnection> connection_; |
47 | 48 |
48 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection); | 49 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection); |
49 }; | 50 }; |
50 | 51 |
51 } // namespace extensions | 52 } // namespace extensions |
52 | 53 |
53 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER
GY_CONNECTION_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER
GY_CONNECTION_H_ |
OLD | NEW |