#include "net/shared_dictionary/shared_dictionary_network_transaction.h"
#include <optional>
#include <string>
#include <string_view>
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/types/expected.h"
#include "net/base/completion_once_callback.h"
#include "net/base/features.h"
#include "net/base/hash_value.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/transport_info.h"
#include "net/base/url_util.h"
#include "net/cert/x509_certificate.h"
#include "net/filter/brotli_source_stream.h"
#include "net/filter/filter_source_stream.h"
#include "net/filter/source_stream.h"
#include "net/filter/zstd_source_stream.h"
#include "net/http/http_request_info.h"
#include "net/http/structured_headers.h"
#include "net/shared_dictionary/shared_dictionary_constants.h"
#include "net/shared_dictionary/shared_dictionary_header_checker_source_stream.h"
#include "net/shared_dictionary/shared_dictionary_isolation_key.h"
#include "net/ssl/ssl_private_key.h"
namespace net {
namespace {
class ProxyingSourceStream : public SourceStream { … };
void AddAcceptEncoding(HttpRequestHeaders* request_headers,
std::string_view encoding_header) { … }
}
SharedDictionaryNetworkTransaction::PendingReadTask::PendingReadTask(
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback)
: … { … }
SharedDictionaryNetworkTransaction::PendingReadTask::~PendingReadTask() =
default;
SharedDictionaryNetworkTransaction::SharedDictionaryNetworkTransaction(
std::unique_ptr<HttpTransaction> network_transaction,
bool enable_shared_zstd)
: … { … }
SharedDictionaryNetworkTransaction::~SharedDictionaryNetworkTransaction() =
default;
int SharedDictionaryNetworkTransaction::Start(const HttpRequestInfo* request,
CompletionOnceCallback callback,
const NetLogWithSource& net_log) { … }
SharedDictionaryNetworkTransaction::SharedDictionaryEncodingType
SharedDictionaryNetworkTransaction::ParseSharedDictionaryEncodingType(
const HttpResponseHeaders& headers) { … }
void SharedDictionaryNetworkTransaction::OnStartCompleted(
CompletionOnceCallback callback,
int result) { … }
void SharedDictionaryNetworkTransaction::ModifyRequestHeaders(
const GURL& request_url,
HttpRequestHeaders* request_headers) { … }
void SharedDictionaryNetworkTransaction::OnReadSharedDictionary(
base::Time read_start_time,
int result) { … }
int SharedDictionaryNetworkTransaction::RestartIgnoringLastError(
CompletionOnceCallback callback) { … }
int SharedDictionaryNetworkTransaction::RestartWithCertificate(
scoped_refptr<X509Certificate> client_cert,
scoped_refptr<SSLPrivateKey> client_private_key,
CompletionOnceCallback callback) { … }
int SharedDictionaryNetworkTransaction::RestartWithAuth(
const AuthCredentials& credentials,
CompletionOnceCallback callback) { … }
bool SharedDictionaryNetworkTransaction::IsReadyToRestartForAuth() { … }
int SharedDictionaryNetworkTransaction::Read(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
void SharedDictionaryNetworkTransaction::StopCaching() { … }
int64_t SharedDictionaryNetworkTransaction::GetTotalReceivedBytes() const { … }
int64_t SharedDictionaryNetworkTransaction::GetTotalSentBytes() const { … }
int64_t SharedDictionaryNetworkTransaction::GetReceivedBodyBytes() const { … }
void SharedDictionaryNetworkTransaction::DoneReading() { … }
const HttpResponseInfo* SharedDictionaryNetworkTransaction::GetResponseInfo()
const { … }
LoadState SharedDictionaryNetworkTransaction::GetLoadState() const { … }
void SharedDictionaryNetworkTransaction::SetQuicServerInfo(
QuicServerInfo* quic_server_info) { … }
bool SharedDictionaryNetworkTransaction::GetLoadTimingInfo(
LoadTimingInfo* load_timing_info) const { … }
bool SharedDictionaryNetworkTransaction::GetRemoteEndpoint(
IPEndPoint* endpoint) const { … }
void SharedDictionaryNetworkTransaction::PopulateNetErrorDetails(
NetErrorDetails* details) const { … }
void SharedDictionaryNetworkTransaction::SetPriority(RequestPriority priority) { … }
void SharedDictionaryNetworkTransaction::
SetWebSocketHandshakeStreamCreateHelper(
WebSocketHandshakeStreamBase::CreateHelper* create_helper) { … }
void SharedDictionaryNetworkTransaction::SetBeforeNetworkStartCallback(
BeforeNetworkStartCallback callback) { … }
void SharedDictionaryNetworkTransaction::SetRequestHeadersCallback(
RequestHeadersCallback callback) { … }
void SharedDictionaryNetworkTransaction::SetResponseHeadersCallback(
ResponseHeadersCallback callback) { … }
void SharedDictionaryNetworkTransaction::SetEarlyResponseHeadersCallback(
ResponseHeadersCallback callback) { … }
void SharedDictionaryNetworkTransaction::SetConnectedCallback(
const ConnectedCallback& callback) { … }
int SharedDictionaryNetworkTransaction::ResumeNetworkStart() { … }
void SharedDictionaryNetworkTransaction::SetModifyRequestHeadersCallback(
base::RepeatingCallback<void(HttpRequestHeaders*)> callback) { … }
void SharedDictionaryNetworkTransaction::
SetIsSharedDictionaryReadAllowedCallback(
base::RepeatingCallback<bool()> callback) { … }
ConnectionAttempts SharedDictionaryNetworkTransaction::GetConnectionAttempts()
const { … }
void SharedDictionaryNetworkTransaction::CloseConnectionOnDestruction() { … }
bool SharedDictionaryNetworkTransaction::IsMdlMatchForMetrics() const { … }
int SharedDictionaryNetworkTransaction::OnConnected(
const TransportInfo& info,
CompletionOnceCallback callback) { … }
}