// 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. #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_REFRESH_SCHEDULER_H_ #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_REFRESH_SCHEDULER_H_ #include <stdint.h> #include "base/cancelable_callback.h" #include "base/functional/callback_helpers.h" #include "base/memory/raw_ptr.h" #include "base/time/clock.h" #include "base/time/tick_clock.h" #include "base/time/time.h" #include "components/policy/core/common/cloud/cloud_policy_client.h" #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler_observer.h" #include "components/policy/core/common/cloud/cloud_policy_store.h" #include "components/policy/policy_export.h" #include "services/network/public/cpp/network_connection_tracker.h" namespace base { class SequencedTaskRunner; } namespace policy { class CloudPolicyService; // Observes CloudPolicyClient and CloudPolicyStore to trigger periodic policy // fetches and issue retries on error conditions. // // Refreshing non-managed responses: // - If there is a cached non-managed response, make sure to only re-query the // server after kUnmanagedRefreshDelayMs. // - NB: For existing policy, an immediate refresh is intentional. // // Refreshing on mobile platforms: // - if no user is signed-in then the |client_| is never registered. // - if the user is signed-in but isn't enterprise then the |client_| is // never registered. // - if the user is signed-in but isn't registered for policy yet then the // |client_| isn't registered either; the UserPolicySigninService will try // to register, and OnRegistrationStateChanged() will be invoked later. // - if the client is signed-in and has policy then its timestamp is used to // determine when to perform the next fetch, which will be once the cached // version is considered "old enough". // // If there is an old policy cache then a fetch will be performed "soon"; if // that fetch fails then a retry is attempted after a delay, with exponential // backoff. If those fetches keep failing then the cached timestamp is *not* // updated, and another fetch (and subsequent retries) will be attempted // again on the next startup. // // But if the cached policy is considered fresh enough then we try to avoid // fetching again on startup; the Android logic differs from the desktop in // this aspect. class POLICY_EXPORT CloudPolicyRefreshScheduler : public CloudPolicyClient::Observer, public CloudPolicyStore::Observer, public network::NetworkConnectionTracker::NetworkConnectionObserver { … }; } // namespace policy #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_REFRESH_SCHEDULER_H_