chromium/components/gcm_driver/gcm_client_impl.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/gcm_driver/gcm_client_impl.h"

#include <stddef.h>

#include <memory>
#include <string_view>
#include <utility>

#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_clock.h"
#include "base/timer/timer.h"
#include "components/crx_file/id_util.h"
#include "components/gcm_driver/crypto/gcm_decryption_result.h"
#include "components/gcm_driver/features.h"
#include "components/gcm_driver/gcm_account_mapper.h"
#include "components/gcm_driver/gcm_backoff_policy.h"
#include "google_apis/gcm/base/encryptor.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/checkin_request.h"
#include "google_apis/gcm/engine/connection_factory_impl.h"
#include "google_apis/gcm/engine/gcm_registration_request_handler.h"
#include "google_apis/gcm/engine/gcm_store_impl.h"
#include "google_apis/gcm/engine/gcm_unregistration_request_handler.h"
#include "google_apis/gcm/engine/instance_id_delete_token_request_handler.h"
#include "google_apis/gcm/engine/instance_id_get_token_request_handler.h"
#include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
#include "google_apis/gcm/protocol/checkin.pb.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "url/gurl.h"

namespace gcm {

// It is okay to append to the enum if these states grow. DO NOT reorder,
// renumber or otherwise reuse existing values.
// Do not assign an explicit value to REGISTRATION_CACHE_STATUS_COUNT, as
// this lets the compiler keep it up to date.
enum class RegistrationCacheStatus {};

namespace {

// Indicates a message type of the received message.
enum MessageType {};

const int kMaxRegistrationRetries =;
const int kMaxUnregistrationRetries =;
const char kDeletedCountKey[] =;
const char kMessageTypeDataMessage[] =;
const char kMessageTypeDeletedMessagesKey[] =;
const char kMessageTypeKey[] =;
const char kMessageTypeSendErrorKey[] =;
const char kSubtypeKey[] =;
const char kSendMessageFromValue[] =;
const int64_t kDefaultUserSerialNumber =;
const int kDestroyGCMStoreDelayMS =;  // 5 minutes.

GCMClient::Result ToGCMClientResult(MCSClient::MessageSendStatus status) {}

void ToCheckinProtoVersion(
    const GCMClient::ChromeBuildInfo& chrome_build_info,
    checkin_proto::ChromeBuildProto* android_build_info) {}

MessageType DecodeMessageType(const std::string& value) {}

int ConstructGCMVersion(const std::string& chrome_version) {}

std::string SerializeInstanceIDData(const std::string& instance_id,
                                    const std::string& extra_data) {}

bool DeserializeInstanceIDData(const std::string& serialized_data,
                               std::string* instance_id,
                               std::string* extra_data) {}

bool InstanceIDUsesSubtypeForAppId(const std::string& app_id) {}

}  // namespace

void RecordRegistrationRequestToUMA(gcm::RegistrationCacheStatus status) {}
GCMInternalsBuilder::GCMInternalsBuilder() {}
GCMInternalsBuilder::~GCMInternalsBuilder() {}

base::Clock* GCMInternalsBuilder::GetClock() {}

std::unique_ptr<MCSClient> GCMInternalsBuilder::BuildMCSClient(
    const std::string& version,
    base::Clock* clock,
    ConnectionFactory* connection_factory,
    GCMStore* gcm_store,
    scoped_refptr<base::SequencedTaskRunner> io_task_runner,
    GCMStatsRecorder* recorder) {}

std::unique_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory(
    const std::vector<GURL>& endpoints,
    const net::BackoffEntry::Policy& backoff_policy,
    base::RepeatingCallback<void(
        mojo::PendingReceiver<network::mojom::ProxyResolvingSocketFactory>)>
        get_socket_factory_callback,
    scoped_refptr<base::SequencedTaskRunner> io_task_runner,
    GCMStatsRecorder* recorder,
    network::NetworkConnectionTracker* network_connection_tracker) {}

GCMClientImpl::CheckinInfo::CheckinInfo()
    :{}

GCMClientImpl::CheckinInfo::~CheckinInfo() = default;

void GCMClientImpl::CheckinInfo::SnapshotCheckinAccounts() {}

void GCMClientImpl::CheckinInfo::Reset() {}

GCMClientImpl::GCMClientImpl(
    std::unique_ptr<GCMInternalsBuilder> internals_builder)
    :{}

GCMClientImpl::~GCMClientImpl() = default;

void GCMClientImpl::Initialize(
    const ChromeBuildInfo& chrome_build_info,
    const base::FilePath& path,
    const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
    scoped_refptr<base::SequencedTaskRunner> io_task_runner,
    base::RepeatingCallback<void(
        mojo::PendingReceiver<network::mojom::ProxyResolvingSocketFactory>)>
        get_socket_factory_callback,
    const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
    network::NetworkConnectionTracker* network_connection_tracker,
    std::unique_ptr<Encryptor> encryptor,
    GCMClient::Delegate* delegate) {}

void GCMClientImpl::Start(StartMode start_mode) {}

void GCMClientImpl::OnLoadCompleted(
    std::unique_ptr<GCMStore::LoadResult> result) {}

void GCMClientImpl::StartGCM() {}

void GCMClientImpl::InitializeMCSClient() {}

void GCMClientImpl::OnFirstTimeDeviceCheckinCompleted(
    const CheckinInfo& checkin_info) {}

void GCMClientImpl::OnReady(const std::vector<AccountMapping>& account_mappings,
                            const base::Time& last_token_fetch_time) {}

void GCMClientImpl::StartMCSLogin() {}

void GCMClientImpl::DestroyStoreWhenNotNeeded() {}

void GCMClientImpl::ResetStore() {}

void GCMClientImpl::SetAccountTokens(
    const std::vector<AccountTokenInfo>& account_tokens) {}

void GCMClientImpl::UpdateAccountMapping(
    const AccountMapping& account_mapping) {}

void GCMClientImpl::RemoveAccountMapping(const CoreAccountId& account_id) {}

void GCMClientImpl::SetLastTokenFetchTime(const base::Time& time) {}

void GCMClientImpl::UpdateHeartbeatTimer(
    std::unique_ptr<base::RetainingOneShotTimer> timer) {}

void GCMClientImpl::AddInstanceIDData(const std::string& app_id,
                                      const std::string& instance_id,
                                      const std::string& extra_data) {}

void GCMClientImpl::RemoveInstanceIDData(const std::string& app_id) {}

void GCMClientImpl::GetInstanceIDData(const std::string& app_id,
                                      std::string* instance_id,
                                      std::string* extra_data) {}

void GCMClientImpl::AddHeartbeatInterval(const std::string& scope,
                                         int interval_ms) {}

void GCMClientImpl::RemoveHeartbeatInterval(const std::string& scope) {}

void GCMClientImpl::StartCheckin() {}

void GCMClientImpl::OnCheckinCompleted(
    net::HttpStatusCode response_code,
    const checkin_proto::AndroidCheckinResponse& checkin_response) {}

void GCMClientImpl::SetGServicesSettingsCallback(bool success) {}

void GCMClientImpl::SchedulePeriodicCheckin() {}

base::TimeDelta GCMClientImpl::GetTimeToNextCheckin() const {}

void GCMClientImpl::SetLastCheckinInfoCallback(bool success) {}

void GCMClientImpl::SetDeviceCredentialsCallback(bool success) {}

void GCMClientImpl::UpdateRegistrationCallback(bool success) {}

void GCMClientImpl::DefaultStoreCallback(bool success) {}

void GCMClientImpl::IgnoreWriteResultCallback(
    const std::string& operation_suffix_for_uma,
    bool success) {}

void GCMClientImpl::DestroyStoreCallback(bool success) {}

void GCMClientImpl::ResetStoreCallback(bool success) {}

void GCMClientImpl::Stop() {}

void GCMClientImpl::ResetCache() {}

void GCMClientImpl::Register(
    scoped_refptr<RegistrationInfo> registration_info) {}

void GCMClientImpl::OnRegisterCompleted(
    scoped_refptr<RegistrationInfo> registration_info,
    RegistrationRequest::Status status,
    const std::string& registration_id) {}

bool GCMClientImpl::ValidateRegistration(
    scoped_refptr<RegistrationInfo> registration_info,
    const std::string& registration_id) {}

void GCMClientImpl::Unregister(
    scoped_refptr<RegistrationInfo> registration_info) {}

void GCMClientImpl::OnUnregisterCompleted(
    scoped_refptr<RegistrationInfo> registration_info,
    UnregistrationRequest::Status status) {}

void GCMClientImpl::OnGCMStoreDestroyed(bool success) {}

void GCMClientImpl::Send(const std::string& app_id,
                         const std::string& receiver_id,
                         const OutgoingMessage& message) {}

std::string GCMClientImpl::GetStateString() const {}

void GCMClientImpl::RecordDecryptionFailure(const std::string& app_id,
                                            GCMDecryptionResult result) {}

void GCMClientImpl::SetRecording(bool recording) {}

void GCMClientImpl::ClearActivityLogs() {}

GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const {}

void GCMClientImpl::OnActivityRecorded() {}

void GCMClientImpl::OnConnected(const GURL& current_server,
                                const net::IPEndPoint& ip_endpoint) {}

void GCMClientImpl::OnDisconnected() {}

void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) {}

void GCMClientImpl::OnMessageSentToMCS(int64_t user_serial_number,
                                       const std::string& app_id,
                                       const std::string& message_id,
                                       MCSClient::MessageSendStatus status) {}

void GCMClientImpl::OnMCSError() {}

void GCMClientImpl::HandleIncomingMessage(const gcm::MCSMessage& message) {}

void GCMClientImpl::HandleIncomingDataMessage(
    const std::string& app_id,
    bool was_subtype,
    const mcs_proto::DataMessageStanza& data_message_stanza,
    MessageData& message_data) {}

void GCMClientImpl::HandleIncomingDeletedMessages(
    const std::string& app_id,
    const mcs_proto::DataMessageStanza& data_message_stanza,
    MessageData& message_data) {}

void GCMClientImpl::HandleIncomingSendError(
    const std::string& app_id,
    const mcs_proto::DataMessageStanza& data_message_stanza,
    MessageData& message_data) {}

bool GCMClientImpl::HasStandaloneRegisteredApp() const {}

}  // namespace gcm