forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfake_bluetooth_discovery_delegate.cc
56 lines (42 loc) · 1.71 KB
/
fake_bluetooth_discovery_delegate.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/bluetooth_config/fake_bluetooth_discovery_delegate.h"
#include "base/bind.h"
#include "base/run_loop.h"
namespace chromeos {
namespace bluetooth_config {
FakeBluetoothDiscoveryDelegate::FakeBluetoothDiscoveryDelegate() = default;
FakeBluetoothDiscoveryDelegate::~FakeBluetoothDiscoveryDelegate() = default;
mojo::PendingRemote<mojom::BluetoothDiscoveryDelegate>
FakeBluetoothDiscoveryDelegate::GeneratePendingRemote() {
auto pending_remote = receiver_.BindNewPipeAndPassRemote();
receiver_.set_disconnect_handler(base::BindOnce(
&FakeBluetoothDiscoveryDelegate::OnDisconnected, base::Unretained(this)));
return pending_remote;
}
void FakeBluetoothDiscoveryDelegate::DisconnectMojoPipe() {
receiver_.reset();
// Allow the disconnection to propagate.
base::RunLoop().RunUntilIdle();
}
bool FakeBluetoothDiscoveryDelegate::IsMojoPipeConnected() const {
return receiver_.is_bound();
}
void FakeBluetoothDiscoveryDelegate::OnBluetoothDiscoveryStarted(
mojo::PendingRemote<mojom::DevicePairingHandler> handler) {
pairing_handler_.Bind(std::move(handler));
++num_start_callbacks_;
}
void FakeBluetoothDiscoveryDelegate::OnBluetoothDiscoveryStopped() {
++num_stop_callbacks_;
}
void FakeBluetoothDiscoveryDelegate::OnDiscoveredDevicesListChanged(
std::vector<mojom::BluetoothDevicePropertiesPtr> discovered_devices) {
discovered_devices_list_ = std::move(discovered_devices);
}
void FakeBluetoothDiscoveryDelegate::OnDisconnected() {
receiver_.reset();
}
} // namespace bluetooth_config
} // namespace chromeos