OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/bluetooth/bluetooth_gatt_notify_session_win.h" |
| 6 |
| 7 namespace device { |
| 8 BluetoothGattNotifySessionWin::BluetoothGattNotifySessionWin( |
| 9 base::WeakPtr<BluetoothRemoteGattCharacteristicWin> characteristic) |
| 10 : is_active_(true), characteristic_(characteristic) {} |
| 11 |
| 12 BluetoothGattNotifySessionWin::~BluetoothGattNotifySessionWin() { |
| 13 if (characteristic_.get() != NULL && is_active_) |
| 14 characteristic_.get()->StopNotifySession(); |
| 15 } |
| 16 |
| 17 std::string BluetoothGattNotifySessionWin::GetCharacteristicIdentifier() const { |
| 18 if (characteristic_.get() != NULL) |
| 19 return characteristic_.get()->GetIdentifier(); |
| 20 return std::string(); |
| 21 } |
| 22 |
| 23 bool BluetoothGattNotifySessionWin::IsActive() { |
| 24 return is_active_ && characteristic_.get() != NULL; |
| 25 } |
| 26 |
| 27 void BluetoothGattNotifySessionWin::Stop(const base::Closure& callback) { |
| 28 is_active_ = false; |
| 29 if (characteristic_.get() != NULL) |
| 30 return characteristic_.get()->StopNotifySession(); |
| 31 callback.Run(); |
| 32 } |
| 33 } |
OLD | NEW |