chromium/content/public/test/test_download_http_response.cc

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

#include "content/public/test/test_download_http_response.h"

#include <inttypes.h>

#include <algorithm>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
#include "base/task/single_thread_task_runner.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/test_completion_callback.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_util.h"
#include "net/test/embedded_test_server/http_response.h"

namespace content {

namespace {

// Lock object for protecting |g_parameters_map|.
base::LazyInstance<base::Lock>::Leaky g_lock =;

ParametersMap;
// Maps url to Parameters so that requests for the same URL will get the same
// parameters.
base::LazyInstance<ParametersMap>::Leaky g_parameters_map =;

const char* kTestDownloadPath =;

// The size of buffer to send the entity body. The header will always be sent in
// one buffer.
const int64_t kBufferSize =;

// Xorshift* PRNG from https://en.wikipedia.org/wiki/Xorshift
uint64_t XorShift64StarWithIndex(uint64_t seed, uint64_t index) {}

// Called to resume the response.
void OnResume(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
              base::OnceClosure resume_callback) {}

void OnResponseSentOnServerIOThread(
    TestDownloadHttpResponse::OnResponseSentCallback callback,
    std::unique_ptr<TestDownloadHttpResponse::CompletedRequest> request) {}

GURL GetURLFromRequest(const net::test_server::HttpRequest& request) {}
// The shim response object used by embedded_test_server. After this object is
// deleted, we may continue to send data with cached SendBytesCallback to
// support pause/resume behaviors.
class HttpResponse : public net::test_server::HttpResponse {};

}  // namespace

const char TestDownloadHttpResponse::kTestDownloadHostName[] =;

// static
GURL TestDownloadHttpResponse::GetNextURLForDownload() {}

TestDownloadHttpResponse::HttpResponseData::HttpResponseData(
    int64_t min_offset,
    int64_t max_offset,
    const std::string& response,
    bool is_transient,
    bool delay_response)
    :{}

// static
TestDownloadHttpResponse::Parameters
TestDownloadHttpResponse::Parameters::WithSingleInterruption(
    const TestDownloadHttpResponse::InjectErrorCallback& inject_error_cb) {}

TestDownloadHttpResponse::Parameters::Parameters()
    :{}

TestDownloadHttpResponse::Parameters::Parameters(const Parameters& that) =
    default;
TestDownloadHttpResponse::Parameters& TestDownloadHttpResponse::Parameters::
operator=(const Parameters& that) = default;

TestDownloadHttpResponse::Parameters::~Parameters() = default;

void TestDownloadHttpResponse::Parameters::ClearInjectedErrors() {}

void TestDownloadHttpResponse::Parameters::SetResponseForRangeRequest(
    int64_t min_offset,
    int64_t max_offset,
    const std::string& response,
    bool is_transient,
    bool delay_response) {}

TestDownloadHttpResponse::CompletedRequest::CompletedRequest(
    const net::test_server::HttpRequest& request)
    :{}

TestDownloadHttpResponse::CompletedRequest::~CompletedRequest() = default;

// static
void TestDownloadHttpResponse::StartServing(
    const TestDownloadHttpResponse::Parameters& parameters,
    const GURL& url) {}

// static
void TestDownloadHttpResponse::StartServingStaticResponse(
    const std::string& response,
    const GURL& url) {}

std::unique_ptr<net::test_server::HttpResponse>
TestDownloadHttpResponse::CreateResponseForTestServer() {}

// static
std::string TestDownloadHttpResponse::GetPatternBytes(int seed,
                                                      int64_t starting_offset,
                                                      int length) {}

TestDownloadHttpResponse::TestDownloadHttpResponse(
    const net::test_server::HttpRequest& request,
    const Parameters& parameters,
    OnResponseSentCallback on_response_sent_callback)
    :{}

TestDownloadHttpResponse::~TestDownloadHttpResponse() = default;

void TestDownloadHttpResponse::SendResponse(
    base::WeakPtr<net::test_server::HttpResponseDelegate> delegate) {}

void TestDownloadHttpResponse::ParseRequestHeader() {}

void TestDownloadHttpResponse::SendResponseHeaders() {}

std::string TestDownloadHttpResponse::GetDefaultResponseHeaders() {}

bool TestDownloadHttpResponse::GetResponseForRangeRequest(
    std::string* output,
    bool* delay_response) {}

bool TestDownloadHttpResponse::HandleRangeAssumingValidatorMatch(
    std::string& response) {}

std::string TestDownloadHttpResponse::GetCommonEntityHeaders() {}

std::string TestDownloadHttpResponse::GetResponseChunk(
    const net::HttpByteRange& buffer_range) {}

bool TestDownloadHttpResponse::ShouldAbortImmediately() const {}

bool TestDownloadHttpResponse::ShouldPauseImmediately() const {}

bool TestDownloadHttpResponse::HandlePause(
    const net::HttpByteRange& buffer_range) {}

bool TestDownloadHttpResponse::HandleInjectedError(
    const net::HttpByteRange& buffer_range) {}

bool TestDownloadHttpResponse::ShouldPause(
    const net::HttpByteRange& buffer_range) const {}

void TestDownloadHttpResponse::PauseResponsesAndWaitForResumption() {}

void TestDownloadHttpResponse::SendResponseBodyChunk() {}

void TestDownloadHttpResponse::SendBodyChunkInternal(
    const net::HttpByteRange& buffer_range,
    base::OnceClosure next) {}

base::OnceClosure TestDownloadHttpResponse::SendNextBodyChunkClosure() {}

void TestDownloadHttpResponse::SendDelayedResponse() {}

void TestDownloadHttpResponse::GenerateResult() {}

base::OnceClosure TestDownloadHttpResponse::GenerateResultClosure() {}

std::unique_ptr<net::test_server::HttpResponse>
TestDownloadResponseHandler::HandleTestDownloadRequest(
    TestDownloadHttpResponse::OnResponseSentCallback callback,
    const net::test_server::HttpRequest& request) {}

TestDownloadResponseHandler::TestDownloadResponseHandler() = default;

TestDownloadResponseHandler::~TestDownloadResponseHandler() {}

void TestDownloadResponseHandler::RegisterToTestServer(
    net::test_server::EmbeddedTestServer* server) {}

void TestDownloadResponseHandler::OnRequestCompleted(
    std::unique_ptr<TestDownloadHttpResponse::CompletedRequest> request) {}

void TestDownloadResponseHandler::WaitUntilCompletion(size_t request_count) {}

void TestDownloadResponseHandler::DispatchDelayedResponses() {}

}  // namespace content