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