#include "components/sharing_message/sharing_fcm_sender.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "base/uuid.h"
#include "base/version.h"
#include "components/gcm_driver/crypto/gcm_encryption_result.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/sharing_message/sharing_constants.h"
#include "components/sharing_message/sharing_message_bridge.h"
#include "components/sharing_message/sharing_sync_preference.h"
#include "components/sharing_message/sharing_utils.h"
#include "components/sharing_message/vapid_key_manager.h"
#include "components/sharing_message/web_push/web_push_sender.h"
#include "components/sync/service/sync_service.h"
#include "components/sync_device_info/device_info_tracker.h"
#include "components/sync_device_info/local_device_info_provider.h"
SharingFCMSender::SharingFCMSender(
std::unique_ptr<WebPushSender> web_push_sender,
SharingMessageBridge* sharing_message_bridge,
SharingSyncPreference* sync_preference,
VapidKeyManager* vapid_key_manager,
gcm::GCMDriver* gcm_driver,
const syncer::DeviceInfoTracker* device_info_tracker,
const syncer::LocalDeviceInfoProvider* local_device_info_provider,
syncer::SyncService* sync_service)
: … { … }
SharingFCMSender::~SharingFCMSender() = default;
void SharingFCMSender::DoSendMessageToDevice(
const SharingTargetDeviceInfo& device,
base::TimeDelta time_to_live,
SharingMessage message,
SendMessageCallback callback) { … }
void SharingFCMSender::DoSendUnencryptedMessageToDevice(
const SharingTargetDeviceInfo& device,
sync_pb::UnencryptedSharingMessage message,
SendMessageCallback callback) { … }
void SharingFCMSender::SendMessageToFcmTarget(
const components_sharing_message::FCMChannelConfiguration&
fcm_configuration,
base::TimeDelta time_to_live,
SharingMessage message,
SendMessageCallback callback) { … }
void SharingFCMSender::SendMessageToServerTarget(
const components_sharing_message::ServerChannelConfiguration&
server_channel,
SharingMessage message,
SendMessageCallback callback) { … }
void SharingFCMSender::EncryptMessage(const std::string& authorized_entity,
const std::string& p256dh,
const std::string& auth_secret,
const SharingMessage& message,
SharingChannelType channel_type,
SendMessageCallback callback,
MessageSender message_sender) { … }
void SharingFCMSender::OnMessageEncrypted(SharingChannelType channel_type,
SendMessageCallback callback,
MessageSender message_sender,
gcm::GCMEncryptionResult result,
std::string message) { … }
void SharingFCMSender::DoSendMessageToVapidTarget(
const std::string& fcm_token,
base::TimeDelta time_to_live,
std::string message,
SendMessageCallback callback) { … }
void SharingFCMSender::OnMessageSentToVapidTarget(
SendMessageCallback callback,
SendWebPushMessageResult result,
std::optional<std::string> message_id) { … }
void SharingFCMSender::DoSendMessageToSenderIdTarget(
const std::string& fcm_token,
base::TimeDelta time_to_live,
const std::string& message_id,
std::string message,
SendMessageCallback callback) { … }
void SharingFCMSender::DoSendMessageToServerTarget(
const std::string& server_channel,
const std::string& message_id,
std::string message,
SendMessageCallback callback) { … }
void SharingFCMSender::OnMessageSentViaSync(
SendMessageCallback callback,
const std::string& message_id,
SharingChannelType channel_type,
const sync_pb::SharingMessageCommitError& error) { … }
bool SharingFCMSender::SetMessageSenderInfo(SharingMessage* message) { … }
void SharingFCMSender::SetWebPushSenderForTesting(
std::unique_ptr<WebPushSender> web_push_sender) { … }
void SharingFCMSender::SetSharingMessageBridgeForTesting(
SharingMessageBridge* sharing_message_bridge) { … }