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

Unified Diff: device/bluetooth/test/fake_peripheral.cc

Issue 2921233002: Revert of bluetooth: Implement simulateGATTConnectionResponse() (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/test/fake_peripheral.cc
diff --git a/device/bluetooth/test/fake_peripheral.cc b/device/bluetooth/test/fake_peripheral.cc
index a8524e2b3abbac5ed4589b1be8cec23248b6a56a..acf93c736d8f69ce17be05c4cf339d7072f23f9d 100644
--- a/device/bluetooth/test/fake_peripheral.cc
+++ b/device/bluetooth/test/fake_peripheral.cc
@@ -3,8 +3,6 @@
// found in the LICENSE file.
#include "device/bluetooth/test/fake_peripheral.h"
-
-#include "base/memory/weak_ptr.h"
namespace bluetooth {
@@ -12,9 +10,7 @@
const std::string& address)
: device::BluetoothDevice(fake_central),
address_(address),
- system_connected_(false),
- gatt_connected_(false),
- weak_ptr_factory_(this) {}
+ gatt_connected_(false) {}
FakePeripheral::~FakePeripheral() {}
@@ -22,18 +18,12 @@
name_ = std::move(name);
}
-void FakePeripheral::SetSystemConnected(bool connected) {
- system_connected_ = connected;
+void FakePeripheral::SetGattConnected(bool connected) {
+ gatt_connected_ = connected;
}
void FakePeripheral::SetServiceUUIDs(UUIDSet service_uuids) {
service_uuids_ = std::move(service_uuids);
-}
-
-void FakePeripheral::SetNextGATTConnectionResponse(uint16_t code) {
- DCHECK(!next_connection_response_);
- DCHECK(create_gatt_connection_error_callbacks_.empty());
- next_connection_response_ = code;
}
uint32_t FakePeripheral::GetBluetoothClass() const {
@@ -102,10 +92,7 @@
}
bool FakePeripheral::IsGattConnected() const {
- // TODO(crbug.com/728870): Return gatt_connected_ only once system connected
- // peripherals are supported and Web Bluetooth uses them. See issue for more
- // details.
- return system_connected_ || gatt_connected_;
+ return gatt_connected_;
}
bool FakePeripheral::IsConnectable() const {
@@ -197,43 +184,11 @@
NOTREACHED();
}
-void FakePeripheral::CreateGattConnection(
- const GattConnectionCallback& callback,
- const ConnectErrorCallback& error_callback) {
- create_gatt_connection_success_callbacks_.push_back(callback);
- create_gatt_connection_error_callbacks_.push_back(error_callback);
-
- // TODO(crbug.com/728870): Stop overriding CreateGattConnection once
- // IsGattConnected() is fixed. See issue for more details.
- if (gatt_connected_)
- return DidConnectGatt();
-
- CreateGattConnectionImpl();
-}
-
void FakePeripheral::CreateGattConnectionImpl() {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakePeripheral::DispatchConnectionResponse,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void FakePeripheral::DispatchConnectionResponse() {
- DCHECK(next_connection_response_);
-
- uint16_t code = next_connection_response_.value();
- next_connection_response_.reset();
-
- if (code == mojom::kHCISuccess) {
- gatt_connected_ = true;
- DidConnectGatt();
- } else if (code == mojom::kHCIConnectionTimeout) {
- DidFailToConnectGatt(ERROR_FAILED);
- } else {
- DidFailToConnectGatt(ERROR_UNKNOWN);
- }
+ NOTREACHED();
}
void FakePeripheral::DisconnectGatt() {
+ NOTREACHED();
}
-
} // namespace bluetooth

Powered by Google App Engine
This is Rietveld 408576698