chromium/chrome/updater/net/network_fetcher_linux.cc

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <curl/curl.h>
#include <curl/system.h>
#include <dlfcn.h>

#include <array>
#include <memory>
#include <optional>
#include <string>
#include <utility>

#include "base/containers/flat_map.h"
#include "base/files/file.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/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/numerics/checked_math.h"
#include "base/sequence_checker.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/threading/sequence_bound.h"
#include "chrome/updater/net/network.h"
#include "chrome/updater/policy/service.h"
#include "chrome/updater/util/util.h"
#include "components/update_client/network.h"
#include "url/gurl.h"

namespace updater {
namespace {

struct CurlDeleter {};
CurlUniquePtr;

class LibcurlNetworkFetcherImpl {};

LibcurlNetworkFetcherImpl::LibcurlNetworkFetcherImpl(
    CurlUniquePtr curl,
    scoped_refptr<base::SequencedTaskRunner> callback_sequence)
    :{}
LibcurlNetworkFetcherImpl::~LibcurlNetworkFetcherImpl() = default;

void LibcurlNetworkFetcherImpl::PostRequest(
    const GURL& url,
    const std::string& post_data,
    const std::string& content_type,
    const base::flat_map<std::string, std::string>& post_additional_headers,
    ResponseStartedCallback response_started_callback,
    ProgressCallback progress_callback,
    PostRequestCompleteCallback post_request_complete_callback) {}

void LibcurlNetworkFetcherImpl::DownloadToFile(
    const GURL& url,
    const base::FilePath& file_path,
    ResponseStartedCallback response_started_callback,
    ProgressCallback progress_callback,
    DownloadToFileCompleteCallback download_to_file_complete_callback) {}

void LibcurlNetworkFetcherImpl::OnTransferInfo(curl_off_t total,
                                               curl_off_t current) {}

size_t LibcurlNetworkFetcherImpl::CurlWriteStringCallback(void* data,
                                                          size_t member_size,
                                                          size_t num_members,
                                                          void* userp) {}

size_t LibcurlNetworkFetcherImpl::CurlHeaderCallback(char* data,
                                                     size_t member_size,
                                                     size_t num_members,
                                                     void* userp) {}

size_t LibcurlNetworkFetcherImpl::CurlWriteFileCallback(void* data,
                                                        size_t member_size,
                                                        size_t num_members,
                                                        void* userp) {}

int LibcurlNetworkFetcherImpl::CurlTransferCallback(void* userp,
                                                    curl_off_t dltotal,
                                                    curl_off_t dlnow,
                                                    curl_off_t ultotal,
                                                    curl_off_t ulnow) {}

// LibcurlNetworkFetcher wraps a |LibcurlNetworkFetcherImpl| in a
// |base::SequenceBound|. This allows the wrapped fetcher to run solely in a
// dedicated io sequence.
class LibcurlNetworkFetcher : public update_client::NetworkFetcher {};

LibcurlNetworkFetcher::LibcurlNetworkFetcher(CurlUniquePtr curl)
    :{}

void LibcurlNetworkFetcher::PostRequest(
    const GURL& url,
    const std::string& post_data,
    const std::string& content_type,
    const base::flat_map<std::string, std::string>& post_additional_headers,
    ResponseStartedCallback response_started_callback,
    ProgressCallback progress_callback,
    PostRequestCompleteCallback post_request_complete_callback) {}

base::OnceClosure LibcurlNetworkFetcher::DownloadToFile(
    const GURL& url,
    const base::FilePath& file_path,
    ResponseStartedCallback response_started_callback,
    ProgressCallback progress_callback,
    DownloadToFileCompleteCallback download_to_file_complete_callback) {}

}  // namespace

class NetworkFetcherFactory::Impl {};

NetworkFetcherFactory::NetworkFetcherFactory(
    std::optional<PolicyServiceProxyConfiguration>) {}
NetworkFetcherFactory::~NetworkFetcherFactory() = default;

std::unique_ptr<update_client::NetworkFetcher> NetworkFetcherFactory::Create()
    const {}

}  // namespace updater