#include "net/shared_dictionary/shared_dictionary_header_checker_source_stream.h"
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "net/base/hash_value.h"
#include "net/base/io_buffer.h"
namespace net {
namespace {
static constexpr unsigned char kCompressionTypeBrotliSignature[] = …;
static constexpr unsigned char kCompressionTypeZstdSignature[] = …;
static constexpr size_t kCompressionTypeBrotliSignatureSize = …;
static constexpr size_t kCompressionTypeZstdSignatureSize = …;
static constexpr int kCompressionDictionaryHashSize = …;
static_assert …;
static constexpr int kCompressionTypeBrotliHeaderSize = …;
static constexpr int kCompressionTypeZstdHeaderSize = …;
size_t GetSignatureSize(SharedDictionaryHeaderCheckerSourceStream::Type type) { … }
size_t GetHeaderSize(SharedDictionaryHeaderCheckerSourceStream::Type type) { … }
base::span<const unsigned char> GetExpectedSignature(
SharedDictionaryHeaderCheckerSourceStream::Type type) { … }
}
SharedDictionaryHeaderCheckerSourceStream::
SharedDictionaryHeaderCheckerSourceStream(
std::unique_ptr<SourceStream> upstream,
Type type,
const SHA256HashValue& dictionary_hash)
: … { … }
SharedDictionaryHeaderCheckerSourceStream::
~SharedDictionaryHeaderCheckerSourceStream() = default;
int SharedDictionaryHeaderCheckerSourceStream::Read(
IOBuffer* dest_buffer,
int buffer_size,
CompletionOnceCallback callback) { … }
std::string SharedDictionaryHeaderCheckerSourceStream::Description() const { … }
bool SharedDictionaryHeaderCheckerSourceStream::MayHaveMoreBytes() const { … }
void SharedDictionaryHeaderCheckerSourceStream::ReadHeader() { … }
void SharedDictionaryHeaderCheckerSourceStream::OnReadCompleted(int result) { … }
bool SharedDictionaryHeaderCheckerSourceStream::CheckHeaderBuffer() const { … }
void SharedDictionaryHeaderCheckerSourceStream::HeaderCheckCompleted(
int header_check_result) { … }
base::span<const unsigned char>
SharedDictionaryHeaderCheckerSourceStream::GetSignatureInBuffer() const { … }
base::span<const unsigned char>
SharedDictionaryHeaderCheckerSourceStream::GetHashInBuffer() const { … }
}