Decouple SourceType enum from net::SourceStream class
This CL extracts the SourceStream::SourceType enum into a new SourceStreamType enum class, defined in source_stream_type.h. This change addresses the issue where users needing the SourceType enum were forced to include source_stream.h, even if they had no other dependencies on the SourceStream class. By creating a dedicated header for SourceStreamType, we improve modularity and reduce unnecessary header dependencies. This CL must not have any behavioral changes. NO_IFTTT=New LINT.If/ThenChange() Bug: 391950057 Change-Id: Ia25db924a0e7a8d1b379dd1042ede0e898cd6dd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6278220 Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Reviewed-by: John Lee <johntlee@chromium.org> Reviewed-by: Dominic Battré <battre@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Gauthier Ambard <gambard@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Benjamin Gordon <bmgordon@chromium.org> Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Cr-Commit-Position: refs/heads/main@{#1422841}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
9b315d56e2
commit
17846bf5d9
chromeos/printing
content
browser
cache_storage
devtools
loader
renderer_host
webui
public
extensions/browser/api/web_request
ios/web/webui
net
BUILD.gn
filter
brotli_source_stream.ccfilter_source_stream.ccfilter_source_stream.hfilter_source_stream_unittest.ccfuzzed_source_stream.ccgzip_source_stream.ccgzip_source_stream.hgzip_source_stream_fuzzer.ccgzip_source_stream_unittest.ccmock_source_stream.ccsource_stream.ccsource_stream.hsource_stream_type.hzstd_source_stream.cc
http
shared_dictionary
test
url_request
tools
content_decoder_tool
url_request
services/network
prefetch_matches.ccurl_loader.ccurl_loader.h
public
cpp
data_pipe_to_source_stream.ccresource_request.hsource_stream_to_data_pipe_unittest.ccsource_type_mojom_traits.ccsource_type_mojom_traits.hurl_request_mojom_traits.hurl_request_mojom_traits_unittest.cc
mojom
third_party/blink
renderer
core
inspector
platform
loader
fetch
tools
blinkpy
presubmit
ui/base/webui
@ -22,6 +22,7 @@
|
||||
#include "net/filter/gzip_header.h"
|
||||
#include "net/filter/gzip_source_stream.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace chromeos {
|
||||
namespace {
|
||||
@ -40,7 +41,7 @@ bool IsNewline(char c) {
|
||||
class StringSourceStream : public net::SourceStream {
|
||||
public:
|
||||
explicit StringSourceStream(const std::string& src)
|
||||
: SourceStream(TYPE_UNKNOWN), src_(src) {}
|
||||
: SourceStream(net::SourceStreamType::kUnknown), src_(src) {}
|
||||
|
||||
// This source always reads sychronously, so never uses the callback.
|
||||
int Read(net::IOBuffer* dest_buffer,
|
||||
@ -73,7 +74,7 @@ class PpdLineReaderImpl : public PpdLineReader {
|
||||
input_ = std::make_unique<StringSourceStream>(ppd_contents);
|
||||
if (net::GZipHeader::HasGZipHeader(base::as_byte_span(ppd_contents))) {
|
||||
input_ = net::GzipSourceStream::Create(std::move(input_),
|
||||
net::SourceStream::TYPE_GZIP);
|
||||
net::SourceStreamType::kGzip);
|
||||
}
|
||||
}
|
||||
~PpdLineReaderImpl() override = default;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "services/network/public/cpp/source_stream_to_data_pipe.h"
|
||||
#include "storage/browser/blob/blob_data_builder.h"
|
||||
#include "storage/browser/blob/blob_impl.h"
|
||||
@ -35,7 +36,7 @@ class DiskCacheStream : public net::SourceStream {
|
||||
CacheStorageCache::EntryIndex cache_index,
|
||||
uint64_t offset,
|
||||
uint64_t length)
|
||||
: SourceStream(net::SourceStream::SourceType::TYPE_NONE),
|
||||
: SourceStream(net::SourceStreamType::kNone),
|
||||
blob_entry_(blob_entry),
|
||||
cache_index_(cache_index),
|
||||
orig_offset_(offset),
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "net/cookies/cookie_inclusion_status.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/quic/web_transport_error.h"
|
||||
#include "net/ssl/ssl_info.h"
|
||||
@ -1310,7 +1311,7 @@ void ApplyNetworkRequestOverrides(
|
||||
bool* disable_cache,
|
||||
bool* network_instrumentation_enabled,
|
||||
bool* skip_service_worker,
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>*
|
||||
std::optional<std::vector<net::SourceStreamType>>*
|
||||
devtools_accepted_stream_types,
|
||||
bool* devtools_user_agent_overridden,
|
||||
bool* devtools_accept_language_overridden) {
|
||||
@ -1364,7 +1365,7 @@ void ApplyNetworkRequestOverrides(
|
||||
FrameTreeNode* frame_tree_node,
|
||||
blink::mojom::BeginNavigationParams* begin_params,
|
||||
bool* report_raw_headers,
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>*
|
||||
std::optional<std::vector<net::SourceStreamType>>*
|
||||
devtools_accepted_stream_types,
|
||||
bool* devtools_user_agent_overridden,
|
||||
bool* devtools_accept_language_overridden) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "content/public/browser/global_routing_id.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "net/cookies/cookie_setting_override.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "services/network/public/cpp/url_loader_completion_status.h"
|
||||
#include "services/network/public/mojom/url_loader_factory.mojom.h"
|
||||
#include "services/network/public/mojom/url_response_head.mojom-forward.h"
|
||||
@ -103,7 +103,7 @@ void ApplyNetworkRequestOverrides(
|
||||
FrameTreeNode* frame_tree_node,
|
||||
blink::mojom::BeginNavigationParams* begin_params,
|
||||
bool* report_raw_headers,
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>*
|
||||
std::optional<std::vector<net::SourceStreamType>>*
|
||||
devtools_accepted_stream_types,
|
||||
bool* devtools_user_agent_overridden,
|
||||
bool* devtools_accept_language_overridden);
|
||||
|
@ -80,6 +80,7 @@
|
||||
#include "net/cookies/cookie_partition_key.h"
|
||||
#include "net/cookies/cookie_setting_override.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/http/http_util.h"
|
||||
@ -1118,18 +1119,18 @@ BuildProtocolAssociatedCookies(const net::CookieAccessResultList& net_list) {
|
||||
return protocol_list;
|
||||
}
|
||||
|
||||
using SourceTypeEnum = net::SourceStream::SourceType;
|
||||
using SourceTypeEnum = net::SourceStreamType;
|
||||
namespace ContentEncodingEnum = protocol::Network::ContentEncodingEnum;
|
||||
std::optional<SourceTypeEnum> SourceTypeFromProtocol(
|
||||
const protocol::Network::ContentEncoding& encoding) {
|
||||
if (ContentEncodingEnum::Gzip == encoding)
|
||||
return SourceTypeEnum::TYPE_GZIP;
|
||||
return SourceTypeEnum::kGzip;
|
||||
if (ContentEncodingEnum::Br == encoding)
|
||||
return SourceTypeEnum::TYPE_BROTLI;
|
||||
return SourceTypeEnum::kBrotli;
|
||||
if (ContentEncodingEnum::Deflate == encoding)
|
||||
return SourceTypeEnum::TYPE_DEFLATE;
|
||||
return SourceTypeEnum::kDeflate;
|
||||
if (ContentEncodingEnum::Zstd == encoding) {
|
||||
return SourceTypeEnum::TYPE_ZSTD;
|
||||
return SourceTypeEnum::kZstd;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -1596,7 +1597,7 @@ Response NetworkHandler::SetCacheDisabled(bool cache_disabled) {
|
||||
|
||||
Response NetworkHandler::SetAcceptedEncodings(
|
||||
std::unique_ptr<Array<Network::ContentEncoding>> encodings) {
|
||||
std::set<net::SourceStream::SourceType> accepted_stream_types;
|
||||
std::set<net::SourceStreamType> accepted_stream_types;
|
||||
for (auto encoding : *encodings) {
|
||||
auto type = SourceTypeFromProtocol(encoding);
|
||||
if (!type)
|
||||
@ -3181,8 +3182,7 @@ void NetworkHandler::ApplyOverrides(
|
||||
net::HttpRequestHeaders* headers,
|
||||
bool* skip_service_worker,
|
||||
bool* disable_cache,
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>*
|
||||
accepted_stream_types) {
|
||||
std::optional<std::vector<net::SourceStreamType>>* accepted_stream_types) {
|
||||
for (auto& entry : extra_headers_)
|
||||
headers->SetHeader(entry.first, entry.second);
|
||||
*skip_service_worker |= bypass_service_worker_;
|
||||
@ -3190,7 +3190,7 @@ void NetworkHandler::ApplyOverrides(
|
||||
if (!accepted_stream_types_)
|
||||
return;
|
||||
if (!*accepted_stream_types)
|
||||
*accepted_stream_types = std::vector<net::SourceStream::SourceType>();
|
||||
*accepted_stream_types = std::vector<net::SourceStreamType>();
|
||||
(*accepted_stream_types)
|
||||
->insert((*accepted_stream_types)->end(), accepted_stream_types_->begin(),
|
||||
accepted_stream_types_->end());
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "net/cookies/cookie_setting_override.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/net_buildflags.h"
|
||||
#include "services/network/public/mojom/devtools_observer.mojom-forward.h"
|
||||
#include "services/network/public/mojom/http_raw_headers.mojom-forward.h"
|
||||
@ -216,11 +216,11 @@ class NetworkHandler : public DevToolsDomainHandler,
|
||||
bool is_download,
|
||||
network::mojom::URLLoaderFactoryOverride* intercepting_factory);
|
||||
|
||||
void ApplyOverrides(net::HttpRequestHeaders* headers,
|
||||
bool* skip_service_worker,
|
||||
bool* disable_cache,
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>*
|
||||
accepted_stream_types);
|
||||
void ApplyOverrides(
|
||||
net::HttpRequestHeaders* headers,
|
||||
bool* skip_service_worker,
|
||||
bool* disable_cache,
|
||||
std::optional<std::vector<net::SourceStreamType>>* accepted_stream_types);
|
||||
void ApplyCookieControlsOverrides(net::CookieSettingOverrides& overrides);
|
||||
void PrefetchRequestWillBeSent(
|
||||
const std::string& request_id,
|
||||
@ -406,7 +406,7 @@ class NetworkHandler : public DevToolsDomainHandler,
|
||||
std::unique_ptr<LoadNetworkResourceCallback>,
|
||||
base::UniquePtrComparator>
|
||||
loaders_;
|
||||
std::optional<std::set<net::SourceStream::SourceType>> accepted_stream_types_;
|
||||
std::optional<std::set<net::SourceStreamType>> accepted_stream_types_;
|
||||
std::unordered_map<String, std::pair<String, bool>> received_body_data_;
|
||||
base::WeakPtrFactory<NetworkHandler> weak_factory_{this};
|
||||
};
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
@ -47,7 +48,8 @@ MerkleIntegritySourceStream::MerkleIntegritySourceStream(
|
||||
std::string_view digest_header_value,
|
||||
std::unique_ptr<SourceStream> upstream)
|
||||
// TODO(ksakamoto): Use appropriate SourceType.
|
||||
: net::FilterSourceStream(SourceStream::TYPE_NONE, std::move(upstream)) {
|
||||
: net::FilterSourceStream(net::SourceStreamType::kNone,
|
||||
std::move(upstream)) {
|
||||
std::string next_proof;
|
||||
if (!base::StartsWith(digest_header_value, kMiSha256Header) ||
|
||||
!base::Base64Decode(digest_header_value.substr(kMiSha256HeaderLength),
|
||||
|
@ -146,6 +146,7 @@
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "net/base/url_util.h"
|
||||
#include "net/cookies/cookie_access_result.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/storage_access_api/status.h"
|
||||
@ -5330,7 +5331,7 @@ void NavigationRequest::OnStartChecksComplete(
|
||||
// Give DevTools a chance to override begin params (headers, skip SW)
|
||||
// before actually loading resource.
|
||||
bool report_raw_headers = false;
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>
|
||||
std::optional<std::vector<net::SourceStreamType>>
|
||||
devtools_accepted_stream_types;
|
||||
devtools_instrumentation::ApplyNetworkRequestOverrides(
|
||||
frame_tree_node_, begin_params_.get(), &report_raw_headers,
|
||||
|
@ -27,7 +27,7 @@ NavigationRequestInfo::NavigationRequestInfo(
|
||||
const base::UnguessableToken& devtools_frame_token,
|
||||
net::HttpRequestHeaders cors_exempt_headers,
|
||||
network::mojom::ClientSecurityStatePtr client_security_state,
|
||||
const std::optional<std::vector<net::SourceStream::SourceType>>&
|
||||
const std::optional<std::vector<net::SourceStreamType>>&
|
||||
devtools_accepted_stream_types,
|
||||
bool is_pdf,
|
||||
int initiator_process_id,
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "content/public/browser/weak_document_ptr.h"
|
||||
#include "content/public/common/referrer.h"
|
||||
#include "net/base/isolation_info.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
#include "services/network/public/mojom/client_security_state.mojom-forward.h"
|
||||
@ -49,7 +49,7 @@ struct CONTENT_EXPORT NavigationRequestInfo {
|
||||
const base::UnguessableToken& devtools_frame_token,
|
||||
net::HttpRequestHeaders cors_exempt_headers,
|
||||
network::mojom::ClientSecurityStatePtr client_security_state,
|
||||
const std::optional<std::vector<net::SourceStream::SourceType>>&
|
||||
const std::optional<std::vector<net::SourceStreamType>>&
|
||||
devtools_accepted_stream_types,
|
||||
bool is_pdf,
|
||||
int initiator_process_id,
|
||||
@ -136,7 +136,7 @@ struct CONTENT_EXPORT NavigationRequestInfo {
|
||||
// If not null, the network service will not advertise any stream types
|
||||
// (via Accept-Encoding) that are not listed. Also, it will not attempt
|
||||
// decoding any non-listed stream types.
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>
|
||||
std::optional<std::vector<net::SourceStreamType>>
|
||||
devtools_accepted_stream_types;
|
||||
|
||||
// Indicates that this navigation is for PDF content in a renderer.
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/log/net_log_util.h"
|
||||
|
@ -111,6 +111,7 @@
|
||||
#include "net/filter/gzip_header.h"
|
||||
#include "net/filter/gzip_source_stream.h"
|
||||
#include "net/filter/mock_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/test/embedded_test_server/embedded_test_server.h"
|
||||
#include "net/test/embedded_test_server/http_request.h"
|
||||
#include "net/test/embedded_test_server/http_response.h"
|
||||
@ -439,7 +440,7 @@ void AppendGzippedResource(const base::RefCountedMemory& encoded,
|
||||
source_stream->AddReadResult(end.data(), end.size(), net::OK,
|
||||
net::MockSourceStream::SYNC);
|
||||
std::unique_ptr<net::GzipSourceStream> filter = net::GzipSourceStream::Create(
|
||||
std::move(source_stream), net::SourceStream::TYPE_GZIP);
|
||||
std::move(source_stream), net::SourceStreamType::kGzip);
|
||||
scoped_refptr<net::IOBufferWithSize> dest_buffer =
|
||||
base::MakeRefCounted<net::IOBufferWithSize>(4096);
|
||||
while (true) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "extensions/browser/extension_event_histogram_value.h"
|
||||
#include "extensions/common/extension_id.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "net/base/completion_once_callback.h"
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#import "net/base/io_buffer.h"
|
||||
#import "net/base/net_errors.h"
|
||||
#import "net/filter/source_stream.h"
|
||||
#import "net/filter/source_stream_type.h"
|
||||
#import "net/http/http_response_headers.h"
|
||||
#import "net/http/http_status_code.h"
|
||||
#import "net/url_request/url_request.h"
|
||||
@ -325,7 +326,7 @@ std::unique_ptr<net::SourceStream> URLRequestChromeJob::SetUpSourceStream() {
|
||||
// which we keep alive via `source_`, ensuring its lifetime is also bound
|
||||
// to the safe URLRequest.
|
||||
source_stream = ui::I18nSourceStream::Create(
|
||||
std::move(source_stream), net::SourceStream::TYPE_NONE, replacements);
|
||||
std::move(source_stream), net::SourceStreamType::kNone, replacements);
|
||||
}
|
||||
|
||||
return source_stream;
|
||||
|
@ -529,6 +529,7 @@ component("net") {
|
||||
"filter/gzip_source_stream.h",
|
||||
"filter/source_stream.cc",
|
||||
"filter/source_stream.h",
|
||||
"filter/source_stream_type.h",
|
||||
"first_party_sets/addition_overlaps_union_find.cc",
|
||||
"first_party_sets/addition_overlaps_union_find.h",
|
||||
"first_party_sets/first_party_set_entry.cc",
|
||||
|
@ -7,15 +7,16 @@
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "net/filter/brotli_source_stream.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "third_party/brotli/include/brotli/decode.h"
|
||||
#include "third_party/brotli/include/brotli/shared_dictionary.h"
|
||||
|
||||
@ -32,7 +33,7 @@ class BrotliSourceStream : public FilterSourceStream {
|
||||
explicit BrotliSourceStream(std::unique_ptr<SourceStream> upstream,
|
||||
scoped_refptr<IOBuffer> dictionary = nullptr,
|
||||
size_t dictionary_size = 0u)
|
||||
: FilterSourceStream(SourceStream::TYPE_BROTLI, std::move(upstream)),
|
||||
: FilterSourceStream(SourceStreamType::kBrotli, std::move(upstream)),
|
||||
dictionary_(std::move(dictionary)),
|
||||
dictionary_size_(dictionary_size) {
|
||||
brotli_state_ =
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/base/trace_constants.h"
|
||||
#include "net/base/tracing.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
@ -33,7 +34,7 @@ const size_t kBufferSize = 32 * 1024;
|
||||
|
||||
} // namespace
|
||||
|
||||
FilterSourceStream::FilterSourceStream(SourceType type,
|
||||
FilterSourceStream::FilterSourceStream(SourceStreamType type,
|
||||
std::unique_ptr<SourceStream> upstream)
|
||||
: SourceStream(type), upstream_(std::move(upstream)) {
|
||||
DCHECK(upstream_);
|
||||
@ -79,21 +80,21 @@ bool FilterSourceStream::MayHaveMoreBytes() const {
|
||||
return !upstream_end_reached_;
|
||||
}
|
||||
|
||||
FilterSourceStream::SourceType FilterSourceStream::ParseEncodingType(
|
||||
SourceStreamType FilterSourceStream::ParseEncodingType(
|
||||
std::string_view encoding) {
|
||||
std::string lower_encoding = base::ToLowerASCII(encoding);
|
||||
static constexpr auto kEncodingMap =
|
||||
base::MakeFixedFlatMap<std::string_view, SourceType>({
|
||||
{"", TYPE_NONE},
|
||||
{kBrotli, TYPE_BROTLI},
|
||||
{kDeflate, TYPE_DEFLATE},
|
||||
{kGZip, TYPE_GZIP},
|
||||
{kXGZip, TYPE_GZIP},
|
||||
{kZstd, TYPE_ZSTD},
|
||||
base::MakeFixedFlatMap<std::string_view, SourceStreamType>({
|
||||
{"", SourceStreamType::kNone},
|
||||
{kBrotli, SourceStreamType::kBrotli},
|
||||
{kDeflate, SourceStreamType::kDeflate},
|
||||
{kGZip, SourceStreamType::kGzip},
|
||||
{kXGZip, SourceStreamType::kGzip},
|
||||
{kZstd, SourceStreamType::kZstd},
|
||||
});
|
||||
auto encoding_type = kEncodingMap.find(lower_encoding);
|
||||
if (encoding_type == kEncodingMap.end()) {
|
||||
return TYPE_UNKNOWN;
|
||||
return SourceStreamType::kUnknown;
|
||||
}
|
||||
return encoding_type->second;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
@ -29,7 +30,8 @@ class NET_EXPORT_PRIVATE FilterSourceStream : public SourceStream {
|
||||
public:
|
||||
// |upstream| is the SourceStream from which |this| will read data.
|
||||
// |upstream| cannot be null.
|
||||
FilterSourceStream(SourceType type, std::unique_ptr<SourceStream> upstream);
|
||||
FilterSourceStream(SourceStreamType type,
|
||||
std::unique_ptr<SourceStream> upstream);
|
||||
|
||||
FilterSourceStream(const FilterSourceStream&) = delete;
|
||||
FilterSourceStream& operator=(const FilterSourceStream&) = delete;
|
||||
@ -43,7 +45,7 @@ class NET_EXPORT_PRIVATE FilterSourceStream : public SourceStream {
|
||||
std::string Description() const override;
|
||||
bool MayHaveMoreBytes() const override;
|
||||
|
||||
static SourceType ParseEncodingType(std::string_view encoding);
|
||||
static SourceStreamType ParseEncodingType(std::string_view encoding);
|
||||
|
||||
private:
|
||||
enum State {
|
||||
|
@ -7,6 +7,8 @@
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
@ -17,8 +19,8 @@
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/base/test_completion_callback.h"
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
#include "net/filter/mock_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace net {
|
||||
@ -31,7 +33,7 @@ const size_t kSmallBufferSize = 1;
|
||||
class TestFilterSourceStreamBase : public FilterSourceStream {
|
||||
public:
|
||||
explicit TestFilterSourceStreamBase(std::unique_ptr<SourceStream> upstream)
|
||||
: FilterSourceStream(SourceStream::TYPE_NONE, std::move(upstream)) {}
|
||||
: FilterSourceStream(SourceStreamType::kNone, std::move(upstream)) {}
|
||||
|
||||
TestFilterSourceStreamBase(const TestFilterSourceStreamBase&) = delete;
|
||||
TestFilterSourceStreamBase& operator=(const TestFilterSourceStreamBase&) =
|
||||
@ -217,7 +219,7 @@ class NoOutputSourceStream : public TestFilterSourceStreamBase {
|
||||
class ErrorFilterSourceStream : public FilterSourceStream {
|
||||
public:
|
||||
explicit ErrorFilterSourceStream(std::unique_ptr<SourceStream> upstream)
|
||||
: FilterSourceStream(SourceStream::TYPE_NONE, std::move(upstream)) {}
|
||||
: FilterSourceStream(SourceStreamType::kNone, std::move(upstream)) {}
|
||||
|
||||
ErrorFilterSourceStream(const ErrorFilterSourceStream&) = delete;
|
||||
ErrorFilterSourceStream& operator=(const ErrorFilterSourceStream&) = delete;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
@ -30,7 +31,7 @@ const Error kReadErrors[] = {OK, ERR_FAILED, ERR_CONTENT_DECODING_FAILED};
|
||||
} // namespace
|
||||
|
||||
FuzzedSourceStream::FuzzedSourceStream(FuzzedDataProvider* data_provider)
|
||||
: SourceStream(SourceStream::TYPE_NONE), data_provider_(data_provider) {}
|
||||
: SourceStream(SourceStreamType::kNone), data_provider_(data_provider) {}
|
||||
|
||||
FuzzedSourceStream::~FuzzedSourceStream() {
|
||||
DCHECK(!read_pending_);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "base/notreached.h"
|
||||
#include "base/numerics/checked_math.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
||||
namespace net {
|
||||
@ -47,8 +48,8 @@ GzipSourceStream::~GzipSourceStream() {
|
||||
|
||||
std::unique_ptr<GzipSourceStream> GzipSourceStream::Create(
|
||||
std::unique_ptr<SourceStream> upstream,
|
||||
SourceStream::SourceType type) {
|
||||
DCHECK(type == TYPE_GZIP || type == TYPE_DEFLATE);
|
||||
SourceStreamType type) {
|
||||
DCHECK(type == SourceStreamType::kGzip || type == SourceStreamType::kDeflate);
|
||||
auto source =
|
||||
base::WrapUnique(new GzipSourceStream(std::move(upstream), type));
|
||||
|
||||
@ -58,7 +59,7 @@ std::unique_ptr<GzipSourceStream> GzipSourceStream::Create(
|
||||
}
|
||||
|
||||
GzipSourceStream::GzipSourceStream(std::unique_ptr<SourceStream> upstream,
|
||||
SourceStream::SourceType type)
|
||||
SourceStreamType type)
|
||||
: FilterSourceStream(type, std::move(upstream)) {}
|
||||
|
||||
bool GzipSourceStream::Init() {
|
||||
@ -68,7 +69,7 @@ bool GzipSourceStream::Init() {
|
||||
memset(zlib_stream_.get(), 0, sizeof(z_stream));
|
||||
|
||||
int ret;
|
||||
if (type() == TYPE_GZIP) {
|
||||
if (type() == SourceStreamType::kGzip) {
|
||||
ret = inflateInit2(zlib_stream_.get(), -MAX_WBITS);
|
||||
} else {
|
||||
ret = inflateInit(zlib_stream_.get());
|
||||
@ -79,9 +80,9 @@ bool GzipSourceStream::Init() {
|
||||
|
||||
std::string GzipSourceStream::GetTypeAsString() const {
|
||||
switch (type()) {
|
||||
case TYPE_GZIP:
|
||||
case SourceStreamType::kGzip:
|
||||
return kGzip;
|
||||
case TYPE_DEFLATE:
|
||||
case SourceStreamType::kDeflate:
|
||||
return kDeflate;
|
||||
default:
|
||||
NOTREACHED();
|
||||
@ -104,7 +105,7 @@ base::expected<size_t, Error> GzipSourceStream::FilterData(
|
||||
InputState state = input_state_;
|
||||
switch (state) {
|
||||
case STATE_START: {
|
||||
if (type() == TYPE_DEFLATE) {
|
||||
if (type() == SourceStreamType::kDeflate) {
|
||||
input_state_ = STATE_SNIFFING_DEFLATE_HEADER;
|
||||
break;
|
||||
}
|
||||
@ -113,7 +114,7 @@ base::expected<size_t, Error> GzipSourceStream::FilterData(
|
||||
break;
|
||||
}
|
||||
case STATE_GZIP_HEADER: {
|
||||
DCHECK_NE(TYPE_DEFLATE, type());
|
||||
DCHECK_NE(SourceStreamType::kDeflate, type());
|
||||
|
||||
const size_t kGzipFooterBytes = 8;
|
||||
size_t header_end = 0u;
|
||||
@ -135,7 +136,7 @@ base::expected<size_t, Error> GzipSourceStream::FilterData(
|
||||
break;
|
||||
}
|
||||
case STATE_SNIFFING_DEFLATE_HEADER: {
|
||||
DCHECK_EQ(TYPE_DEFLATE, type());
|
||||
DCHECK_EQ(SourceStreamType::kDeflate, type());
|
||||
|
||||
zlib_stream_.get()->next_in = reinterpret_cast<Bytef*>(input_data);
|
||||
zlib_stream_.get()->avail_in = input_data_size;
|
||||
@ -181,7 +182,7 @@ base::expected<size_t, Error> GzipSourceStream::FilterData(
|
||||
break;
|
||||
}
|
||||
case STATE_REPLAY_DATA: {
|
||||
DCHECK_EQ(TYPE_DEFLATE, type());
|
||||
DCHECK_EQ(SourceStreamType::kDeflate, type());
|
||||
|
||||
if (replay_data_.empty()) {
|
||||
input_state_ = replay_state_;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
#include "net/filter/gzip_header.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
typedef struct z_stream_s z_stream;
|
||||
|
||||
@ -35,7 +36,7 @@ class NET_EXPORT_PRIVATE GzipSourceStream : public FilterSourceStream {
|
||||
// Creates a GzipSourceStream. Return nullptr if initialization fails.
|
||||
static std::unique_ptr<GzipSourceStream> Create(
|
||||
std::unique_ptr<SourceStream> previous,
|
||||
SourceStream::SourceType type);
|
||||
SourceStreamType type);
|
||||
|
||||
private:
|
||||
enum InputState {
|
||||
@ -66,7 +67,7 @@ class NET_EXPORT_PRIVATE GzipSourceStream : public FilterSourceStream {
|
||||
};
|
||||
|
||||
GzipSourceStream(std::unique_ptr<SourceStream> previous,
|
||||
SourceStream::SourceType type);
|
||||
SourceStreamType type);
|
||||
|
||||
// Returns true if initialization is successful, false otherwise.
|
||||
// For instance, this method returns false if there is not enough memory or
|
||||
@ -113,4 +114,4 @@ class NET_EXPORT_PRIVATE GzipSourceStream : public FilterSourceStream {
|
||||
|
||||
} // namespace net
|
||||
|
||||
#endif // NET_FILTER_GZIP_SOURCE_STREAM_H__
|
||||
#endif // NET_FILTER_GZIP_SOURCE_STREAM_H_
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/test_completion_callback.h"
|
||||
#include "net/filter/fuzzed_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
// Fuzzer for GzipSourceStream.
|
||||
//
|
||||
@ -28,10 +29,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// because lots of 1-byte chunks is also a problem.
|
||||
const size_t kMaxReads = 10 * 1024;
|
||||
|
||||
const net::SourceStream::SourceType kGzipTypes[] = {
|
||||
net::SourceStream::TYPE_GZIP, net::SourceStream::TYPE_DEFLATE};
|
||||
net::SourceStream::SourceType type =
|
||||
data_provider.PickValueInArray(kGzipTypes);
|
||||
const net::SourceStreamType kGzipTypes[] = {net::SourceStreamType::kGzip,
|
||||
net::SourceStreamType::kDeflate};
|
||||
net::SourceStreamType type = data_provider.PickValueInArray(kGzipTypes);
|
||||
std::unique_ptr<net::GzipSourceStream> gzip_stream =
|
||||
net::GzipSourceStream::Create(std::move(fuzzed_source_stream), type);
|
||||
size_t num_reads = 0;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "net/filter/filter_source_stream_test_util.h"
|
||||
#include "net/filter/gzip_header.h"
|
||||
#include "net/filter/mock_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
||||
@ -68,9 +69,9 @@ class GzipSourceStreamTest : public ::testing::TestWithParam<GzipTestParam> {
|
||||
// Helpful function to initialize the test fixture.|type| specifies which type
|
||||
// of GzipSourceStream to create. It must be one of TYPE_GZIP and
|
||||
// TYPE_DEFLATE.
|
||||
void Init(SourceStream::SourceType type) {
|
||||
EXPECT_TRUE(SourceStream::TYPE_GZIP == type ||
|
||||
SourceStream::TYPE_DEFLATE == type);
|
||||
void Init(SourceStreamType type) {
|
||||
EXPECT_TRUE(SourceStreamType::kGzip == type ||
|
||||
SourceStreamType::kDeflate == type);
|
||||
source_data_len_ = kBigBufferSize - kEOFMargin;
|
||||
|
||||
for (size_t i = 0; i < source_data_len_; i++)
|
||||
@ -78,7 +79,7 @@ class GzipSourceStreamTest : public ::testing::TestWithParam<GzipTestParam> {
|
||||
|
||||
encoded_data_len_ = kBigBufferSize;
|
||||
CompressGzip(source_data_, source_data_len_, encoded_data_,
|
||||
&encoded_data_len_, type != SourceStream::TYPE_DEFLATE);
|
||||
&encoded_data_len_, type != SourceStreamType::kDeflate);
|
||||
|
||||
output_buffer_ =
|
||||
base::MakeRefCounted<IOBufferWithSize>(output_buffer_size_);
|
||||
@ -186,7 +187,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
ReadResultType::ONE_BYTE_AT_A_TIME)));
|
||||
|
||||
TEST_P(GzipSourceStreamTest, EmptyStream) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
source()->AddReadResult(nullptr, 0, OK, GetParam().mode);
|
||||
TestCompletionCallback callback;
|
||||
std::string actual_output;
|
||||
@ -197,7 +198,7 @@ TEST_P(GzipSourceStreamTest, EmptyStream) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, DeflateOneBlock) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
source()->AddReadResult(encoded_data(), encoded_data_len(), OK,
|
||||
GetParam().mode);
|
||||
source()->AddReadResult(nullptr, 0, OK, GetParam().mode);
|
||||
@ -210,7 +211,7 @@ TEST_P(GzipSourceStreamTest, DeflateOneBlock) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, GzipOneBloc) {
|
||||
Init(SourceStream::TYPE_GZIP);
|
||||
Init(SourceStreamType::kGzip);
|
||||
source()->AddReadResult(encoded_data(), encoded_data_len(), OK,
|
||||
GetParam().mode);
|
||||
source()->AddReadResult(nullptr, 0, OK, GetParam().mode);
|
||||
@ -223,7 +224,7 @@ TEST_P(GzipSourceStreamTest, GzipOneBloc) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, DeflateTwoReads) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
source()->AddReadResult(encoded_data(), 10, OK, GetParam().mode);
|
||||
source()->AddReadResult(encoded_data() + 10, encoded_data_len() - 10, OK,
|
||||
GetParam().mode);
|
||||
@ -238,7 +239,7 @@ TEST_P(GzipSourceStreamTest, DeflateTwoReads) {
|
||||
// Check that any extra bytes after the end of the gzipped data are silently
|
||||
// ignored.
|
||||
TEST_P(GzipSourceStreamTest, IgnoreDataAfterEof) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
const char kExtraData[] = "Hello, World!";
|
||||
std::string encoded_data_with_trailing_data(encoded_data(),
|
||||
encoded_data_len());
|
||||
@ -258,7 +259,7 @@ TEST_P(GzipSourceStreamTest, IgnoreDataAfterEof) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, MissingZlibHeader) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
const size_t kZlibHeaderLen = 2;
|
||||
source()->AddReadResult(encoded_data() + kZlibHeaderLen,
|
||||
encoded_data_len() - kZlibHeaderLen, OK,
|
||||
@ -273,7 +274,7 @@ TEST_P(GzipSourceStreamTest, MissingZlibHeader) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, CorruptGzipHeader) {
|
||||
Init(SourceStream::TYPE_GZIP);
|
||||
Init(SourceStreamType::kGzip);
|
||||
encoded_data()[1] = 0;
|
||||
int read_len = encoded_data_len();
|
||||
// Needed to a avoid a DCHECK that all reads were consumed.
|
||||
@ -290,7 +291,7 @@ TEST_P(GzipSourceStreamTest, CorruptGzipHeader) {
|
||||
// This test checks that the gzip stream source works correctly on 'golden' data
|
||||
// as produced by gzip(1).
|
||||
TEST_P(GzipSourceStreamTest, GzipCorrectness) {
|
||||
Init(SourceStream::TYPE_GZIP);
|
||||
Init(SourceStreamType::kGzip);
|
||||
const char kDecompressedData[] = "Hello, World!";
|
||||
const unsigned char kGzipData[] = {
|
||||
// From:
|
||||
@ -313,7 +314,7 @@ TEST_P(GzipSourceStreamTest, GzipCorrectness) {
|
||||
// Same as GzipCorrectness except that last 8 bytes are removed to test that the
|
||||
// implementation can handle missing footer.
|
||||
TEST_P(GzipSourceStreamTest, GzipCorrectnessWithoutFooter) {
|
||||
Init(SourceStream::TYPE_GZIP);
|
||||
Init(SourceStreamType::kGzip);
|
||||
const char kDecompressedData[] = "Hello, World!";
|
||||
const unsigned char kGzipData[] = {
|
||||
// From:
|
||||
@ -337,7 +338,7 @@ TEST_P(GzipSourceStreamTest, GzipCorrectnessWithoutFooter) {
|
||||
// header and checksum. Tests the Z_STREAM_END case in
|
||||
// STATE_SNIFFING_DEFLATE_HEADER.
|
||||
TEST_P(GzipSourceStreamTest, DeflateWithAdler32) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
const char kDecompressedData[] = "Hello, World!";
|
||||
const unsigned char kGzipData[] = {0x78, 0x01, 0xf3, 0x48, 0xcd, 0xc9, 0xc9,
|
||||
0xd7, 0x51, 0x08, 0xcf, 0x2f, 0xca, 0x49,
|
||||
@ -354,7 +355,7 @@ TEST_P(GzipSourceStreamTest, DeflateWithAdler32) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, DeflateWithBadAdler32) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
const unsigned char kGzipData[] = {0x78, 0x01, 0xf3, 0x48, 0xcd, 0xc9, 0xc9,
|
||||
0xd7, 0x51, 0x08, 0xcf, 0x2f, 0xca, 0x49,
|
||||
0x51, 0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
@ -368,7 +369,7 @@ TEST_P(GzipSourceStreamTest, DeflateWithBadAdler32) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, DeflateWithoutHeaderWithAdler32) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
const char kDecompressedData[] = "Hello, World!";
|
||||
const unsigned char kGzipData[] = {0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51,
|
||||
0x08, 0xcf, 0x2f, 0xca, 0x49, 0x51, 0x04,
|
||||
@ -385,7 +386,7 @@ TEST_P(GzipSourceStreamTest, DeflateWithoutHeaderWithAdler32) {
|
||||
}
|
||||
|
||||
TEST_P(GzipSourceStreamTest, DeflateWithoutHeaderWithBadAdler32) {
|
||||
Init(SourceStream::TYPE_DEFLATE);
|
||||
Init(SourceStreamType::kDeflate);
|
||||
const unsigned char kGzipData[] = {0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51,
|
||||
0x08, 0xcf, 0x2f, 0xca, 0x49, 0x51, 0x04,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
@ -14,11 +14,12 @@
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
MockSourceStream::MockSourceStream() : SourceStream(SourceStream::TYPE_NONE) {}
|
||||
MockSourceStream::MockSourceStream() : SourceStream(SourceStreamType::kNone) {}
|
||||
|
||||
MockSourceStream::~MockSourceStream() {
|
||||
DCHECK(!awaiting_completion_);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace net {
|
||||
|
||||
SourceStream::SourceStream(SourceType type) : type_(type) {}
|
||||
SourceStream::SourceStream(SourceStreamType type) : type_(type) {}
|
||||
|
||||
SourceStream::~SourceStream() = default;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "net/base/completion_once_callback.h"
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
@ -17,17 +18,8 @@ class IOBuffer;
|
||||
// The SourceStream class implements a producer of bytes.
|
||||
class NET_EXPORT_PRIVATE SourceStream {
|
||||
public:
|
||||
enum SourceType {
|
||||
TYPE_BROTLI,
|
||||
TYPE_DEFLATE,
|
||||
TYPE_GZIP,
|
||||
TYPE_ZSTD,
|
||||
TYPE_UNKNOWN,
|
||||
TYPE_NONE,
|
||||
};
|
||||
|
||||
// |type| is the type of the SourceStream.
|
||||
explicit SourceStream(SourceType type);
|
||||
explicit SourceStream(SourceStreamType type);
|
||||
|
||||
SourceStream(const SourceStream&) = delete;
|
||||
SourceStream& operator=(const SourceStream&) = delete;
|
||||
@ -60,10 +52,10 @@ class NET_EXPORT_PRIVATE SourceStream {
|
||||
// is guaranteed to be complete.
|
||||
virtual bool MayHaveMoreBytes() const = 0;
|
||||
|
||||
SourceType type() const { return type_; }
|
||||
SourceStreamType type() const { return type_; }
|
||||
|
||||
private:
|
||||
SourceType type_;
|
||||
const SourceStreamType type_;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
24
net/filter/source_stream_type.h
Normal file
24
net/filter/source_stream_type.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef NET_FILTER_SOURCE_STREAM_TYPE_H_
|
||||
#define NET_FILTER_SOURCE_STREAM_TYPE_H_
|
||||
|
||||
namespace net {
|
||||
|
||||
// The type of net::SourceStream.
|
||||
// LINT.IfChange(SourceStreamType)
|
||||
enum class SourceStreamType {
|
||||
kBrotli,
|
||||
kDeflate,
|
||||
kGzip,
|
||||
kZstd,
|
||||
kUnknown,
|
||||
kNone,
|
||||
};
|
||||
// LINT.ThenChange(//services/network/public/mojom/source_type.mojom:SourceType)
|
||||
|
||||
} // namespace net
|
||||
|
||||
#endif // NET_FILTER_SOURCE_STREAM_TYPE_H_
|
@ -15,6 +15,7 @@
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "third_party/zstd/src/lib/zstd.h"
|
||||
#include "third_party/zstd/src/lib/zstd_errors.h"
|
||||
|
||||
@ -35,7 +36,7 @@ class ZstdSourceStream : public FilterSourceStream {
|
||||
explicit ZstdSourceStream(std::unique_ptr<SourceStream> upstream,
|
||||
scoped_refptr<IOBuffer> dictionary = nullptr,
|
||||
size_t dictionary_size = 0u)
|
||||
: FilterSourceStream(SourceStream::TYPE_ZSTD, std::move(upstream)),
|
||||
: FilterSourceStream(SourceStreamType::kZstd, std::move(upstream)),
|
||||
dictionary_(std::move(dictionary)),
|
||||
dictionary_size_(dictionary_size) {
|
||||
ZSTD_customMem custom_mem = {&customMalloc, &customFree, this};
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "net/base/url_util.h"
|
||||
#include "net/cert/cert_status_flags.h"
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/bidirectional_stream_impl.h"
|
||||
#include "net/http/http_auth.h"
|
||||
#include "net/http/http_auth_controller.h"
|
||||
@ -2184,11 +2185,12 @@ bool HttpNetworkTransaction::ContentEncodingsValid() const {
|
||||
|
||||
bool result = true;
|
||||
for (auto const& encoding : used_encodings) {
|
||||
SourceStream::SourceType source_type =
|
||||
SourceStreamType source_type =
|
||||
FilterSourceStream::ParseEncodingType(encoding);
|
||||
// We don't reject encodings we are not aware. They just will not decode.
|
||||
if (source_type == SourceStream::TYPE_UNKNOWN)
|
||||
if (source_type == SourceStreamType::kUnknown) {
|
||||
continue;
|
||||
}
|
||||
if (allowed_encodings.find(encoding) == allowed_encodings.end()) {
|
||||
result = false;
|
||||
break;
|
||||
|
@ -26,10 +26,9 @@ namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
bool SupportsStreamType(
|
||||
const std::optional<base::flat_set<SourceStream::SourceType>>&
|
||||
accepted_stream_types,
|
||||
SourceStream::SourceType type) {
|
||||
bool SupportsStreamType(const std::optional<base::flat_set<SourceStreamType>>&
|
||||
accepted_stream_types,
|
||||
SourceStreamType type) {
|
||||
if (!accepted_stream_types)
|
||||
return true;
|
||||
return accepted_stream_types->contains(type);
|
||||
@ -241,7 +240,7 @@ base::Value::Dict HttpRequestHeaders::NetLogParams(
|
||||
|
||||
void HttpRequestHeaders::SetAcceptEncodingIfMissing(
|
||||
const GURL& url,
|
||||
const std::optional<base::flat_set<SourceStream::SourceType>>&
|
||||
const std::optional<base::flat_set<SourceStreamType>>&
|
||||
accepted_stream_types,
|
||||
bool enable_brotli,
|
||||
bool enable_zstd) {
|
||||
@ -260,12 +259,10 @@ void HttpRequestHeaders::SetAcceptEncodingIfMissing(
|
||||
// to filter and analyze the streams to assure that a proxy has not damaged
|
||||
// these headers. Some proxies deliberately corrupt Accept-Encoding headers.
|
||||
std::vector<std::string> advertised_encoding_names;
|
||||
if (SupportsStreamType(accepted_stream_types,
|
||||
SourceStream::SourceType::TYPE_GZIP)) {
|
||||
if (SupportsStreamType(accepted_stream_types, SourceStreamType::kGzip)) {
|
||||
advertised_encoding_names.push_back("gzip");
|
||||
}
|
||||
if (SupportsStreamType(accepted_stream_types,
|
||||
SourceStream::SourceType::TYPE_DEFLATE)) {
|
||||
if (SupportsStreamType(accepted_stream_types, SourceStreamType::kDeflate)) {
|
||||
advertised_encoding_names.push_back("deflate");
|
||||
}
|
||||
|
||||
@ -274,15 +271,13 @@ void HttpRequestHeaders::SetAcceptEncodingIfMissing(
|
||||
|
||||
// Advertise "br" encoding only if transferred data is opaque to proxy.
|
||||
if (enable_brotli &&
|
||||
SupportsStreamType(accepted_stream_types,
|
||||
SourceStream::SourceType::TYPE_BROTLI) &&
|
||||
SupportsStreamType(accepted_stream_types, SourceStreamType::kBrotli) &&
|
||||
can_use_advanced_encodings) {
|
||||
advertised_encoding_names.push_back("br");
|
||||
}
|
||||
// Advertise "zstd" encoding only if transferred data is opaque to proxy.
|
||||
if (enable_zstd &&
|
||||
SupportsStreamType(accepted_stream_types,
|
||||
SourceStream::SourceType::TYPE_ZSTD) &&
|
||||
SupportsStreamType(accepted_stream_types, SourceStreamType::kZstd) &&
|
||||
can_use_advanced_encodings) {
|
||||
advertised_encoding_names.push_back("zstd");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/values.h"
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
@ -198,7 +198,7 @@ class NET_EXPORT HttpRequestHeaders {
|
||||
// it does not exist. "br" is appended only when `enable_brotli` is true.
|
||||
void SetAcceptEncodingIfMissing(
|
||||
const GURL& url,
|
||||
const std::optional<base::flat_set<SourceStream::SourceType>>&
|
||||
const std::optional<base::flat_set<SourceStreamType>>&
|
||||
accepted_stream_types,
|
||||
bool enable_brotli,
|
||||
bool enable_zstd);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "net/base/hash_value.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace net {
|
||||
namespace {
|
||||
@ -72,7 +73,7 @@ SharedDictionaryHeaderCheckerSourceStream::
|
||||
std::unique_ptr<SourceStream> upstream,
|
||||
Type type,
|
||||
const SHA256HashValue& dictionary_hash)
|
||||
: SourceStream(SourceStream::TYPE_NONE),
|
||||
: SourceStream(SourceStreamType::kNone),
|
||||
upstream_(std::move(upstream)),
|
||||
type_(type),
|
||||
dictionary_hash_(dictionary_hash),
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "net/filter/brotli_source_stream.h"
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/filter/zstd_source_stream.h"
|
||||
#include "net/http/http_request_info.h"
|
||||
#include "net/http/structured_headers.h"
|
||||
@ -47,7 +48,7 @@ namespace {
|
||||
class ProxyingSourceStream : public SourceStream {
|
||||
public:
|
||||
explicit ProxyingSourceStream(HttpTransaction* transaction)
|
||||
: SourceStream(SourceStream::TYPE_NONE), transaction_(transaction) {}
|
||||
: SourceStream(SourceStreamType::kNone), transaction_(transaction) {}
|
||||
|
||||
ProxyingSourceStream(const ProxyingSourceStream&) = delete;
|
||||
ProxyingSourceStream& operator=(const ProxyingSourceStream&) = delete;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "net/filter/gzip_source_stream.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "net/url_request/url_request_error_job.h"
|
||||
#include "url/gurl.h"
|
||||
@ -152,7 +152,7 @@ URLRequestTestJobBackedByFile::SetUpSourceStream() {
|
||||
if (!base::EqualsCaseInsensitiveASCII(file_path_.Extension(), ".svgz"))
|
||||
return source;
|
||||
|
||||
return GzipSourceStream::Create(std::move(source), SourceStream::TYPE_GZIP);
|
||||
return GzipSourceStream::Create(std::move(source), SourceStreamType::kGzip);
|
||||
}
|
||||
|
||||
std::unique_ptr<URLRequestTestJobBackedByFile::FileMetaInfo>
|
||||
|
@ -31,7 +31,7 @@ const char kBrotli[] = "br";
|
||||
class StdinSourceStream : public SourceStream {
|
||||
public:
|
||||
explicit StdinSourceStream(std::istream* input_stream)
|
||||
: SourceStream(SourceStream::TYPE_NONE), input_stream_(input_stream) {}
|
||||
: SourceStream(SourceStreamType::kNone), input_stream_(input_stream) {}
|
||||
|
||||
StdinSourceStream(const StdinSourceStream&) = delete;
|
||||
StdinSourceStream& operator=(const StdinSourceStream&) = delete;
|
||||
@ -74,11 +74,11 @@ bool ContentDecoderToolProcessInput(std::vector<std::string> content_encodings,
|
||||
downstream = CreateBrotliSourceStream(std::move(upstream));
|
||||
} else if (base::EqualsCaseInsensitiveASCII(content_encoding, kDeflate)) {
|
||||
downstream = GzipSourceStream::Create(std::move(upstream),
|
||||
SourceStream::TYPE_DEFLATE);
|
||||
SourceStreamType::kDeflate);
|
||||
} else if (base::EqualsCaseInsensitiveASCII(content_encoding, kGZip) ||
|
||||
base::EqualsCaseInsensitiveASCII(content_encoding, kXGZip)) {
|
||||
downstream = GzipSourceStream::Create(std::move(upstream),
|
||||
SourceStream::TYPE_GZIP);
|
||||
SourceStreamType::kGzip);
|
||||
} else {
|
||||
LOG(ERROR) << "Unsupported decoder '" << content_encoding << "'.";
|
||||
return false;
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/cookies/site_for_cookies.h"
|
||||
#include "net/dns/public/secure_dns_policy.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_raw_request_headers.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
@ -774,17 +774,16 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
|
||||
return traffic_annotation_;
|
||||
}
|
||||
|
||||
const std::optional<base::flat_set<net::SourceStream::SourceType>>&
|
||||
accepted_stream_types() const {
|
||||
const std::optional<base::flat_set<SourceStreamType>>& accepted_stream_types()
|
||||
const {
|
||||
return accepted_stream_types_;
|
||||
}
|
||||
|
||||
void set_accepted_stream_types(
|
||||
const std::optional<base::flat_set<net::SourceStream::SourceType>>&
|
||||
types) {
|
||||
const std::optional<base::flat_set<SourceStreamType>>& types) {
|
||||
if (types) {
|
||||
DCHECK(!types->contains(net::SourceStream::SourceType::TYPE_NONE));
|
||||
DCHECK(!types->contains(net::SourceStream::SourceType::TYPE_UNKNOWN));
|
||||
DCHECK(!types->contains(SourceStreamType::kNone));
|
||||
DCHECK(!types->contains(SourceStreamType::kUnknown));
|
||||
}
|
||||
accepted_stream_types_ = types;
|
||||
}
|
||||
@ -1149,8 +1148,7 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
|
||||
// If not null, the network service will not advertise any stream types
|
||||
// (via Accept-Encoding) that are not listed. Also, it will not attempt
|
||||
// decoding any non-listed stream types.
|
||||
std::optional<base::flat_set<net::SourceStream::SourceType>>
|
||||
accepted_stream_types_;
|
||||
std::optional<base::flat_set<net::SourceStreamType>> accepted_stream_types_;
|
||||
|
||||
const NetworkTrafficAnnotationTag traffic_annotation_;
|
||||
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
#include "net/filter/gzip_source_stream.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/filter/zstd_source_stream.h"
|
||||
#include "net/first_party_sets/first_party_set_entry.h"
|
||||
#include "net/first_party_sets/first_party_set_metadata.h"
|
||||
@ -1478,29 +1479,28 @@ std::unique_ptr<SourceStream> URLRequestHttpJob::SetUpSourceStream() {
|
||||
|
||||
std::unique_ptr<SourceStream> upstream = URLRequestJob::SetUpSourceStream();
|
||||
HttpResponseHeaders* headers = GetResponseHeaders();
|
||||
std::vector<SourceStream::SourceType> types;
|
||||
std::vector<SourceStreamType> types;
|
||||
size_t iter = 0;
|
||||
while (std::optional<std::string_view> type =
|
||||
headers->EnumerateHeader(&iter, "Content-Encoding")) {
|
||||
SourceStream::SourceType source_type =
|
||||
FilterSourceStream::ParseEncodingType(*type);
|
||||
SourceStreamType source_type = FilterSourceStream::ParseEncodingType(*type);
|
||||
switch (source_type) {
|
||||
case SourceStream::TYPE_BROTLI:
|
||||
case SourceStream::TYPE_DEFLATE:
|
||||
case SourceStream::TYPE_GZIP:
|
||||
case SourceStream::TYPE_ZSTD:
|
||||
case SourceStreamType::kBrotli:
|
||||
case SourceStreamType::kDeflate:
|
||||
case SourceStreamType::kGzip:
|
||||
case SourceStreamType::kZstd:
|
||||
if (request_->accepted_stream_types() &&
|
||||
!request_->accepted_stream_types()->contains(source_type)) {
|
||||
// If the source type is disabled, we treat it
|
||||
// in the same way as SourceStream::TYPE_UNKNOWN.
|
||||
// in the same way as SourceStreamType::kUnknown.
|
||||
return upstream;
|
||||
}
|
||||
types.push_back(source_type);
|
||||
break;
|
||||
case SourceStream::TYPE_NONE:
|
||||
case SourceStreamType::kNone:
|
||||
// Identity encoding type. Pass through raw response body.
|
||||
return upstream;
|
||||
case SourceStream::TYPE_UNKNOWN:
|
||||
case SourceStreamType::kUnknown:
|
||||
// Unknown encoding type. Pass through raw response body.
|
||||
// Request will not be canceled; though
|
||||
// it is expected that user will see malformed / garbage response.
|
||||
@ -1513,23 +1513,23 @@ std::unique_ptr<SourceStream> URLRequestHttpJob::SetUpSourceStream() {
|
||||
for (const auto& type : base::Reversed(types)) {
|
||||
std::unique_ptr<FilterSourceStream> downstream;
|
||||
switch (type) {
|
||||
case SourceStream::TYPE_BROTLI:
|
||||
case SourceStreamType::kBrotli:
|
||||
downstream = CreateBrotliSourceStream(std::move(upstream));
|
||||
content_encoding_type = ContentEncodingType::kBrotli;
|
||||
break;
|
||||
case SourceStream::TYPE_GZIP:
|
||||
case SourceStream::TYPE_DEFLATE:
|
||||
case SourceStreamType::kGzip:
|
||||
case SourceStreamType::kDeflate:
|
||||
downstream = GzipSourceStream::Create(std::move(upstream), type);
|
||||
content_encoding_type = type == SourceStream::TYPE_GZIP
|
||||
content_encoding_type = type == SourceStreamType::kGzip
|
||||
? ContentEncodingType::kGZip
|
||||
: ContentEncodingType::kDeflate;
|
||||
break;
|
||||
case SourceStream::TYPE_ZSTD:
|
||||
case SourceStreamType::kZstd:
|
||||
downstream = CreateZstdSourceStream(std::move(upstream));
|
||||
content_encoding_type = ContentEncodingType::kZstd;
|
||||
break;
|
||||
case SourceStream::TYPE_NONE:
|
||||
case SourceStream::TYPE_UNKNOWN:
|
||||
case SourceStreamType::kNone:
|
||||
case SourceStreamType::kUnknown:
|
||||
NOTREACHED();
|
||||
}
|
||||
if (downstream == nullptr)
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "net/cookies/cookie_store_test_callbacks.h"
|
||||
#include "net/cookies/cookie_store_test_helpers.h"
|
||||
#include "net/cookies/test_cookie_access_delegate.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_transaction_factory.h"
|
||||
#include "net/http/http_transaction_test_util.h"
|
||||
#include "net/http/transport_security_state.h"
|
||||
@ -1930,52 +1932,51 @@ TEST_F(URLRequestHttpJobWithBrotliSupportTest, BrotliAdvertisement) {
|
||||
|
||||
TEST_F(URLRequestHttpJobWithBrotliSupportTest, DefaultAcceptEncodingOverriden) {
|
||||
struct {
|
||||
base::flat_set<net::SourceStream::SourceType> accepted_types;
|
||||
base::flat_set<net::SourceStreamType> accepted_types;
|
||||
const char* expected_request_headers;
|
||||
} kTestCases[] = {{{net::SourceStream::SourceType::TYPE_DEFLATE},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: deflate\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStream::SourceType::TYPE_GZIP},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: gzip\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStream::SourceType::TYPE_GZIP,
|
||||
net::SourceStream::SourceType::TYPE_DEFLATE},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: gzip, deflate\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStream::SourceType::TYPE_BROTLI},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: br\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStream::SourceType::TYPE_BROTLI,
|
||||
net::SourceStream::SourceType::TYPE_GZIP,
|
||||
net::SourceStream::SourceType::TYPE_DEFLATE},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: gzip, deflate, br\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"}};
|
||||
} kTestCases[] = {
|
||||
{{net::SourceStreamType::kDeflate},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: deflate\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStreamType::kGzip},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: gzip\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStreamType::kGzip, net::SourceStreamType::kDeflate},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: gzip, deflate\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStreamType::kBrotli},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: br\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"},
|
||||
{{net::SourceStreamType::kBrotli, net::SourceStreamType::kGzip,
|
||||
net::SourceStreamType::kDeflate},
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: www.example.com\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent: \r\n"
|
||||
"Accept-Encoding: gzip, deflate, br\r\n"
|
||||
"Accept-Language: en-us,fr\r\n\r\n"}};
|
||||
|
||||
for (auto test : kTestCases) {
|
||||
net::SSLSocketDataProvider ssl_socket_data_provider(net::ASYNC, net::OK);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "net/cert/x509_certificate.h"
|
||||
#include "net/cookies/cookie_setting_override.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/log/net_log.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
#include "net/log/net_log_event_type.h"
|
||||
@ -57,7 +59,7 @@ base::Value::Dict SourceStreamSetParams(SourceStream* source_stream) {
|
||||
class URLRequestJob::URLRequestJobSourceStream : public SourceStream {
|
||||
public:
|
||||
explicit URLRequestJobSourceStream(URLRequestJob* job)
|
||||
: SourceStream(SourceStream::TYPE_NONE), job_(job) {
|
||||
: SourceStream(SourceStreamType::kNone), job_(job) {
|
||||
DCHECK(job_);
|
||||
}
|
||||
|
||||
@ -492,7 +494,7 @@ void URLRequestJob::NotifyFinalHeadersReceived() {
|
||||
OnDone(ERR_CONTENT_DECODING_INIT_FAILED, true /* notify_done */);
|
||||
return;
|
||||
}
|
||||
if (source_stream_->type() == SourceStream::TYPE_NONE) {
|
||||
if (source_stream_->type() == SourceStreamType::kNone) {
|
||||
// If the subclass didn't set |expected_content_size|, and there are
|
||||
// headers, and the response body is not compressed, try to get the
|
||||
// expected content size from the headers.
|
||||
@ -715,7 +717,7 @@ void URLRequestJob::GatherRawReadStats(int bytes_read) {
|
||||
|
||||
if (bytes_read > 0) {
|
||||
// If there is a filter, bytes will be logged after the filter is applied.
|
||||
if (source_stream_->type() != SourceStream::TYPE_NONE &&
|
||||
if (source_stream_->type() != SourceStreamType::kNone &&
|
||||
request()->net_log().IsCapturing()) {
|
||||
request()->net_log().AddByteTransferEvent(
|
||||
NetLogEventType::URL_REQUEST_JOB_BYTES_READ, bytes_read,
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "net/cookies/cookie_setting_override.h"
|
||||
#include "net/cookies/cookie_util.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/http/http_raw_request_headers.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/socket/connection_attempts.h"
|
||||
@ -43,6 +42,7 @@ class HttpResponseInfo;
|
||||
class IOBuffer;
|
||||
struct LoadTimingInfo;
|
||||
class ProxyChain;
|
||||
class SourceStream;
|
||||
class SSLCertRequestInfo;
|
||||
class SSLInfo;
|
||||
class SSLPrivateKey;
|
||||
|
@ -8688,14 +8688,13 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptEncodingOverridden) {
|
||||
ASSERT_TRUE(http_test_server()->Start());
|
||||
|
||||
struct {
|
||||
base::flat_set<net::SourceStream::SourceType> accepted_types;
|
||||
base::flat_set<SourceStreamType> accepted_types;
|
||||
const char* expected_accept_encoding;
|
||||
} tests[] = {{{net::SourceStream::SourceType::TYPE_DEFLATE}, "deflate"},
|
||||
{{}, "None"},
|
||||
{{net::SourceStream::SourceType::TYPE_GZIP}, "gzip"},
|
||||
{{net::SourceStream::SourceType::TYPE_GZIP,
|
||||
net::SourceStream::SourceType::TYPE_DEFLATE},
|
||||
"gzip, deflate"}};
|
||||
} tests[] = {
|
||||
{{SourceStreamType::kDeflate}, "deflate"},
|
||||
{{}, "None"},
|
||||
{{SourceStreamType::kGzip}, "gzip"},
|
||||
{{SourceStreamType::kGzip, SourceStreamType::kDeflate}, "gzip, deflate"}};
|
||||
for (auto test : tests) {
|
||||
TestDelegate d;
|
||||
std::unique_ptr<URLRequest> req(default_context().CreateRequest(
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/load_flags_to_string.h"
|
||||
#include "net/cookies/site_for_cookies.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "services/network/public/cpp/data_element.h"
|
||||
#include "services/network/public/cpp/resource_request.h"
|
||||
|
@ -12,12 +12,13 @@
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
|
||||
namespace network {
|
||||
|
||||
DataPipeToSourceStream::DataPipeToSourceStream(
|
||||
mojo::ScopedDataPipeConsumerHandle body)
|
||||
: net::SourceStream(net::SourceStream::TYPE_NONE),
|
||||
: net::SourceStream(net::SourceStreamType::kNone),
|
||||
body_(std::move(body)),
|
||||
handle_watcher_(FROM_HERE,
|
||||
mojo::SimpleWatcher::ArmingPolicy::MANUAL,
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "net/base/isolation_info.h"
|
||||
#include "net/base/request_priority.h"
|
||||
#include "net/cookies/site_for_cookies.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/log/net_log_source.h"
|
||||
#include "net/socket/socket_tag.h"
|
||||
@ -217,7 +217,7 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest {
|
||||
// If not null, the network service will not advertise any stream types
|
||||
// (via Accept-Encoding) that are not listed. Also, it will not attempt
|
||||
// decoding any non-listed stream types.
|
||||
std::optional<std::vector<net::SourceStream::SourceType>>
|
||||
std::optional<std::vector<net::SourceStreamType>>
|
||||
devtools_accepted_stream_types;
|
||||
std::optional<net::NetLogSource> net_log_create_info;
|
||||
std::optional<net::NetLogSource> net_log_reference_info;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/test/task_environment.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/filter/mock_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace network {
|
||||
@ -48,7 +49,8 @@ struct SourceStreamToDataPipeTestParam {
|
||||
|
||||
class DummyPendingSourceStream : public net::SourceStream {
|
||||
public:
|
||||
DummyPendingSourceStream() : net::SourceStream(SourceStream::TYPE_NONE) {}
|
||||
DummyPendingSourceStream()
|
||||
: net::SourceStream(net::SourceStreamType::kNone) {}
|
||||
~DummyPendingSourceStream() override = default;
|
||||
|
||||
DummyPendingSourceStream(const DummyPendingSourceStream&) = delete;
|
||||
|
@ -9,46 +9,46 @@
|
||||
namespace mojo {
|
||||
|
||||
network::mojom::SourceType
|
||||
EnumTraits<network::mojom::SourceType, net::SourceStream::SourceType>::ToMojom(
|
||||
net::SourceStream::SourceType type) {
|
||||
EnumTraits<network::mojom::SourceType, net::SourceStreamType>::ToMojom(
|
||||
net::SourceStreamType type) {
|
||||
switch (type) {
|
||||
case net::SourceStream::SourceType::TYPE_BROTLI:
|
||||
case net::SourceStreamType::kBrotli:
|
||||
return network::mojom::SourceType::kBrotli;
|
||||
case net::SourceStream::SourceType::TYPE_DEFLATE:
|
||||
case net::SourceStreamType::kDeflate:
|
||||
return network::mojom::SourceType::kDeflate;
|
||||
case net::SourceStream::SourceType::TYPE_GZIP:
|
||||
case net::SourceStreamType::kGzip:
|
||||
return network::mojom::SourceType::kGzip;
|
||||
case net::SourceStream::SourceType::TYPE_ZSTD:
|
||||
case net::SourceStreamType::kZstd:
|
||||
return network::mojom::SourceType::kZstd;
|
||||
case net::SourceStream::SourceType::TYPE_NONE:
|
||||
case net::SourceStreamType::kNone:
|
||||
return network::mojom::SourceType::kNone;
|
||||
case net::SourceStream::SourceType::TYPE_UNKNOWN:
|
||||
case net::SourceStreamType::kUnknown:
|
||||
return network::mojom::SourceType::kUnknown;
|
||||
}
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
bool EnumTraits<network::mojom::SourceType, net::SourceStream::SourceType>::
|
||||
FromMojom(network::mojom::SourceType in,
|
||||
net::SourceStream::SourceType* out) {
|
||||
bool EnumTraits<network::mojom::SourceType, net::SourceStreamType>::FromMojom(
|
||||
network::mojom::SourceType in,
|
||||
net::SourceStreamType* out) {
|
||||
switch (in) {
|
||||
case network::mojom::SourceType::kBrotli:
|
||||
*out = net::SourceStream::SourceType::TYPE_BROTLI;
|
||||
*out = net::SourceStreamType::kBrotli;
|
||||
return true;
|
||||
case network::mojom::SourceType::kDeflate:
|
||||
*out = net::SourceStream::SourceType::TYPE_DEFLATE;
|
||||
*out = net::SourceStreamType::kDeflate;
|
||||
return true;
|
||||
case network::mojom::SourceType::kGzip:
|
||||
*out = net::SourceStream::SourceType::TYPE_GZIP;
|
||||
*out = net::SourceStreamType::kGzip;
|
||||
return true;
|
||||
case network::mojom::SourceType::kZstd:
|
||||
*out = net::SourceStream::SourceType::TYPE_ZSTD;
|
||||
*out = net::SourceStreamType::kZstd;
|
||||
return true;
|
||||
case network::mojom::SourceType::kNone:
|
||||
*out = net::SourceStream::SourceType::TYPE_NONE;
|
||||
*out = net::SourceStreamType::kNone;
|
||||
return true;
|
||||
case network::mojom::SourceType::kUnknown:
|
||||
*out = net::SourceStream::SourceType::TYPE_UNKNOWN;
|
||||
*out = net::SourceStreamType::kUnknown;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7,17 +7,17 @@
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "mojo/public/cpp/bindings/enum_traits.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "services/network/public/mojom/source_type.mojom-shared.h"
|
||||
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
|
||||
EnumTraits<network::mojom::SourceType, net::SourceStream::SourceType> {
|
||||
static network::mojom::SourceType ToMojom(net::SourceStream::SourceType type);
|
||||
EnumTraits<network::mojom::SourceType, net::SourceStreamType> {
|
||||
static network::mojom::SourceType ToMojom(net::SourceStreamType type);
|
||||
static bool FromMojom(network::mojom::SourceType in,
|
||||
net::SourceStream::SourceType* out);
|
||||
net::SourceStreamType* out);
|
||||
};
|
||||
|
||||
} // namespace mojo
|
||||
|
@ -352,7 +352,7 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
|
||||
const network::ResourceRequest& request) {
|
||||
return request.original_destination;
|
||||
}
|
||||
static const std::optional<std::vector<net::SourceStream::SourceType>>&
|
||||
static const std::optional<std::vector<net::SourceStreamType>>&
|
||||
devtools_accepted_stream_types(const network::ResourceRequest& request) {
|
||||
return request.devtools_accepted_stream_types;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "mojo/public/cpp/test_support/test_utils.h"
|
||||
#include "net/base/isolation_info.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/log/net_log.h"
|
||||
#include "net/log/net_log_source.h"
|
||||
#include "net/log/net_log_source_type.h"
|
||||
@ -109,11 +109,9 @@ TEST(URLRequestMojomTraitsTest, Roundtrips_ResourceRequest) {
|
||||
net::NetLogSourceType::URL_REQUEST, net::NetLog::Get()->NextID()));
|
||||
original.net_log_reference_info = std::make_optional(net::NetLogSource(
|
||||
net::NetLogSourceType::URL_REQUEST, net::NetLog::Get()->NextID()));
|
||||
original.devtools_accepted_stream_types =
|
||||
std::vector<net::SourceStream::SourceType>(
|
||||
{net::SourceStream::SourceType::TYPE_BROTLI,
|
||||
net::SourceStream::SourceType::TYPE_GZIP,
|
||||
net::SourceStream::SourceType::TYPE_DEFLATE});
|
||||
original.devtools_accepted_stream_types = std::vector<net::SourceStreamType>(
|
||||
{net::SourceStreamType::kBrotli, net::SourceStreamType::kGzip,
|
||||
net::SourceStreamType::kDeflate});
|
||||
original.target_ip_address_space = mojom::IPAddressSpace::kPrivate;
|
||||
original.storage_access_api_status =
|
||||
net::StorageAccessApiStatus::kAccessViaAPI;
|
||||
|
@ -764,7 +764,7 @@ mojom("url_loader_base") {
|
||||
types = [
|
||||
{
|
||||
mojom = "network.mojom.SourceType"
|
||||
cpp = "::net::SourceStream::SourceType"
|
||||
cpp = "::net::SourceStreamType"
|
||||
},
|
||||
]
|
||||
traits_headers =
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
module network.mojom;
|
||||
|
||||
// This enums corresponds to net::SourceStream::SourceType.
|
||||
// This enums corresponds to net::SourceStreamType.
|
||||
// LINT.IfChange(SourceType)
|
||||
enum SourceType {
|
||||
kBrotli,
|
||||
kDeflate,
|
||||
@ -13,3 +14,4 @@ enum SourceType {
|
||||
kNone,
|
||||
kUnknown,
|
||||
};
|
||||
// LINT.ThenChange(//net/filter/source_stream_type.h:SourceStreamType)
|
||||
|
@ -896,7 +896,7 @@ void URLLoader::ConfigureRequest(
|
||||
bool force_main_frame_for_same_site_cookies,
|
||||
net::SecureDnsPolicy secure_dns_policy,
|
||||
net::HttpRequestHeaders extra_request_headers,
|
||||
const std::optional<std::vector<net::SourceStream::SourceType>>&
|
||||
const std::optional<std::vector<net::SourceStreamType>>&
|
||||
accepted_stream_types,
|
||||
const std::optional<url::Origin>& initiator,
|
||||
net::RedirectInfo::FirstPartyURLPolicy first_party_url_policy,
|
||||
|
@ -366,7 +366,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) URLLoader
|
||||
bool force_main_frame_for_same_site_cookies,
|
||||
net::SecureDnsPolicy secure_dns_policy,
|
||||
net::HttpRequestHeaders extra_request_headers,
|
||||
const std::optional<std::vector<net::SourceStream::SourceType>>&
|
||||
const std::optional<std::vector<net::SourceStreamType>>&
|
||||
accepted_stream_types,
|
||||
const std::optional<url::Origin>& initiator,
|
||||
net::RedirectInfo::FirstPartyURLPolicy first_party_url_policy,
|
||||
|
@ -40,10 +40,8 @@ specific_include_rules = {
|
||||
"inspector_contrast.h": [
|
||||
"+cc/base/rtree.h",
|
||||
],
|
||||
"inspector_network_agent.h": [
|
||||
"+net/filter/source_stream.h",
|
||||
],
|
||||
"inspector_network_agent.cc": [
|
||||
"+net/filter/source_stream_type.h",
|
||||
"+third_party/boringssl/src/include",
|
||||
],
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "net/base/ip_endpoint.h"
|
||||
#include "net/cert/ct_sct_to_string.h"
|
||||
#include "net/cert/x509_util.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/ssl/ssl_cipher_suite_names.h"
|
||||
#include "net/ssl/ssl_connection_status_flags.h"
|
||||
@ -745,16 +746,16 @@ String AcceptedEncodingFromProtocol(
|
||||
return result;
|
||||
}
|
||||
|
||||
using SourceTypeEnum = net::SourceStream::SourceType;
|
||||
using SourceTypeEnum = net::SourceStreamType;
|
||||
SourceTypeEnum SourceTypeFromString(const String& type) {
|
||||
if (type == ContentEncodingEnum::Gzip)
|
||||
return SourceTypeEnum::TYPE_GZIP;
|
||||
return SourceTypeEnum::kGzip;
|
||||
if (type == ContentEncodingEnum::Deflate)
|
||||
return SourceTypeEnum::TYPE_DEFLATE;
|
||||
return SourceTypeEnum::kDeflate;
|
||||
if (type == ContentEncodingEnum::Br)
|
||||
return SourceTypeEnum::TYPE_BROTLI;
|
||||
return SourceTypeEnum::kBrotli;
|
||||
if (type == ContentEncodingEnum::Zstd) {
|
||||
return SourceTypeEnum::TYPE_ZSTD;
|
||||
return SourceTypeEnum::kZstd;
|
||||
}
|
||||
NOTREACHED();
|
||||
}
|
||||
@ -1444,12 +1445,11 @@ void InspectorNetworkAgent::PrepareRequest(DocumentLoader* loader,
|
||||
}
|
||||
}
|
||||
if (!accepted_encodings_.IsEmpty()) {
|
||||
scoped_refptr<
|
||||
base::RefCountedData<base::flat_set<net::SourceStream::SourceType>>>
|
||||
scoped_refptr<base::RefCountedData<base::flat_set<net::SourceStreamType>>>
|
||||
accepted_stream_types = request.GetDevToolsAcceptedStreamTypes();
|
||||
if (!accepted_stream_types) {
|
||||
accepted_stream_types = base::MakeRefCounted<base::RefCountedData<
|
||||
base::flat_set<net::SourceStream::SourceType>>>();
|
||||
accepted_stream_types = base::MakeRefCounted<
|
||||
base::RefCountedData<base::flat_set<net::SourceStreamType>>>();
|
||||
}
|
||||
if (!accepted_encodings_.Get("none")) {
|
||||
for (auto key : accepted_encodings_.Keys())
|
||||
|
@ -5,7 +5,7 @@ include_rules = [
|
||||
"+net/base/ip_endpoint.h",
|
||||
"+net/base/schemeful_site.h",
|
||||
"+net/dns/public",
|
||||
"+net/filter/source_stream.h",
|
||||
"+net/filter/source_stream_type.h",
|
||||
"+net/http/alternate_protocol_usage.h",
|
||||
"+net/ssl/ssl_info.h",
|
||||
"+net/storage_access_api/status.h",
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "base/time/time.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "net/cookies/site_for_cookies.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/storage_access_api/status.h"
|
||||
#include "services/metrics/public/cpp/ukm_source_id.h"
|
||||
#include "services/network/public/mojom/attribution.mojom-blink.h"
|
||||
@ -458,14 +458,13 @@ class PLATFORM_EXPORT ResourceRequestHead {
|
||||
}
|
||||
|
||||
const scoped_refptr<
|
||||
base::RefCountedData<base::flat_set<net::SourceStream::SourceType>>>&
|
||||
base::RefCountedData<base::flat_set<net::SourceStreamType>>>&
|
||||
GetDevToolsAcceptedStreamTypes() const {
|
||||
return devtools_accepted_stream_types_;
|
||||
}
|
||||
void SetDevToolsAcceptedStreamTypes(
|
||||
const scoped_refptr<
|
||||
base::RefCountedData<base::flat_set<net::SourceStream::SourceType>>>&
|
||||
types) {
|
||||
base::RefCountedData<base::flat_set<net::SourceStreamType>>>& types) {
|
||||
devtools_accepted_stream_types_ = types;
|
||||
}
|
||||
|
||||
@ -793,8 +792,7 @@ class PLATFORM_EXPORT ResourceRequestHead {
|
||||
// Instead of using std::optional, we use scoped_refptr to reduce
|
||||
// blink memory footprint because the attribute is only used by DevTools
|
||||
// and we should keep the footprint minimal when DevTools is closed.
|
||||
scoped_refptr<
|
||||
base::RefCountedData<base::flat_set<net::SourceStream::SourceType>>>
|
||||
scoped_refptr<base::RefCountedData<base::flat_set<net::SourceStreamType>>>
|
||||
devtools_accepted_stream_types_;
|
||||
|
||||
net::StorageAccessApiStatus storage_access_api_status_ =
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mojo/public/cpp/system/data_pipe.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/request_priority.h"
|
||||
#include "net/filter/source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "services/network/public/cpp/is_potentially_trustworthy.h"
|
||||
@ -262,10 +262,9 @@ void PopulateResourceRequest(const ResourceRequestHead& src,
|
||||
dest->upgrade_if_insecure = src.UpgradeIfInsecure();
|
||||
dest->is_revalidating = src.IsRevalidating();
|
||||
if (src.GetDevToolsAcceptedStreamTypes()) {
|
||||
dest->devtools_accepted_stream_types =
|
||||
std::vector<net::SourceStream::SourceType>(
|
||||
src.GetDevToolsAcceptedStreamTypes()->data.begin(),
|
||||
src.GetDevToolsAcceptedStreamTypes()->data.end());
|
||||
dest->devtools_accepted_stream_types = std::vector<net::SourceStreamType>(
|
||||
src.GetDevToolsAcceptedStreamTypes()->data.begin(),
|
||||
src.GetDevToolsAcceptedStreamTypes()->data.end());
|
||||
}
|
||||
if (src.RequestorOrigin()->ToString() == "null") {
|
||||
// "file:" origin is treated like an opaque unique origin when
|
||||
|
@ -1485,7 +1485,7 @@ _CONFIG = [
|
||||
'base::HexEncode',
|
||||
'net::ct::.+',
|
||||
'net::IPAddress',
|
||||
'net::SourceStream',
|
||||
'net::SourceStreamType',
|
||||
'net::SSL.+',
|
||||
],
|
||||
},
|
||||
|
@ -16,7 +16,7 @@ I18nSourceStream::~I18nSourceStream() {}
|
||||
|
||||
std::unique_ptr<I18nSourceStream> I18nSourceStream::Create(
|
||||
std::unique_ptr<SourceStream> upstream,
|
||||
SourceStream::SourceType type,
|
||||
net::SourceStreamType type,
|
||||
const TemplateReplacements* replacements) {
|
||||
DCHECK(replacements);
|
||||
std::unique_ptr<I18nSourceStream> source(
|
||||
@ -25,7 +25,7 @@ std::unique_ptr<I18nSourceStream> I18nSourceStream::Create(
|
||||
}
|
||||
|
||||
I18nSourceStream::I18nSourceStream(std::unique_ptr<SourceStream> upstream,
|
||||
SourceStream::SourceType type,
|
||||
net::SourceStreamType type,
|
||||
const TemplateReplacements* replacements)
|
||||
: FilterSourceStream(type, std::move(upstream)),
|
||||
replacements_(replacements) {}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/component_export.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "net/filter/filter_source_stream.h"
|
||||
#include "net/filter/source_stream_type.h"
|
||||
#include "ui/base/template_expressions.h"
|
||||
|
||||
namespace ui {
|
||||
@ -27,12 +28,12 @@ class COMPONENT_EXPORT(UI_BASE) I18nSourceStream
|
||||
// |replacements| is a dictionary of i18n replacements.
|
||||
static std::unique_ptr<I18nSourceStream> Create(
|
||||
std::unique_ptr<SourceStream> previous,
|
||||
SourceStream::SourceType type,
|
||||
net::SourceStreamType type,
|
||||
const ui::TemplateReplacements* replacements);
|
||||
|
||||
private:
|
||||
I18nSourceStream(std::unique_ptr<SourceStream> previous,
|
||||
SourceStream::SourceType type,
|
||||
net::SourceStreamType type,
|
||||
const TemplateReplacements* replacements);
|
||||
|
||||
// SourceStream implementation.
|
||||
|
@ -102,7 +102,7 @@ class I18nSourceStreamTest : public ::testing::TestWithParam<I18nTestParam> {
|
||||
replacements_["beta"] = "banana";
|
||||
replacements_["gamma"] = "carrot";
|
||||
stream_ = I18nSourceStream::Create(
|
||||
std::move(source), net::SourceStream::TYPE_NONE, &replacements_);
|
||||
std::move(source), net::SourceStreamType::kNone, &replacements_);
|
||||
}
|
||||
|
||||
// If MockSourceStream::Mode is ASYNC, completes 1 read from |mock_stream| and
|
||||
|
Reference in New Issue
Block a user