#include "components/sync/engine/sync_scheduler_impl.h"
#include <cstring>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/rand_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/platform_thread.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/engine/backoff_delay_provider.h"
#include "components/sync/engine/sync_protocol_error.h"
#include "components/sync/protocol/sync_enums.pb.h"
TimeTicks;
namespace syncer {
namespace {
constexpr base::TimeDelta kLocalChangeNudgeDelayForTest = …;
bool IsConfigRelatedUpdateOriginValue(
sync_pb::SyncEnums::GetUpdatesOrigin origin) { … }
bool ShouldRequestEarlyExit(const SyncProtocolError& error) { … }
bool IsActionableProtocolError(const SyncProtocolError& error) { … }
}
#define SDVLOG …
SyncSchedulerImpl::SyncSchedulerImpl(
const std::string& name,
std::unique_ptr<BackoffDelayProvider> delay_provider,
SyncCycleContext* context,
std::unique_ptr<Syncer> syncer,
bool ignore_auth_credentials)
: … { … }
SyncSchedulerImpl::~SyncSchedulerImpl() { … }
void SyncSchedulerImpl::OnCredentialsUpdated() { … }
void SyncSchedulerImpl::OnConnectionStatusChange(
network::mojom::ConnectionType type) { … }
void SyncSchedulerImpl::OnServerConnectionErrorFixed() { … }
void SyncSchedulerImpl::Start(Mode mode, base::Time last_poll_time) { … }
DataTypeSet SyncSchedulerImpl::GetEnabledAndUnblockedTypes() { … }
void SyncSchedulerImpl::SetHasPendingInvalidations(DataType type,
bool has_invalidation) { … }
void SyncSchedulerImpl::SendInitialSnapshot() { … }
void SyncSchedulerImpl::ScheduleConfiguration(
sync_pb::SyncEnums::GetUpdatesOrigin origin,
DataTypeSet types_to_download,
base::OnceClosure ready_task) { … }
bool SyncSchedulerImpl::CanRunJobNow(RespectGlobalBackoff respect_backoff) { … }
bool SyncSchedulerImpl::CanRunNudgeJobNow(
RespectGlobalBackoff respect_backoff) { … }
void SyncSchedulerImpl::ScheduleLocalNudge(DataType type) { … }
void SyncSchedulerImpl::ScheduleLocalRefreshRequest(DataTypeSet types) { … }
void SyncSchedulerImpl::ScheduleInvalidationNudge(DataType data_type) { … }
void SyncSchedulerImpl::ScheduleInitialSyncNudge(DataType data_type) { … }
void SyncSchedulerImpl::ScheduleNudgeImpl(const base::TimeDelta& delay) { … }
const char* SyncSchedulerImpl::GetModeString(SyncScheduler::Mode mode) { … }
void SyncSchedulerImpl::ForceShortNudgeDelayForTest() { … }
SyncSchedulerImpl::ConfigurationParams::ConfigurationParams(
sync_pb::SyncEnums::GetUpdatesOrigin origin,
DataTypeSet types_to_download,
base::OnceClosure ready)
: … { … }
SyncSchedulerImpl::ConfigurationParams::~ConfigurationParams() = default;
void SyncSchedulerImpl::DoNudgeSyncCycleJob() { … }
void SyncSchedulerImpl::DoConfigurationSyncCycleJob(
RespectGlobalBackoff respect_backoff) { … }
void SyncSchedulerImpl::HandleSuccess() { … }
void SyncSchedulerImpl::HandleFailure(
const ModelNeutralState& model_neutral_state) { … }
void SyncSchedulerImpl::DoPollSyncCycleJob() { … }
base::TimeDelta SyncSchedulerImpl::GetPollInterval() { … }
void SyncSchedulerImpl::AdjustPolling(PollAdjustType type) { … }
void SyncSchedulerImpl::RestartWaiting() { … }
void SyncSchedulerImpl::Stop() { … }
void SyncSchedulerImpl::TrySyncCycleJob(RespectGlobalBackoff respect_backoff) { … }
void SyncSchedulerImpl::TrySyncCycleJobImpl(
RespectGlobalBackoff respect_backoff) { … }
void SyncSchedulerImpl::PollTimerCallback() { … }
void SyncSchedulerImpl::RetryTimerCallback() { … }
void SyncSchedulerImpl::Unthrottle() { … }
void SyncSchedulerImpl::OnTypesUnblocked() { … }
void SyncSchedulerImpl::PerformDelayedNudge() { … }
void SyncSchedulerImpl::ExponentialBackoffRetry() { … }
void SyncSchedulerImpl::NotifyRetryTime(base::Time retry_time) { … }
void SyncSchedulerImpl::NotifyBlockedTypesChanged() { … }
bool SyncSchedulerImpl::IsGlobalThrottle() const { … }
bool SyncSchedulerImpl::IsGlobalBackoff() const { … }
void SyncSchedulerImpl::OnThrottled(const base::TimeDelta& throttle_duration) { … }
void SyncSchedulerImpl::OnTypesThrottled(
DataTypeSet types,
const base::TimeDelta& throttle_duration) { … }
void SyncSchedulerImpl::OnTypesBackedOff(DataTypeSet types) { … }
bool SyncSchedulerImpl::IsAnyThrottleOrBackoff() { … }
void SyncSchedulerImpl::OnReceivedPollIntervalUpdate(
const base::TimeDelta& new_interval) { … }
void SyncSchedulerImpl::OnReceivedCustomNudgeDelays(
const std::map<DataType, base::TimeDelta>& nudge_delays) { … }
void SyncSchedulerImpl::OnSyncProtocolError(
const SyncProtocolError& sync_protocol_error) { … }
void SyncSchedulerImpl::OnReceivedGuRetryDelay(const base::TimeDelta& delay) { … }
void SyncSchedulerImpl::OnReceivedMigrationRequest(DataTypeSet types) { … }
void SyncSchedulerImpl::OnReceivedQuotaParamsForExtensionTypes(
std::optional<int> max_tokens,
std::optional<base::TimeDelta> refill_interval,
std::optional<base::TimeDelta> depleted_quota_nudge_delay) { … }
void SyncSchedulerImpl::SetNotificationsEnabled(bool notifications_enabled) { … }
bool SyncSchedulerImpl::IsEarlierThanCurrentPendingJob(
const base::TimeDelta& delay) { … }
#undef SDVLOG
}