Files
nearby/sharing/incoming_share_target_info.cc
T
Francis Tsui 2d845718f2 Cleanup share target info.
PiperOrigin-RevId: 641091075
2024-06-06 18:57:08 -07:00

57 lines
1.8 KiB
C++

// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "sharing/incoming_share_target_info.h"
#include <functional>
#include <string>
#include <utility>
#include "sharing/nearby_connection.h"
#include "sharing/share_target.h"
#include "sharing/share_target_info.h"
#include "sharing/transfer_metadata.h"
namespace nearby {
namespace sharing {
IncomingShareTargetInfo::IncomingShareTargetInfo(
std::string endpoint_id, const ShareTarget& share_target,
std::function<void(const IncomingShareTargetInfo&, const TransferMetadata&)>
transfer_update_callback)
: ShareTargetInfo(std::move(endpoint_id), share_target),
transfer_update_callback_(std::move(transfer_update_callback)) {}
IncomingShareTargetInfo::IncomingShareTargetInfo(IncomingShareTargetInfo&&) =
default;
IncomingShareTargetInfo& IncomingShareTargetInfo::operator=(
IncomingShareTargetInfo&&) = default;
IncomingShareTargetInfo::~IncomingShareTargetInfo() = default;
void IncomingShareTargetInfo::InvokeTransferUpdateCallback(
const TransferMetadata& metadata) {
transfer_update_callback_(*this, metadata);
}
bool IncomingShareTargetInfo::OnNewConnection(NearbyConnection* connection) {
set_disconnect_status(
TransferMetadata::Status::kAwaitingRemoteAcceptanceFailed);
return true;
}
} // namespace sharing
} // namespace nearby