chromium/components/update_client/op_download.cc

// Copyright 2024 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/update_client/op_download.h"

#include <cstdint>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/update_client/cancellation.h"
#include "components/update_client/component.h"
#include "components/update_client/configurator.h"
#include "components/update_client/crx_downloader.h"
#include "components/update_client/crx_downloader_factory.h"
#include "components/update_client/protocol_definition.h"
#include "components/update_client/task_traits.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/update_engine.h"
#include "url/gurl.h"

namespace update_client {

namespace {

#if BUILDFLAG(IS_MAC)
// The minimum size of a download to attempt it at background priority.
constexpr int64_t kBackgroundDownloadSizeThreshold = 10000000; /*10 MB*/
#endif

bool CanDoBackgroundDownload(scoped_refptr<const UpdateContext> update_context,
                             int64_t size) {}

// Returns a string literal corresponding to the value of the downloader |d|.
const char* DownloaderToString(CrxDownloader::DownloadMetrics::Downloader d) {}

base::Value::Dict MakeEvent(const CrxDownloader::DownloadMetrics& dm) {}

void DownloadComplete(
    scoped_refptr<CrxDownloader> crx_downloader,
    scoped_refptr<Cancellation> cancellation,
    base::RepeatingCallback<void(base::Value::Dict)> event_adder,
    base::OnceCallback<
        void(const base::expected<base::FilePath, CategorizedError>&)> callback,
    const CrxDownloader::Result& download_result) {}

void HandleAvailableSpace(
    scoped_refptr<const UpdateContext> update_context,
    scoped_refptr<Cancellation> cancellation,
    const std::vector<GURL>& urls,
    int64_t size,
    const std::string& hash,
    CrxDownloader::ProgressCallback progress_callback,
    base::RepeatingCallback<void(base::Value::Dict)> event_adder,
    base::OnceCallback<
        void(const base::expected<base::FilePath, CategorizedError>&)> callback,
    int64_t available_bytes) {}

}  // namespace

base::OnceClosure DownloadOperation(
    scoped_refptr<const UpdateContext> update_context,
    const std::vector<GURL>& urls,
    int64_t size,
    const std::string& hash,
    base::RepeatingCallback<void(base::Value::Dict)> event_adder,
    CrxDownloader::ProgressCallback progress_callback,
    base::OnceCallback<void(
        const base::expected<base::FilePath, CategorizedError>&)> callback) {}

}  // namespace update_client