chromium/net/http/http_transaction_test_util.cc

// Copyright 2014 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/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "net/http/http_transaction_test_util.h"

#include <algorithm>
#include <unordered_map>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
#include "net/base/net_errors.h"
#include "net/base/network_isolation_key.h"
#include "net/base/proxy_chain.h"
#include "net/base/schemeful_site.h"
#include "net/cert/x509_certificate.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_cache.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_info.h"
#include "net/http/http_transaction.h"
#include "net/log/net_log.h"
#include "net/log/net_log_source.h"
#include "net/ssl/ssl_private_key.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace net {

namespace {
MockTransactionMap;
static MockTransactionMap mock_transactions;

void AddMockTransaction(const MockTransaction* trans) {}

void RemoveMockTransaction(const MockTransaction* trans) {}

}  // namespace

TransportInfo DefaultTransportInfo() {}

//-----------------------------------------------------------------------------
// mock transaction data

const MockTransaction kSimpleGET_Transaction =;

const MockTransaction kSimplePOST_Transaction =;

const MockTransaction kTypicalGET_Transaction =;

const MockTransaction kETagGET_Transaction =;

const MockTransaction kRangeGET_Transaction =;

static const MockTransaction* const kBuiltinMockTransactions[] =;

const MockTransaction* FindMockTransaction(const GURL& url) {}

ScopedMockTransaction::ScopedMockTransaction(const char* url)
    :{}

ScopedMockTransaction::ScopedMockTransaction(const MockTransaction& t,
                                             const char* url)
    :{}

ScopedMockTransaction::~ScopedMockTransaction() {}

MockHttpRequest::MockHttpRequest(const MockTransaction& t) {}

std::string MockHttpRequest::CacheKey() {}

//-----------------------------------------------------------------------------

TestTransactionConsumer::TestTransactionConsumer(
    RequestPriority priority,
    HttpTransactionFactory* factory) {}

TestTransactionConsumer::~TestTransactionConsumer() = default;

void TestTransactionConsumer::Start(const HttpRequestInfo* request,
                                    const NetLogWithSource& net_log) {}

void TestTransactionConsumer::DidStart(int result) {}

void TestTransactionConsumer::DidRead(int result) {}

void TestTransactionConsumer::DidFinish(int result) {}

void TestTransactionConsumer::Read() {}

void TestTransactionConsumer::OnIOComplete(int result) {}

MockNetworkTransaction::MockNetworkTransaction(RequestPriority priority,
                                               MockNetworkLayer* factory)
    :{}

MockNetworkTransaction::~MockNetworkTransaction() {}

int MockNetworkTransaction::Start(const HttpRequestInfo* request,
                                  CompletionOnceCallback callback,
                                  const NetLogWithSource& net_log) {}

int MockNetworkTransaction::RestartIgnoringLastError(
    CompletionOnceCallback callback) {}

int MockNetworkTransaction::RestartWithCertificate(
    scoped_refptr<X509Certificate> client_cert,
    scoped_refptr<SSLPrivateKey> client_private_key,
    CompletionOnceCallback callback) {}

int MockNetworkTransaction::RestartWithAuth(const AuthCredentials& credentials,
                                            CompletionOnceCallback callback) {}

void MockNetworkTransaction::PopulateNetErrorDetails(
    NetErrorDetails* /*details*/) const {}

bool MockNetworkTransaction::IsReadyToRestartForAuth() {}

int MockNetworkTransaction::Read(IOBuffer* buf,
                                 int buf_len,
                                 CompletionOnceCallback callback) {}

void MockNetworkTransaction::StopCaching() {}

int64_t MockNetworkTransaction::GetTotalReceivedBytes() const {}

int64_t MockNetworkTransaction::GetTotalSentBytes() const {}

int64_t MockNetworkTransaction::GetReceivedBodyBytes() const {}

void MockNetworkTransaction::DoneReading() {}

const HttpResponseInfo* MockNetworkTransaction::GetResponseInfo() const {}

LoadState MockNetworkTransaction::GetLoadState() const {}

void MockNetworkTransaction::SetQuicServerInfo(
    QuicServerInfo* quic_server_info) {}

bool MockNetworkTransaction::GetLoadTimingInfo(
    LoadTimingInfo* load_timing_info) const {}

bool MockNetworkTransaction::GetRemoteEndpoint(IPEndPoint* endpoint) const {}

void MockNetworkTransaction::SetPriority(RequestPriority priority) {}

void MockNetworkTransaction::SetWebSocketHandshakeStreamCreateHelper(
    WebSocketHandshakeStreamBase::CreateHelper* create_helper) {}

// static
const int64_t MockNetworkTransaction::kTotalReceivedBytes =;

// static
const int64_t MockNetworkTransaction::kTotalSentBytes =;

// static
const int64_t MockNetworkTransaction::kReceivedBodyBytes =;

int MockNetworkTransaction::StartInternal(HttpRequestInfo request,
                                          CompletionOnceCallback callback) {}

int MockNetworkTransaction::DoNotifyBeforeCreateStream() {}

int MockNetworkTransaction::DoCreateStream() {}

int MockNetworkTransaction::DoCreateStreamComplete(int result) {}

int MockNetworkTransaction::DoConnectedCallback() {}

int MockNetworkTransaction::DoConnectedCallbackComplete(int result) {}

int MockNetworkTransaction::DoBuildRequest() {}

int MockNetworkTransaction::DoBuildRequestComplete(int result) {}

int MockNetworkTransaction::DoSendRequest() {}

int MockNetworkTransaction::DoSendRequestComplete(int result) {}

int MockNetworkTransaction::DoReadHeaders() {}

int MockNetworkTransaction::DoReadHeadersComplete(int result) {}

int MockNetworkTransaction::DoLoop(int result) {}

void MockNetworkTransaction::OnIOComplete(int result) {}

void MockNetworkTransaction::SetBeforeNetworkStartCallback(
    BeforeNetworkStartCallback callback) {}

void MockNetworkTransaction::SetModifyRequestHeadersCallback(
    base::RepeatingCallback<void(HttpRequestHeaders*)> callback) {}

void MockNetworkTransaction::SetConnectedCallback(
    const ConnectedCallback& callback) {}

int MockNetworkTransaction::ResumeNetworkStart() {}

ConnectionAttempts MockNetworkTransaction::GetConnectionAttempts() const {}

void MockNetworkTransaction::CloseConnectionOnDestruction() {}

bool MockNetworkTransaction::IsMdlMatchForMetrics() const {}

void MockNetworkTransaction::CallbackLater(CompletionOnceCallback callback,
                                           int result) {}

void MockNetworkTransaction::RunCallback(CompletionOnceCallback callback,
                                         int result) {}

MockNetworkLayer::MockNetworkLayer() = default;

MockNetworkLayer::~MockNetworkLayer() = default;

void MockNetworkLayer::TransactionDoneReading() {}

void MockNetworkLayer::TransactionStopCaching() {}

void MockNetworkLayer::ResetTransactionCount() {}

int MockNetworkLayer::CreateTransaction(
    RequestPriority priority,
    std::unique_ptr<HttpTransaction>* trans) {}

HttpCache* MockNetworkLayer::GetCache() {}

HttpNetworkSession* MockNetworkLayer::GetSession() {}

void MockNetworkLayer::SetClock(base::Clock* clock) {}

base::Time MockNetworkLayer::Now() {}

//-----------------------------------------------------------------------------
// helpers

int ReadTransaction(HttpTransaction* trans, std::string* result) {}

//-----------------------------------------------------------------------------
// connected callback handler

ConnectedHandler::ConnectedHandler() = default;
ConnectedHandler::~ConnectedHandler() = default;

ConnectedHandler::ConnectedHandler(const ConnectedHandler&) = default;
ConnectedHandler& ConnectedHandler::operator=(const ConnectedHandler&) =
    default;
ConnectedHandler::ConnectedHandler(ConnectedHandler&&) = default;
ConnectedHandler& ConnectedHandler::operator=(ConnectedHandler&&) = default;

int ConnectedHandler::OnConnected(const TransportInfo& info,
                                  CompletionOnceCallback callback) {}

}  // namespace net