Keep management of outgoing_share_target_map_ and outgoing_share_session_map_ together.

PiperOrigin-RevId: 721918835
This commit is contained in:
Francis Tsui
2025-01-31 15:15:17 -08:00
committed by Copybara-Service
parent 0575cbd155
commit 17c6dd8ee4
2 changed files with 5 additions and 7 deletions
+1 -3
View File
@@ -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_,
+4 -4
View File
@@ -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);