chromium/pdf/loader/document_loader_impl.cc

// Copyright 2010 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if defined(UNSAFE_BUFFERS_BUILD)
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "pdf/loader/document_loader_impl.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <utility>

#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_util.h"
#include "pdf/loader/result_codes.h"
#include "pdf/loader/url_loader_wrapper.h"
#include "pdf/pdf_features.h"
#include "ui/gfx/range/range.h"

namespace chrome_pdf {

namespace {

// The distance from last received chunk, when we wait requesting data, using
// current connection (like playing a cassette tape) and do not send new range
// request (like rewind a cassette tape, and continue playing after).
// Experimentally chosen value.
constexpr int kChunkCloseDistance =;

constexpr size_t kReadBufferSize =;

// Return true if the HTTP response of `loader` is a successful one and loading
// should continue. 4xx error indicate subsequent requests will fail too.
// e.g. resource has been removed from the server while loading it. 301
// indicates a redirect was returned which won't be successful because we
// disable following redirects for PDF loading (we assume they are already
// resolved by the browser.
bool ResponseStatusSuccess(const URLLoaderWrapper* loader) {}

bool IsValidContentType(const std::string& type) {}

}  // namespace

DocumentLoaderImpl::Chunk::Chunk() = default;

DocumentLoaderImpl::Chunk::~Chunk() = default;

void DocumentLoaderImpl::Chunk::Clear() {}

DocumentLoaderImpl::DocumentLoaderImpl(Client* client)
    :{}

DocumentLoaderImpl::~DocumentLoaderImpl() = default;

bool DocumentLoaderImpl::Init(std::unique_ptr<URLLoaderWrapper> loader,
                              const std::string& url) {}

bool DocumentLoaderImpl::IsDocumentComplete() const {}

uint32_t DocumentLoaderImpl::GetDocumentSize() const {}

uint32_t DocumentLoaderImpl::BytesReceived() const {}

void DocumentLoaderImpl::ClearPendingRequests() {}

bool DocumentLoaderImpl::GetBlock(uint32_t position,
                                  uint32_t size,
                                  void* buf) const {}

bool DocumentLoaderImpl::IsDataAvailable(uint32_t position,
                                         uint32_t size) const {}

void DocumentLoaderImpl::RequestData(uint32_t position, uint32_t size) {}

void DocumentLoaderImpl::SetPartialLoadingEnabled(bool enabled) {}

bool DocumentLoaderImpl::ShouldCancelLoading() const {}

void DocumentLoaderImpl::ContinueDownload() {}

void DocumentLoaderImpl::DidOpenPartial(int32_t result) {}

void DocumentLoaderImpl::ReadMore() {}

void DocumentLoaderImpl::DidRead(int32_t result) {}

bool DocumentLoaderImpl::SaveBuffer(uint32_t input_size) {}

void DocumentLoaderImpl::SaveChunkData() {}

uint32_t DocumentLoaderImpl::EndOfCurrentChunk() const {}

void DocumentLoaderImpl::ReadComplete() {}

}  // namespace chrome_pdf