chromium/components/policy/core/common/cloud/cloud_policy_refresh_scheduler.cc

// Copyright 2012 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/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"

#include <algorithm>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "build/build_config.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_service.h"
#include "components/policy/core/common/cloud/user_cloud_policy_store.h"

namespace policy {

namespace {

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
BASE_FEATURE();
#endif

base::Clock* clock_for_testing_ =;

const base::Clock* GetClock() {}

base::TickClock* tick_clock_for_testing_ =;

const base::TickClock* GetTickClock() {}

}  // namespace

#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)

const int64_t CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs =
    24 * 60 * 60 * 1000;  // 1 day.
const int64_t CloudPolicyRefreshScheduler::kUnmanagedRefreshDelayMs =
    24 * 60 * 60 * 1000;  // 1 day.
// Delay for periodic refreshes when the invalidations service is available,
// in milliseconds.
// TODO(joaodasilva): increase this value once we're confident that the
// invalidations channel works as expected.
const int64_t CloudPolicyRefreshScheduler::kWithInvalidationsRefreshDelayMs =
    24 * 60 * 60 * 1000;  // 1 day.
const int64_t CloudPolicyRefreshScheduler::kInitialErrorRetryDelayMs =
    5 * 60 * 1000;  // 5 minutes.
const int64_t CloudPolicyRefreshScheduler::kRefreshDelayMinMs =
    30 * 60 * 1000;  // 30 minutes.
const int64_t CloudPolicyRefreshScheduler::kRefreshDelayMaxMs =
    7 * 24 * 60 * 60 * 1000;  // 1 week.
const int64_t CloudPolicyRefreshScheduler::kRandomSaltDelayMaxValueMs =
    5 * 60 * 1000;  // 5 minutes.

#else

const int64_t CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs =;  // 3 hours.
const int64_t CloudPolicyRefreshScheduler::kUnmanagedRefreshDelayMs =;  // 1 day.
// Delay for periodic refreshes when the invalidations service is available,
// in milliseconds.
const int64_t CloudPolicyRefreshScheduler::kWithInvalidationsRefreshDelayMs =;  // 1 day.
const int64_t CloudPolicyRefreshScheduler::kInitialErrorRetryDelayMs =;  // 5 minutes.
const int64_t CloudPolicyRefreshScheduler::kRefreshDelayMinMs =;  // 30 minutes.
const int64_t CloudPolicyRefreshScheduler::kRefreshDelayMaxMs =;  // 1 day.
const int64_t CloudPolicyRefreshScheduler::kRandomSaltDelayMaxValueMs =;  // 5 minutes.

#endif

CloudPolicyRefreshScheduler::CloudPolicyRefreshScheduler(
    CloudPolicyClient* client,
    CloudPolicyStore* store,
    CloudPolicyService* service,
    const scoped_refptr<base::SequencedTaskRunner>& task_runner,
    network::NetworkConnectionTrackerGetter network_connection_tracker_getter)
    :{}

CloudPolicyRefreshScheduler::~CloudPolicyRefreshScheduler() {}

void CloudPolicyRefreshScheduler::SetDesiredRefreshDelay(
    int64_t refresh_delay) {}

int64_t CloudPolicyRefreshScheduler::GetActualRefreshDelay() const {}

void CloudPolicyRefreshScheduler::RefreshSoon(PolicyFetchReason reason) {}

void CloudPolicyRefreshScheduler::SetInvalidationServiceAvailability(
    bool is_available) {}

void CloudPolicyRefreshScheduler::OnPolicyFetched(CloudPolicyClient* client) {}

void CloudPolicyRefreshScheduler::OnRegistrationStateChanged(
    CloudPolicyClient* client) {}

void CloudPolicyRefreshScheduler::OnClientError(CloudPolicyClient* client) {}

void CloudPolicyRefreshScheduler::OnStoreLoaded(CloudPolicyStore* store) {}

void CloudPolicyRefreshScheduler::OnStoreError(CloudPolicyStore* store) {}

void CloudPolicyRefreshScheduler::OnConnectionChanged(
    network::mojom::ConnectionType type) {}

void CloudPolicyRefreshScheduler::UpdateLastRefreshFromPolicy() {}

void CloudPolicyRefreshScheduler::ScheduleRefresh() {}

void CloudPolicyRefreshScheduler::PerformRefresh(PolicyFetchReason reason) {}

void CloudPolicyRefreshScheduler::RefreshAfter(int delta_ms,
                                               PolicyFetchReason reason) {}

void CloudPolicyRefreshScheduler::CancelRefresh() {}

void CloudPolicyRefreshScheduler::UpdateLastRefresh() {}

void CloudPolicyRefreshScheduler::OnPolicyRefreshed(bool success) {}

// static
base::ScopedClosureRunner CloudPolicyRefreshScheduler::OverrideClockForTesting(
    base::Clock* clock_for_testing) {}

// static
base::ScopedClosureRunner
CloudPolicyRefreshScheduler::OverrideTickClockForTesting(
    base::TickClock* tick_clock_for_testing) {}

void CloudPolicyRefreshScheduler::AddObserver(
    CloudPolicyRefreshSchedulerObserver* observer) {}

void CloudPolicyRefreshScheduler::RemoveObserver(
    CloudPolicyRefreshSchedulerObserver* observer) {}

}  // namespace policy