#include "components/invalidation/impl/fcm_network_handler.h"
#include <memory>
#include <string>
#include <string_view>
#include "base/base64url.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/i18n/time_formatting.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/gcm_profile_service.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/invalidation/impl/invalidation_switches.h"
#include "components/invalidation/impl/status.h"
#include "components/invalidation/public/invalidator_state.h"
InstanceID;
namespace invalidation {
namespace {
const char kPayloadKey[] = …;
const char kPublicTopic[] = …;
const char kVersionKey[] = …;
const char kGCMScope[] = …;
const int kTokenValidationPeriodMinutesDefault = …;
base::TimeDelta GetTimeToLive(const std::string& sender_id) { … }
std::string GetValueFromMessage(const gcm::IncomingMessage& message,
const std::string& key) { … }
std::string UnpackPrivateTopic(std::string_view private_topic) { … }
InvalidationParsingStatus ParseIncomingMessage(
const gcm::IncomingMessage& message,
std::string* payload,
std::string* private_topic,
std::string* public_topic,
int64_t* version) { … }
void RecordFCMMessageStatus(InvalidationParsingStatus status,
const std::string& sender_id) { … }
}
FCMNetworkHandler::FCMNetworkHandler(
gcm::GCMDriver* gcm_driver,
instance_id::InstanceIDDriver* instance_id_driver,
const std::string& sender_id,
const std::string& app_id)
: … { … }
FCMNetworkHandler::~FCMNetworkHandler() { … }
std::unique_ptr<FCMNetworkHandler> FCMNetworkHandler::Create(
gcm::GCMDriver* gcm_driver,
instance_id::InstanceIDDriver* instance_id_driver,
const std::string& sender_id,
const std::string& app_id) { … }
void FCMNetworkHandler::StartListening() { … }
void FCMNetworkHandler::StopListening() { … }
bool FCMNetworkHandler::IsListening() const { … }
void FCMNetworkHandler::DidRetrieveToken(const std::string& subscription_token,
InstanceID::Result result) { … }
void FCMNetworkHandler::ScheduleNextTokenValidation() { … }
void FCMNetworkHandler::StartTokenValidation() { … }
void FCMNetworkHandler::DidReceiveTokenForValidation(
const std::string& new_token,
InstanceID::Result result) { … }
void FCMNetworkHandler::UpdateChannelState(FcmChannelState state) { … }
void FCMNetworkHandler::ShutdownHandler() { … }
void FCMNetworkHandler::OnStoreReset() { … }
void FCMNetworkHandler::OnMessage(const std::string& app_id,
const gcm::IncomingMessage& message) { … }
void FCMNetworkHandler::OnMessagesDeleted(const std::string& app_id) { … }
void FCMNetworkHandler::OnSendError(
const std::string& app_id,
const gcm::GCMClient::SendErrorDetails& details) { … }
void FCMNetworkHandler::OnSendAcknowledged(const std::string& app_id,
const std::string& message_id) { … }
void FCMNetworkHandler::SetTokenValidationTimerForTesting(
std::unique_ptr<base::OneShotTimer> token_validation_timer) { … }
}