Commit d8bbe351 authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[Nearby] Remove surprising use of unique_ptr for CorePayload.

Discovered while debugging crbug.com/2393616.

The code in question moves the wrapped CorePayload of a
std::unique_ptr<CorePayload>, instead of moving the entire smart
pointer. Resolved by simply not using std::unique_ptr in the first
place.

Also fix a minor typo discovered while debugging.

Bug: 2393616
Change-Id: I518230bd2ced6735d13f4fc8fbee54758ceec1e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398952
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#805154}
parent 594aaf47
......@@ -468,7 +468,7 @@ void NearbyConnectionsManagerImpl::OnConnectionInitiated(
[](const std::string& endpoint_id, ConnectionsStatus status) {
NS_LOG(VERBOSE)
<< __func__ << ": Accept connection attempted to endpoint "
<< endpoint_id << "over Nearby Connections with result: "
<< endpoint_id << " over Nearby Connections with result: "
<< ConnectionsStatusToString(status);
},
endpoint_id));
......
......@@ -362,12 +362,12 @@ void NearbyConnections::SendPayload(
const std::vector<std::string>& endpoint_ids,
mojom::PayloadPtr payload,
SendPayloadCallback callback) {
std::unique_ptr<Payload> core_payload;
Payload core_payload;
switch (payload->content->which()) {
case mojom::PayloadContent::Tag::BYTES:
core_payload = std::make_unique<Payload>(
payload->id,
ByteArrayFromMojom(payload->content->get_bytes()->bytes));
core_payload =
Payload(payload->id,
ByteArrayFromMojom(payload->content->get_bytes()->bytes));
break;
case mojom::PayloadContent::Tag::FILE:
int64_t file_size = payload->content->get_file()->file.GetLength();
......@@ -376,12 +376,11 @@ void NearbyConnections::SendPayload(
input_file_map_.insert_or_assign(
payload->id, std::move(payload->content->get_file()->file));
}
core_payload = std::make_unique<Payload>(
payload->id, InputFile(payload->id, file_size));
core_payload = Payload(payload->id, InputFile(payload->id, file_size));
break;
}
core_->SendPayload(absl::MakeSpan(endpoint_ids), std::move(*core_payload),
core_->SendPayload(absl::MakeSpan(endpoint_ids), std::move(core_payload),
ResultCallbackFromMojom(std::move(callback)));
}
......
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