Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2075)

Side by Side Diff: device/bluetooth/bluetooth_gatt_notify_session_win.cc

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 is_active_ = false;
32 if (characteristic_.get() != nullptr)
33 characteristic_.get()->StopNotifySession();
34 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
35 }
36
37 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698