#include "chrome/browser/safe_browsing/cloud_content_scanning/connector_data_pipe_getter.h"
#include <algorithm>
#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "base/files/memory_mapped_file.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/metrics/histogram_functions.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "mojo/public/c/system/data_pipe.h"
#include "net/base/net_errors.h"
#if BUILDFLAG(IS_POSIX)
#include <sys/mman.h>
#include "base/threading/scoped_blocking_call.h"
#endif
namespace safe_browsing {
namespace {
const char kDataContentType[] = …;
constexpr size_t kMaxSize = …;
}
#if BUILDFLAG(IS_POSIX)
bool ConnectorDataPipeGetter::InternalMemoryMappedFile::Initialize(
base::File file) { … }
bool ConnectorDataPipeGetter::InternalMemoryMappedFile::DoInitialize() { … }
void ConnectorDataPipeGetter::InternalMemoryMappedFile::CloseHandles() { … }
#endif
std::unique_ptr<ConnectorDataPipeGetter>
ConnectorDataPipeGetter::CreateMultipartPipeGetter(const std::string& boundary,
const std::string& metadata,
base::File file) { … }
std::unique_ptr<ConnectorDataPipeGetter>
ConnectorDataPipeGetter::CreateMultipartPipeGetter(
const std::string& boundary,
const std::string& metadata,
base::ReadOnlySharedMemoryRegion page) { … }
std::unique_ptr<ConnectorDataPipeGetter>
ConnectorDataPipeGetter::CreateResumablePipeGetter(base::File file) { … }
std::unique_ptr<ConnectorDataPipeGetter>
ConnectorDataPipeGetter::CreateResumablePipeGetter(
base::ReadOnlySharedMemoryRegion page) { … }
ConnectorDataPipeGetter::ConnectorDataPipeGetter(
const std::string& boundary,
const std::string& metadata,
std::unique_ptr<InternalMemoryMappedFile> file)
: … { … }
ConnectorDataPipeGetter::ConnectorDataPipeGetter(
const std::string& boundary,
const std::string& metadata,
base::ReadOnlySharedMemoryMapping page)
: … { … }
ConnectorDataPipeGetter::ConnectorDataPipeGetter(
const std::string& boundary,
const std::string& metadata,
std::unique_ptr<InternalMemoryMappedFile> file,
base::ReadOnlySharedMemoryMapping page)
: … { … }
ConnectorDataPipeGetter::~ConnectorDataPipeGetter() = default;
void ConnectorDataPipeGetter::Read(mojo::ScopedDataPipeProducerHandle pipe,
ReadCallback callback) { … }
void ConnectorDataPipeGetter::Clone(
mojo::PendingReceiver<network::mojom::DataPipeGetter> receiver) { … }
void ConnectorDataPipeGetter::Reset() { … }
std::unique_ptr<ConnectorDataPipeGetter::InternalMemoryMappedFile>
ConnectorDataPipeGetter::ReleaseFile() { … }
void ConnectorDataPipeGetter::MojoReadyCallback(
MojoResult result,
const mojo::HandleSignalsState& state) { … }
void ConnectorDataPipeGetter::Write() { … }
inline void ConnectorDataPipeGetter::PrepareMultipartRequestFormat(
const std::string& boundary,
const std::string& metadata) { … }
bool ConnectorDataPipeGetter::WriteMultipartRequestFormat(
const std::string& str,
int64_t offset) { … }
bool ConnectorDataPipeGetter::WriteFileData() { … }
bool ConnectorDataPipeGetter::WritePageData() { … }
bool ConnectorDataPipeGetter::Write(base::span<const uint8_t> data) { … }
bool ConnectorDataPipeGetter::IsWritePositionInRange(int64_t range_start,
int64_t range_end) { … }
int64_t ConnectorDataPipeGetter::FullSize() { … }
bool ConnectorDataPipeGetter::is_file_data_pipe() const { … }
bool ConnectorDataPipeGetter::is_page_data_pipe() const { … }
}