| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 #include "base/location.h" |
| 8 #include "base/thread_task_runner_handle.h" |
| 9 |
| 10 namespace device { |
| 11 BluetoothGattNotifySessionWin::BluetoothGattNotifySessionWin( |
| 12 base::WeakPtr<BluetoothRemoteGattCharacteristicWin> characteristic) |
| 13 : is_active_(true), characteristic_(characteristic) {} |
| 14 |
| 15 BluetoothGattNotifySessionWin::~BluetoothGattNotifySessionWin() { |
| 16 if (characteristic_.get() != nullptr && is_active_) |
| 17 characteristic_.get()->StopNotifySession(); |
| 18 } |
| 19 |
| 20 std::string BluetoothGattNotifySessionWin::GetCharacteristicIdentifier() const { |
| 21 if (characteristic_.get() != nullptr) |
| 22 return characteristic_.get()->GetIdentifier(); |
| 23 return std::string(); |
| 24 } |
| 25 |
| 26 bool BluetoothGattNotifySessionWin::IsActive() { |
| 27 return is_active_ && characteristic_.get() != nullptr; |
| 28 } |
| 29 |
| 30 void BluetoothGattNotifySessionWin::Stop(const base::Closure& callback) { |
| 31 if (characteristic_.get() != nullptr && is_active_) |
| 32 characteristic_.get()->StopNotifySession(); |
| 33 is_active_ = false; |
| 34 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 35 } |
| 36 |
| 37 } // namespace device |
| OLD | NEW |