#include "components/update_client/update_engine.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "base/uuid.h"
#include "components/prefs/pref_service.h"
#include "components/update_client/component.h"
#include "components/update_client/configurator.h"
#include "components/update_client/crx_cache.h"
#include "components/update_client/crx_update_item.h"
#include "components/update_client/persisted_data.h"
#include "components/update_client/protocol_parser.h"
#include "components/update_client/update_checker.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/utils.h"
namespace update_client {
UpdateContext::UpdateContext(
scoped_refptr<Configurator> config,
std::optional<scoped_refptr<CrxCache>> crx_cache,
bool is_foreground,
bool is_install,
const std::vector<std::string>& ids,
UpdateClient::CrxStateChangeCallback crx_state_change_callback,
const UpdateEngine::NotifyObserversCallback& notify_observers_callback,
UpdateEngine::Callback callback,
PersistedData* persisted_data,
bool is_update_check_only,
base::RepeatingCallback<int64_t(const base::FilePath&)> get_available_space)
: … { … }
UpdateContext::~UpdateContext() = default;
UpdateEngine::UpdateEngine(
scoped_refptr<Configurator> config,
UpdateChecker::Factory update_checker_factory,
scoped_refptr<PingManager> ping_manager,
const NotifyObserversCallback& notify_observers_callback)
: … { … }
UpdateEngine::~UpdateEngine() = default;
base::RepeatingClosure UpdateEngine::Update(
bool is_foreground,
bool is_install,
const std::vector<std::string>& ids,
UpdateClient::CrxDataCallback crx_data_callback,
UpdateClient::CrxStateChangeCallback crx_state_change_callback,
Callback callback) { … }
void UpdateEngine::CheckForUpdate(
bool is_foreground,
const std::string& id,
UpdateClient::CrxDataCallback crx_data_callback,
UpdateClient::CrxStateChangeCallback crx_state_change_callback,
Callback callback) { … }
base::RepeatingClosure UpdateEngine::InvokeOperation(
bool is_foreground,
bool is_update_check_only,
bool is_install,
const std::vector<std::string>& ids,
UpdateClient::CrxDataCallback crx_data_callback,
UpdateClient::CrxStateChangeCallback crx_state_change_callback,
Callback callback) { … }
void UpdateEngine::StartOperation(
scoped_refptr<UpdateContext> update_context,
const std::vector<std::optional<CrxComponent>>& crx_components) { … }
void UpdateEngine::DoUpdateCheck(scoped_refptr<UpdateContext> update_context) { … }
void UpdateEngine::UpdateCheckResultsAvailable(
scoped_refptr<UpdateContext> update_context,
const std::optional<ProtocolParser::Results>& results,
ErrorCategory error_category,
int error,
int retry_after_sec) { … }
void UpdateEngine::UpdateCheckComplete(
scoped_refptr<UpdateContext> update_context) { … }
void UpdateEngine::HandleComponent(
scoped_refptr<UpdateContext> update_context) { … }
void UpdateEngine::HandleComponentComplete(
scoped_refptr<UpdateContext> update_context) { … }
void UpdateEngine::UpdateComplete(scoped_refptr<UpdateContext> update_context,
Error error) { … }
bool UpdateEngine::GetUpdateState(const std::string& id,
CrxUpdateItem* update_item) { … }
bool UpdateEngine::IsThrottled(bool is_foreground) const { … }
void UpdateEngine::SendPing(const CrxComponent& crx_component,
UpdateClient::PingParams ping_params,
Callback callback) { … }
}