#include "components/sharing_message/sharing_fcm_handler.h"
#include "base/functional/callback_helpers.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/sharing_message/features.h"
#include "components/sharing_message/proto/sharing_message_type.pb.h"
#include "components/sharing_message/sharing_constants.h"
#include "components/sharing_message/sharing_fcm_sender.h"
#include "components/sharing_message/sharing_handler_registry.h"
#include "components/sharing_message/sharing_message_handler.h"
#include "components/sharing_message/sharing_metrics.h"
#include "components/sharing_message/sharing_utils.h"
#include "components/sync_device_info/device_info_tracker.h"
#include "third_party/re2/src/re2/re2.h"
namespace {
const char kMessageIdRegexPattern[] = …;
std::string GetStrippedMessageId(const std::string& message_id) { … }
}
SharingFCMHandler::SharingFCMHandler(
gcm::GCMDriver* gcm_driver,
syncer::DeviceInfoTracker* device_info_tracker,
SharingFCMSender* sharing_fcm_sender,
SharingHandlerRegistry* handler_registry)
: … { … }
SharingFCMHandler::~SharingFCMHandler() { … }
void SharingFCMHandler::StartListening() { … }
void SharingFCMHandler::StopListening() { … }
void SharingFCMHandler::OnMessagesDeleted(const std::string& app_id) { … }
void SharingFCMHandler::ShutdownHandler() { … }
void SharingFCMHandler::OnMessage(const std::string& app_id,
const gcm::IncomingMessage& message) { … }
void SharingFCMHandler::OnSendAcknowledged(const std::string& app_id,
const std::string& message_id) { … }
void SharingFCMHandler::OnSendError(
const std::string& app_id,
const gcm::GCMClient::SendErrorDetails& details) { … }
void SharingFCMHandler::OnStoreReset() { … }
std::optional<components_sharing_message::FCMChannelConfiguration>
SharingFCMHandler::GetFCMChannel(
const components_sharing_message::SharingMessage& original_message) { … }
std::optional<components_sharing_message::ServerChannelConfiguration>
SharingFCMHandler::GetServerChannel(
const components_sharing_message::SharingMessage& original_message) { … }
SharingDevicePlatform SharingFCMHandler::GetSenderPlatform(
const components_sharing_message::SharingMessage& original_message) { … }
void SharingFCMHandler::SendAckMessage(
std::string original_message_id,
sharing_message::MessageType original_message_type,
std::optional<components_sharing_message::FCMChannelConfiguration>
fcm_channel,
std::optional<components_sharing_message::ServerChannelConfiguration>
server_channel,
SharingDevicePlatform sender_device_type,
std::unique_ptr<components_sharing_message::ResponseMessage> response) { … }
void SharingFCMHandler::OnAckMessageSent(
std::string original_message_id,
sharing_message::MessageType original_message_type,
SharingDevicePlatform sender_device_type,
int trace_id,
SharingSendMessageResult result,
std::optional<std::string> message_id,
SharingChannelType channel_type) { … }