chromium/google_apis/common/base_requests.cc

// Copyright 2012 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 "google_apis/common/base_requests.h"

#include <stddef.h>

#include <algorithm>
#include <memory>
#include <string>
#include <string_view>
#include <utility>

#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "google_apis/common/request_sender.h"
#include "google_apis/common/task_util.h"
#include "google_apis/credentials_mode.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/url_response_head.mojom.h"

namespace {

// Template for optional OAuth2 authorization HTTP header.
const char kAuthorizationHeaderFormat[] =;
// Template for GData API version HTTP header.
const char kGDataVersionHeader[] =;

// Maximum number of attempts for re-authentication per request.
const int kMaxReAuthenticateAttemptsPerRequest =;

// Returns response headers as a string. Returns a warning message if
// |response_head| does not contain a valid response. Used only for debugging.
std::string GetResponseHeadersAsString(
    const network::mojom::URLResponseHead& response_head) {}

}  // namespace

namespace google_apis {

std::optional<std::string> MapJsonErrorToReason(const std::string& error_body) {}

std::unique_ptr<base::Value> ParseJson(const std::string& json) {}

std::string HttpRequestMethodToString(HttpRequestMethod method) {}

UrlFetchRequestBase::UrlFetchRequestBase(
    RequestSender* sender,
    ProgressCallback upload_progress_callback,
    ProgressCallback download_progress_callback)
    :{}

UrlFetchRequestBase::~UrlFetchRequestBase() = default;

void UrlFetchRequestBase::Start(const std::string& access_token,
                                const std::string& custom_user_agent,
                                ReAuthenticateCallback callback) {}

void UrlFetchRequestBase::Prepare(PrepareCallback callback) {}

void UrlFetchRequestBase::StartAfterPrepare(
    const std::string& access_token,
    const std::string& custom_user_agent,
    ReAuthenticateCallback callback,
    ApiErrorCode code) {}

void UrlFetchRequestBase::OnDownloadProgress(ProgressCallback progress_callback,
                                             uint64_t current) {}

void UrlFetchRequestBase::OnUploadProgress(ProgressCallback progress_callback,
                                           uint64_t position,
                                           uint64_t total) {}

void UrlFetchRequestBase::OnResponseStarted(
    const GURL& final_url,
    const network::mojom::URLResponseHead& response_head) {}

UrlFetchRequestBase::DownloadData::DownloadData(
    scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
    :{}

UrlFetchRequestBase::DownloadData::~DownloadData() {}

// static
bool UrlFetchRequestBase::WriteFileData(std::string file_data,
                                        DownloadData* download_data) {}

void UrlFetchRequestBase::OnWriteComplete(
    std::unique_ptr<DownloadData> download_data,
    base::OnceClosure resume,
    bool write_success) {}

void UrlFetchRequestBase::OnDataReceived(std::string_view string_piece,
                                         base::OnceClosure resume) {}

void UrlFetchRequestBase::OnComplete(bool success) {}

void UrlFetchRequestBase::OnOutputFileClosed(bool success) {}

void UrlFetchRequestBase::OnRetry(base::OnceClosure start_retry) {}

HttpRequestMethod UrlFetchRequestBase::GetRequestType() const {}

std::vector<std::string> UrlFetchRequestBase::GetExtraRequestHeaders() const {}

bool UrlFetchRequestBase::GetContentData(std::string* upload_content_type,
                                         std::string* upload_content) {}

bool UrlFetchRequestBase::GetContentFile(base::FilePath* local_file_path,
                                         int64_t* range_offset,
                                         int64_t* range_length,
                                         std::string* upload_content_type) {}

void UrlFetchRequestBase::GetOutputFilePath(
    base::FilePath* local_file_path,
    GetContentCallback* get_content_callback) {}

void UrlFetchRequestBase::Cancel() {}

ApiErrorCode UrlFetchRequestBase::GetErrorCode() const {}

int UrlFetchRequestBase::NetError() const {}

bool UrlFetchRequestBase::CalledOnValidThread() {}

base::SequencedTaskRunner* UrlFetchRequestBase::blocking_task_runner() const {}

void UrlFetchRequestBase::OnProcessURLFetchResultsComplete() {}

void UrlFetchRequestBase::CompleteRequestWithError(ApiErrorCode code) {}

void UrlFetchRequestBase::OnAuthFailed(ApiErrorCode code) {}

base::WeakPtr<AuthenticatedRequestInterface> UrlFetchRequestBase::GetWeakPtr() {}

}  // namespace google_apis