Fix race when sending a Sharing message

There is a race when we wait on the response from FCM to give us the
message id of the sent message. If we for some reason get the ACK for
that message before the response from FCM, we discard the ACK and
timeout.

Bug: None
Change-Id: I35a1965aa5e1034af1b046099a60656ea61b59cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001302
Commit-Queue: Richard Knoll <[email protected]>
Reviewed-by: Alex Chau <[email protected]>
Cr-Commit-Position: refs/heads/master@{#732097}
diff --git a/chrome/browser/sharing/sharing_message_sender.h b/chrome/browser/sharing/sharing_message_sender.h
index 529ff73d..999c4d0 100644
--- a/chrome/browser/sharing/sharing_message_sender.h
+++ b/chrome/browser/sharing/sharing_message_sender.h
@@ -112,6 +112,10 @@
   std::map<std::string, SentMessageMetadata> message_metadata_;
   // Map of FCM message_id to random GUID.
   std::map<std::string, std::string> message_guids_;
+  // Map of FCM message_id to received ACK response messages.
+  std::map<std::string,
+           std::unique_ptr<chrome_browser_sharing::ResponseMessage>>
+      cached_ack_response_messages_;
 
   // Registered delegates to send messages.
   std::map<DelegateType, std::unique_ptr<SendMessageDelegate>> send_delegates_;