From 0a96c9f7e077ee7a853a4f4dbe9ab910ed63fc75 Mon Sep 17 00:00:00 2001 From: Anay Wadhera Date: Tue, 4 Jun 2024 10:26:11 -0700 Subject: [PATCH] Remove SetArcCleanupCallback API. PiperOrigin-RevId: 640199327 --- sharing/fake_nearby_sharing_service.cc | 4 ---- sharing/fake_nearby_sharing_service.h | 3 --- sharing/nearby_sharing_service.h | 4 ---- sharing/nearby_sharing_service_impl.cc | 27 -------------------------- sharing/nearby_sharing_service_impl.h | 4 ---- 5 files changed, 42 deletions(-) diff --git a/sharing/fake_nearby_sharing_service.cc b/sharing/fake_nearby_sharing_service.cc index 6b005407..c1423454 100644 --- a/sharing/fake_nearby_sharing_service.cc +++ b/sharing/fake_nearby_sharing_service.cc @@ -181,10 +181,6 @@ void FakeNearbySharingService::OpenUrl(const ::nearby::network::Url& url) {} // Copies text to cache/clipboard. void FakeNearbySharingService::CopyText(absl::string_view text) {} -// Sets a cleanup callback to be called once done with transfer for ARC. -void FakeNearbySharingService::SetArcTransferCleanupCallback( - std::function callback) {} - std::string FakeNearbySharingService::Dump() const { return ""; } NearbyShareSettings* FakeNearbySharingService::GetSettings() { return nullptr; } diff --git a/sharing/fake_nearby_sharing_service.h b/sharing/fake_nearby_sharing_service.h index 237cddeb..5c70b8c3 100644 --- a/sharing/fake_nearby_sharing_service.h +++ b/sharing/fake_nearby_sharing_service.h @@ -130,9 +130,6 @@ class FakeNearbySharingService : public NearbySharingService { // Copies text to cache/clipboard. void CopyText(absl::string_view text) override; - // Sets a cleanup callback to be called once done with transfer for ARC. - void SetArcTransferCleanupCallback(std::function callback) override; - std::string Dump() const override; NearbyShareSettings* GetSettings() override; diff --git a/sharing/nearby_sharing_service.h b/sharing/nearby_sharing_service.h index ed9abdf0..c02d38f2 100644 --- a/sharing/nearby_sharing_service.h +++ b/sharing/nearby_sharing_service.h @@ -252,10 +252,6 @@ class NearbySharingService { virtual void JoinWifiNetwork(absl::string_view ssid, absl::string_view password) = 0; - // Sets a cleanup callback to be called once done with transfer for ARC. - virtual void SetArcTransferCleanupCallback( - std::function callback) = 0; - virtual std::string Dump() const = 0; virtual void UpdateFilePathsInProgress(bool update_file_paths) = 0; diff --git a/sharing/nearby_sharing_service_impl.cc b/sharing/nearby_sharing_service_impl.cc index 788e149c..5cbda5b3 100644 --- a/sharing/nearby_sharing_service_impl.cc +++ b/sharing/nearby_sharing_service_impl.cc @@ -1010,26 +1010,6 @@ void NearbySharingServiceImpl::JoinWifiNetwork(absl::string_view ssid, }); } -void NearbySharingServiceImpl::SetArcTransferCleanupCallback( - std::function callback) { - // In the case where multiple Nearby Share sessions are started, successive - // Nearby Share bubbles shown will prevent the user from sharing while the - // initial bubble is still active. For the successive bubble(s), we want to - // make sure only the original cleanup callback is valid. - // Also in the following case: - // 1. CrOS starts a receive transfer. - // 2. ARC starts a send transfer and |arc_transfer_cleanup_callback_| is set - // erroneously if |is_transferring_| check is missing. - // As multiple transfers cannot occur at the same time, a "Can't Share" error - // will occur. When the transfer in [1] finishes and another ARC Nearby Share - // session starts, the |arc_transfer_cleanup_callback_| can't be set if a - // value is already set to ensure all clean up is performed. Hence, check if - // not |is_transferring_| before setting |arc_transfer_cleanup_callback_|. - if (!is_transferring_ && arc_transfer_cleanup_callback_ == nullptr) { - arc_transfer_cleanup_callback_ = std::move(callback); - } -} - NearbyShareSettings* NearbySharingServiceImpl::GetSettings() { return settings_.get(); } @@ -2512,13 +2492,6 @@ void NearbySharingServiceImpl::OnTransferComplete() { is_transferring_ = false; is_sending_files_ = false; - // Cleanup ARC after send transfer completes since reading from file - // descriptor(s) are done at this point even though there could be Nearby - // Connection frames cached that are not yet sent to the remote device. - if (was_sending_files && arc_transfer_cleanup_callback_) { - arc_transfer_cleanup_callback_(); - } - NL_VLOG(1) << __func__ << ": NearbySharing state change transfer finished"; // Files transfer is done! Receivers can immediately cancel, but senders // should add a short delay to ensure the final in-flight packet(s) make diff --git a/sharing/nearby_sharing_service_impl.h b/sharing/nearby_sharing_service_impl.h index 043404a4..a3df97b0 100644 --- a/sharing/nearby_sharing_service_impl.h +++ b/sharing/nearby_sharing_service_impl.h @@ -183,7 +183,6 @@ class NearbySharingServiceImpl void CopyText(absl::string_view text) override; void JoinWifiNetwork(absl::string_view ssid, absl::string_view password) override; - void SetArcTransferCleanupCallback(std::function callback) override; NearbyShareSettings* GetSettings() override; nearby::sharing::api::SharingRpcNotifier* GetRpcNotifier() override; NearbyShareLocalDeviceDataManager* GetLocalDeviceDataManager() override; @@ -647,9 +646,6 @@ class NearbySharingServiceImpl // finishes. When processing finishes, the event is removed from the queue. std::queue> endpoint_discovery_events_; - // Called when cleanup for ARC is needed as part of the transfer. - std::function arc_transfer_cleanup_callback_; - // Shouldn't schedule new task after shutting down, and skip task if the // object is null. std::shared_ptr is_shutting_down_ = nullptr;