Commit dbcab207 authored by George Burgess IV's avatar George Burgess IV Committed by Commit Bot

bluetooth: return after running a callback

Running this callback twice seems unintended, given that we `std::move`
it at each call.

Bug: None
Change-Id: I0e9a19fd0caf255bcd817fffa6cf95b621fb6eaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2203477Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769977}
parent c4317ec7
...@@ -204,6 +204,7 @@ void FakeCentral::SimulateGATTDisconnection( ...@@ -204,6 +204,7 @@ void FakeCentral::SimulateGATTDisconnection(
FakePeripheral* fake_peripheral = GetFakePeripheral(address); FakePeripheral* fake_peripheral = GetFakePeripheral(address);
if (fake_peripheral == nullptr) { if (fake_peripheral == nullptr) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_peripheral->SimulateGATTDisconnection(); fake_peripheral->SimulateGATTDisconnection();
...@@ -289,6 +290,7 @@ void FakeCentral::AddFakeDescriptor( ...@@ -289,6 +290,7 @@ void FakeCentral::AddFakeDescriptor(
characteristic_id); characteristic_id);
if (fake_remote_gatt_characteristic == nullptr) { if (fake_remote_gatt_characteristic == nullptr) {
std::move(callback).Run(base::nullopt); std::move(callback).Run(base::nullopt);
return;
} }
std::move(callback).Run( std::move(callback).Run(
...@@ -324,6 +326,7 @@ void FakeCentral::SetNextReadCharacteristicResponse( ...@@ -324,6 +326,7 @@ void FakeCentral::SetNextReadCharacteristicResponse(
characteristic_id); characteristic_id);
if (fake_remote_gatt_characteristic == nullptr) { if (fake_remote_gatt_characteristic == nullptr) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_remote_gatt_characteristic->SetNextReadResponse(gatt_code, value); fake_remote_gatt_characteristic->SetNextReadResponse(gatt_code, value);
...@@ -341,6 +344,7 @@ void FakeCentral::SetNextWriteCharacteristicResponse( ...@@ -341,6 +344,7 @@ void FakeCentral::SetNextWriteCharacteristicResponse(
characteristic_id); characteristic_id);
if (fake_remote_gatt_characteristic == nullptr) { if (fake_remote_gatt_characteristic == nullptr) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_remote_gatt_characteristic->SetNextWriteResponse(gatt_code); fake_remote_gatt_characteristic->SetNextWriteResponse(gatt_code);
...@@ -358,6 +362,7 @@ void FakeCentral::SetNextSubscribeToNotificationsResponse( ...@@ -358,6 +362,7 @@ void FakeCentral::SetNextSubscribeToNotificationsResponse(
characteristic_id); characteristic_id);
if (fake_remote_gatt_characteristic == nullptr) { if (fake_remote_gatt_characteristic == nullptr) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_remote_gatt_characteristic->SetNextSubscribeToNotificationsResponse( fake_remote_gatt_characteristic->SetNextSubscribeToNotificationsResponse(
...@@ -376,6 +381,7 @@ void FakeCentral::SetNextUnsubscribeFromNotificationsResponse( ...@@ -376,6 +381,7 @@ void FakeCentral::SetNextUnsubscribeFromNotificationsResponse(
characteristic_id); characteristic_id);
if (fake_remote_gatt_characteristic == nullptr) { if (fake_remote_gatt_characteristic == nullptr) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_remote_gatt_characteristic->SetNextUnsubscribeFromNotificationsResponse( fake_remote_gatt_characteristic->SetNextUnsubscribeFromNotificationsResponse(
...@@ -392,6 +398,7 @@ void FakeCentral::IsNotifying(const std::string& characteristic_id, ...@@ -392,6 +398,7 @@ void FakeCentral::IsNotifying(const std::string& characteristic_id,
characteristic_id); characteristic_id);
if (!fake_remote_gatt_characteristic) { if (!fake_remote_gatt_characteristic) {
std::move(callback).Run(false, false); std::move(callback).Run(false, false);
return;
} }
std::move(callback).Run(true, fake_remote_gatt_characteristic->IsNotifying()); std::move(callback).Run(true, fake_remote_gatt_characteristic->IsNotifying());
...@@ -407,6 +414,7 @@ void FakeCentral::GetLastWrittenCharacteristicValue( ...@@ -407,6 +414,7 @@ void FakeCentral::GetLastWrittenCharacteristicValue(
characteristic_id); characteristic_id);
if (fake_remote_gatt_characteristic == nullptr) { if (fake_remote_gatt_characteristic == nullptr) {
std::move(callback).Run(false, base::nullopt); std::move(callback).Run(false, base::nullopt);
return;
} }
std::move(callback).Run( std::move(callback).Run(
...@@ -426,6 +434,7 @@ void FakeCentral::SetNextReadDescriptorResponse( ...@@ -426,6 +434,7 @@ void FakeCentral::SetNextReadDescriptorResponse(
characteristic_id, descriptor_id); characteristic_id, descriptor_id);
if (fake_remote_gatt_descriptor == nullptr) { if (fake_remote_gatt_descriptor == nullptr) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_remote_gatt_descriptor->SetNextReadResponse(gatt_code, value); fake_remote_gatt_descriptor->SetNextReadResponse(gatt_code, value);
...@@ -444,6 +453,7 @@ void FakeCentral::SetNextWriteDescriptorResponse( ...@@ -444,6 +453,7 @@ void FakeCentral::SetNextWriteDescriptorResponse(
characteristic_id, descriptor_id); characteristic_id, descriptor_id);
if (!fake_remote_gatt_descriptor) { if (!fake_remote_gatt_descriptor) {
std::move(callback).Run(false); std::move(callback).Run(false);
return;
} }
fake_remote_gatt_descriptor->SetNextWriteResponse(gatt_code); fake_remote_gatt_descriptor->SetNextWriteResponse(gatt_code);
...@@ -461,6 +471,7 @@ void FakeCentral::GetLastWrittenDescriptorValue( ...@@ -461,6 +471,7 @@ void FakeCentral::GetLastWrittenDescriptorValue(
characteristic_id, descriptor_id); characteristic_id, descriptor_id);
if (!fake_remote_gatt_descriptor) { if (!fake_remote_gatt_descriptor) {
std::move(callback).Run(false, base::nullopt); std::move(callback).Run(false, base::nullopt);
return;
} }
std::move(callback).Run(true, std::move(callback).Run(true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment