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