Commit 87071b64 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

[Nearby] Filter status updates after final status

This will filter any further TransferMetadata updates afterr receiving a
final status one.

Bug: 1085067
Change-Id: I75fa89ad57f61cf81ed7738c6b646218f3823e32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368598Reviewed-by: default avatarAlex Chau <alexchau@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800722}
parent d4364ffe
...@@ -193,9 +193,9 @@ class NearbySharingServiceImpl ...@@ -193,9 +193,9 @@ class NearbySharingServiceImpl
ShareTarget placeholder_share_target, ShareTarget placeholder_share_target,
sharing::mojom::AdvertisementPtr advertisement); sharing::mojom::AdvertisementPtr advertisement);
void OnIncomingTransferUpdate(const ShareTarget& share_target, void OnIncomingTransferUpdate(const ShareTarget& share_target,
TransferMetadata metadata); const TransferMetadata& metadata);
void OnOutgoingTransferUpdate(const ShareTarget& share_target, void OnOutgoingTransferUpdate(const ShareTarget& share_target,
TransferMetadata metadata); const TransferMetadata& metadata);
void CloseConnection(const ShareTarget& share_target); void CloseConnection(const ShareTarget& share_target);
void OnIncomingDecryptedCertificate( void OnIncomingDecryptedCertificate(
const std::string& endpoint_id, const std::string& endpoint_id,
......
...@@ -2359,12 +2359,10 @@ TEST_F(NearbySharingServiceImplTest, SendText_FailedKeyVerification) { ...@@ -2359,12 +2359,10 @@ TEST_F(NearbySharingServiceImplTest, SendText_FailedKeyVerification) {
DiscoverShareTarget(transfer_callback, discovery_callback); DiscoverShareTarget(transfer_callback, discovery_callback);
base::RunLoop run_loop; base::RunLoop run_loop;
ExpectTransferUpdates( ExpectTransferUpdates(transfer_callback, target,
transfer_callback, target, {TransferMetadata::Status::kConnecting,
{TransferMetadata::Status::kConnecting, TransferMetadata::Status::kFailed, TransferMetadata::Status::kFailed},
// TODO(crbug.com/1085067): Filter updates after the first final one. run_loop.QuitClosure());
TransferMetadata::Status::kAwaitingRemoteAcceptanceFailed},
run_loop.QuitClosure());
SetUpKeyVerification(/*is_incoming=*/false, SetUpKeyVerification(/*is_incoming=*/false,
sharing::mojom::PairedKeyResultFrame_Status::kFail); sharing::mojom::PairedKeyResultFrame_Status::kFail);
...@@ -2429,12 +2427,8 @@ TEST_P(NearbySharingServiceImplSendFailureTest, SendText_RemoteFailure) { ...@@ -2429,12 +2427,8 @@ TEST_P(NearbySharingServiceImplSendFailureTest, SendText_RemoteFailure) {
// We're now waiting for the remote device to respond with the accept result. // We're now waiting for the remote device to respond with the accept result.
base::RunLoop reject_run_loop; base::RunLoop reject_run_loop;
ExpectTransferUpdates( ExpectTransferUpdates(transfer_callback, target, {GetParam().expected_status},
transfer_callback, target, reject_run_loop.QuitClosure());
{GetParam().expected_status,
// TODO(crbug.com/1085067): Filter updates after the first final one.
TransferMetadata::Status::kAwaitingRemoteAcceptanceFailed},
reject_run_loop.QuitClosure());
// Cancel the transfer by rejecting it. // Cancel the transfer by rejecting it.
SendConnectionResponse(GetParam().response_status); SendConnectionResponse(GetParam().response_status);
...@@ -2472,12 +2466,8 @@ TEST_P(NearbySharingServiceImplSendFailureTest, SendFiles_RemoteFailure) { ...@@ -2472,12 +2466,8 @@ TEST_P(NearbySharingServiceImplSendFailureTest, SendFiles_RemoteFailure) {
// We're now waiting for the remote device to respond with the accept result. // We're now waiting for the remote device to respond with the accept result.
base::RunLoop reject_run_loop; base::RunLoop reject_run_loop;
ExpectTransferUpdates( ExpectTransferUpdates(transfer_callback, target, {GetParam().expected_status},
transfer_callback, target, reject_run_loop.QuitClosure());
{GetParam().expected_status,
// TODO(crbug.com/1085067): Filter updates after the first final one.
TransferMetadata::Status::kAwaitingRemoteAcceptanceFailed},
reject_run_loop.QuitClosure());
// Cancel the transfer by rejecting it. // Cancel the transfer by rejecting it.
SendConnectionResponse(GetParam().response_status); SendConnectionResponse(GetParam().response_status);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/nearby_sharing/incoming_frames_reader.h" #include "chrome/browser/nearby_sharing/incoming_frames_reader.h"
#include "chrome/browser/nearby_sharing/paired_key_verification_runner.h" #include "chrome/browser/nearby_sharing/paired_key_verification_runner.h"
#include "chrome/browser/nearby_sharing/payload_tracker.h" #include "chrome/browser/nearby_sharing/payload_tracker.h"
#include "chrome/browser/nearby_sharing/transfer_update_callback.h"
class NearbyConnection; class NearbyConnection;
...@@ -47,6 +48,15 @@ class ShareTargetInfo { ...@@ -47,6 +48,15 @@ class ShareTargetInfo {
connection_ = connection; connection_ = connection;
} }
TransferUpdateCallback* transfer_update_callback() const {
return transfer_update_callback_.get();
}
void set_transfer_update_callback(
std::unique_ptr<TransferUpdateCallback> transfer_update_callback) {
transfer_update_callback_ = std::move(transfer_update_callback);
}
const base::Optional<std::string>& token() const { return token_; } const base::Optional<std::string>& token() const { return token_; }
void set_token(std::string token) { token_ = std::move(token); } void set_token(std::string token) { token_ = std::move(token); }
...@@ -76,6 +86,7 @@ class ShareTargetInfo { ...@@ -76,6 +86,7 @@ class ShareTargetInfo {
base::Optional<std::string> endpoint_id_; base::Optional<std::string> endpoint_id_;
base::Optional<NearbyShareDecryptedPublicCertificate> certificate_; base::Optional<NearbyShareDecryptedPublicCertificate> certificate_;
NearbyConnection* connection_ = nullptr; NearbyConnection* connection_ = nullptr;
std::unique_ptr<TransferUpdateCallback> transfer_update_callback_;
base::Optional<std::string> token_; base::Optional<std::string> token_;
std::unique_ptr<IncomingFramesReader> frames_reader_; std::unique_ptr<IncomingFramesReader> frames_reader_;
std::unique_ptr<PairedKeyVerificationRunner> key_verification_runner_; std::unique_ptr<PairedKeyVerificationRunner> key_verification_runner_;
......
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