blob: 8012b2fd1132c1ba39fc4d49b0055d95740b09f7 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COBALT_UPDATER_CONFIGURATOR_H_
#define COBALT_UPDATER_CONFIGURATOR_H_
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "cobalt/network/network_module.h"
#include "components/update_client/configurator.h"
class GURL;
class PrefService;
namespace base {
class Version;
} // namespace base
namespace service_manager {
class Connector;
} // namespace service_manager
namespace update_client {
class ActivityDataService;
class NetworkFetcherFactory;
class ProtocolHandlerFactory;
} // namespace update_client
namespace cobalt {
namespace updater {
class Configurator : public update_client::Configurator {
public:
explicit Configurator(network::NetworkModule* network_module);
// Configurator for update_client::Configurator.
int InitialDelay() const override;
int NextCheckDelay() const override;
int OnDemandDelay() const override;
int UpdateDelay() const override;
std::vector<GURL> UpdateUrl() const override;
std::vector<GURL> PingUrl() const override;
std::string GetProdId() const override;
base::Version GetBrowserVersion() const override;
std::string GetChannel() const override;
std::string GetBrand() const override;
std::string GetLang() const override;
std::string GetOSLongName() const override;
base::flat_map<std::string, std::string> ExtraRequestParams() const override;
std::string GetDownloadPreference() const override;
scoped_refptr<update_client::NetworkFetcherFactory> GetNetworkFetcherFactory()
override;
scoped_refptr<update_client::UnzipperFactory> GetUnzipperFactory() override;
scoped_refptr<update_client::PatcherFactory> GetPatcherFactory() override;
bool EnabledDeltas() const override;
bool EnabledComponentUpdates() const override;
bool EnabledBackgroundDownloader() const override;
bool EnabledCupSigning() const override;
PrefService* GetPrefService() const override;
update_client::ActivityDataService* GetActivityDataService() const override;
bool IsPerUserInstall() const override;
std::vector<uint8_t> GetRunActionKeyHash() const override;
std::string GetAppGuid() const override;
std::unique_ptr<update_client::ProtocolHandlerFactory>
GetProtocolHandlerFactory() const override;
update_client::RecoveryCRXElevator GetRecoveryCRXElevator() const override;
void SetChannel(const std::string& updater_channel) override;
void MarkChannelChanged() { is_channel_changed = true; }
bool IsChannelChanged() const override { return is_channel_changed; }
bool IsChannelValid(const std::string& channel);
std::string GetUpdaterStatus() const;
void SetUpdaterStatus(const std::string& status);
private:
friend class base::RefCountedThreadSafe<Configurator>;
~Configurator() override;
std::unique_ptr<PrefService> pref_service_;
scoped_refptr<update_client::NetworkFetcherFactory> network_fetcher_factory_;
scoped_refptr<update_client::UnzipperFactory> unzip_factory_;
scoped_refptr<update_client::PatcherFactory> patch_factory_;
std::string updater_channel_;
base::Lock updater_channel_lock_;
bool is_channel_changed = false;
std::string updater_status_;
base::Lock updater_status_lock_;
DISALLOW_COPY_AND_ASSIGN(Configurator);
};
} // namespace updater
} // namespace cobalt
#endif // COBALT_UPDATER_CONFIGURATOR_H_