chromium/chrome/updater/policy/policy_fetcher.h

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

#ifndef CHROME_UPDATER_POLICY_POLICY_FETCHER_H_
#define CHROME_UPDATER_POLICY_POLICY_FETCHER_H_

#include <optional>
#include <vector>

#include "base/functional/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "chrome/updater/policy/manager.h"
#include "chrome/updater/policy/service.h"
#include "url/gurl.h"

namespace updater {

// Base class for the policy fetchers.
class PolicyFetcher : public base::RefCountedThreadSafe<PolicyFetcher> {};

// A wrapper class that contains a number of `PolicyFetchers` and falls back
// between them when one encounters an error.
class FallbackPolicyFetcher : public PolicyFetcher {};

// Creates an out-of-process policy fetcher that delegates fetch tasks to the
// enterprise companion app.
[[nodiscard]] scoped_refptr<PolicyFetcher> CreateOutOfProcessPolicyFetcher(
    bool usage_stats_enabled,
    std::optional<bool> override_is_managed_device);

// Creates an in-process policy fether.
//   `server_url`: the DM server endpoint.
//   `proxy_configuration`: Proxy configurations set by the existing policies.
[[nodiscard]] scoped_refptr<PolicyFetcher> CreateInProcessPolicyFetcher(
    const GURL& server_url,
    std::optional<PolicyServiceProxyConfiguration> proxy_configuration,
    std::optional<bool> override_is_managed_device);

}  // namespace updater

#endif  // CHROME_UPDATER_POLICY_POLICY_FETCHER_H_