mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Keep management of outgoing_share_target_map_ and outgoing_share_session_map_ together.
PiperOrigin-RevId: 721918835
This commit is contained in:
committed by
Copybara-Service
parent
0575cbd155
commit
17c6dd8ee4
@@ -1790,7 +1790,6 @@ void NearbySharingServiceImpl::OnOutgoingDecryptedCertificate(
|
||||
VLOG(1) << __func__ << ": Adding (endpoint_id=" << endpoint_id
|
||||
<< ", share_target_id=" << share_target->id
|
||||
<< ") to outgoing share target map";
|
||||
outgoing_share_target_map_.insert_or_assign(endpoint_id, *share_target);
|
||||
CreateOutgoingShareSession(*share_target, endpoint_id,
|
||||
std::move(certificate));
|
||||
|
||||
@@ -3229,7 +3228,6 @@ bool NearbySharingServiceImpl::FindDuplicateInDiscoveryCache(
|
||||
<< it->second.share_target.id;
|
||||
share_target.id = it->second.share_target.id;
|
||||
discovery_cache_.erase(it);
|
||||
outgoing_share_target_map_.insert_or_assign(endpoint_id, share_target);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3244,7 +3242,6 @@ bool NearbySharingServiceImpl::FindDuplicateInDiscoveryCache(
|
||||
// Copy only the id field from cache entry,
|
||||
share_target.id = it->second.share_target.id;
|
||||
discovery_cache_.erase(it);
|
||||
outgoing_share_target_map_.insert_or_assign(endpoint_id, share_target);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3379,6 +3376,7 @@ void NearbySharingServiceImpl::MoveToDiscoveryCache(std::string endpoint_id,
|
||||
void NearbySharingServiceImpl::CreateOutgoingShareSession(
|
||||
const ShareTarget& share_target, absl::string_view endpoint_id,
|
||||
std::optional<NearbyShareDecryptedPublicCertificate> certificate) {
|
||||
outgoing_share_target_map_.insert_or_assign(endpoint_id, share_target);
|
||||
auto [it_out, inserted] = outgoing_share_session_map_.try_emplace(
|
||||
share_target.id, context_->GetClock(), *service_thread_,
|
||||
nearby_connections_manager_.get(), analytics_recorder_,
|
||||
|
||||
@@ -382,8 +382,8 @@ class NearbySharingServiceImpl
|
||||
const ShareTarget& share_target, absl::string_view endpoint_id,
|
||||
std::optional<NearbyShareDecryptedPublicCertificate> certificate);
|
||||
|
||||
// Add an entry to the outgoing_share_session_map_
|
||||
// and OnShareTargetUpdated is called.
|
||||
// Add an entry to the outgoing_share_session_map_ and
|
||||
// outgoing_share_target_map_ and OnShareTargetUpdated is called.
|
||||
void DeDuplicateInDiscoveryCache(
|
||||
const ShareTarget& share_target, absl::string_view endpoint_id,
|
||||
std::optional<NearbyShareDecryptedPublicCertificate> certificate);
|
||||
@@ -395,8 +395,8 @@ class NearbySharingServiceImpl
|
||||
ShareTarget& share_target);
|
||||
|
||||
// Looks for a duplicate of the share target in the discovery cache.
|
||||
// If found, move the share target to the outgoing share target map.
|
||||
// The share target's id is updated to match the cached entry.
|
||||
// If found, the share target is removed from the discovery cache and its
|
||||
// id is copied into `share_target`.
|
||||
// Returns true if the duplicate is found.
|
||||
bool FindDuplicateInDiscoveryCache(absl::string_view endpoint_id,
|
||||
ShareTarget& share_target);
|
||||
|
||||
Reference in New Issue
Block a user