Commit 18947daf authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

[Nearby] Download contacts/certificates when actively using Nearby Share

Sync down local-device, contact, and certificate data from the Nearby
server when the sending or receiving flow starts, making our best effort
at freshness. We do not wait for these calls to finish. The periodic
server requests will typically be sufficient, but we don't want the user
to be blocked for hours waiting for a periodic sync.

Manually verified that the download is performed once during a sending
flow and once during a receiving flow.

Fixed: b/168834197
Change-Id: Id35e097ce09cfe7c5a85f079074943788d2359b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505009
Auto-Submit: Josh Nohle <nohle@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821779}
parent c4212d51
...@@ -414,6 +414,21 @@ NearbySharingService::StatusCodes NearbySharingServiceImpl::RegisterSendSurface( ...@@ -414,6 +414,21 @@ NearbySharingService::StatusCodes NearbySharingServiceImpl::RegisterSendSurface(
last_outgoing_metadata_->second); last_outgoing_metadata_->second);
} }
// Sync down data from Nearby server when the sending flow starts, making our
// best effort to have fresh contact and certificate data. There is no need to
// wait for these calls to finish. The periodic server requests will typically
// be sufficient, but we don't want the user to be blocked for hours waiting
// for a periodic sync.
if (state == SendSurfaceState::kForeground && !last_outgoing_metadata_) {
NS_LOG(VERBOSE)
<< __func__
<< ": Downloading local device data, contacts, and certificates from "
<< "Nearby server at start of sending flow.";
local_device_data_manager_->DownloadDeviceData();
contact_manager_->DownloadContacts();
certificate_manager_->DownloadPublicCertificates();
}
// Let newly registered send surface catch up with discovered share targets // Let newly registered send surface catch up with discovered share targets
// from current scanning session. // from current scanning session.
for (const std::pair<std::string, ShareTarget>& item : for (const std::pair<std::string, ShareTarget>& item :
...@@ -800,6 +815,20 @@ void NearbySharingServiceImpl::OnIncomingConnection( ...@@ -800,6 +815,20 @@ void NearbySharingServiceImpl::OnIncomingConnection(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(connection); DCHECK(connection);
DCHECK(profile_); DCHECK(profile_);
// Sync down data from Nearby server when the receiving flow starts, making
// our best effort to have fresh contact and certificate data. There is no
// need to wait for these calls to finish. The periodic server requests will
// typically be sufficient, but we don't want the user to be blocked for hours
// waiting for a periodic sync.
NS_LOG(VERBOSE)
<< __func__
<< ": Downloading local device data, contacts, and certificates from "
<< "Nearby server at start of receiving flow.";
local_device_data_manager_->DownloadDeviceData();
contact_manager_->DownloadContacts();
certificate_manager_->DownloadPublicCertificates();
ShareTarget placeholder_share_target; ShareTarget placeholder_share_target;
placeholder_share_target.is_incoming = true; placeholder_share_target.is_incoming = true;
ShareTargetInfo& share_target_info = ShareTargetInfo& share_target_info =
......
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