diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-03-12 09:13:00 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-03-16 09:58:26 +0000 |
commit | 03561cae90f1d99b5c54b1ef3be69f10e882b25e (patch) | |
tree | cc5f0958e823c044e7ae51cc0117fe51432abe5e /chromium/net/third_party/quiche/src/quic/tools | |
parent | fa98118a45f7e169f8846086dc2c22c49a8ba310 (diff) | |
download | qtwebengine-chromium-03561cae90f1d99b5c54b1ef3be69f10e882b25e.tar.gz |
BASELINE: Update Chromium to 88.0.4324.208
Change-Id: I3ae87d23e4eff4b4a469685658740a213600c667
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/tools')
35 files changed, 483 insertions, 392 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h b/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h index 7f4a38ea5ec..87078798edf 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h +++ b/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TOOLS_FAKE_PROOF_VERIFIER_H_ #define QUICHE_QUIC_TOOLS_FAKE_PROOF_VERIFIER_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -19,7 +19,7 @@ class FakeProofVerifier : public ProofVerifier { const uint16_t /*port*/, const std::string& /*server_config*/, QuicTransportVersion /*quic_version*/, - quiche::QuicheStringPiece /*chlo_hash*/, + absl::string_view /*chlo_hash*/, const std::vector<std::string>& /*certs*/, const std::string& /*cert_sct*/, const std::string& /*signature*/, @@ -38,6 +38,7 @@ class FakeProofVerifier : public ProofVerifier { const ProofVerifyContext* /*context*/, std::string* /*error_details*/, std::unique_ptr<ProofVerifyDetails>* /*details*/, + uint8_t* /*out_alert*/, std::unique_ptr<ProofVerifierCallback> /*callback*/) override { return QUIC_SUCCESS; } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc index 7900683913d..defa9bfec02 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc @@ -8,7 +8,7 @@ namespace quic { QuicBackendResponse::ServerPushInfo::ServerPushInfo( QuicUrl request_url, - spdy::SpdyHeaderBlock headers, + spdy::Http2HeaderBlock headers, spdy::SpdyPriority priority, std::string body) : request_url(request_url), diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h index af6cf84ee0c..9209038f4b3 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_BACKEND_RESPONSE_H_ #define QUICHE_QUIC_TOOLS_QUIC_BACKEND_RESPONSE_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" namespace quic { @@ -19,13 +19,13 @@ class QuicBackendResponse { // comprising a response for the push request. struct ServerPushInfo { ServerPushInfo(QuicUrl request_url, - spdy::SpdyHeaderBlock headers, + spdy::Http2HeaderBlock headers, spdy::SpdyPriority priority, std::string body); ServerPushInfo(const ServerPushInfo& other); QuicUrl request_url; - spdy::SpdyHeaderBlock headers; + spdy::Http2HeaderBlock headers; spdy::SpdyPriority priority; std::string body; }; @@ -51,30 +51,28 @@ class QuicBackendResponse { ~QuicBackendResponse(); SpecialResponseType response_type() const { return response_type_; } - const spdy::SpdyHeaderBlock& headers() const { return headers_; } - const spdy::SpdyHeaderBlock& trailers() const { return trailers_; } - const quiche::QuicheStringPiece body() const { - return quiche::QuicheStringPiece(body_); - } + const spdy::Http2HeaderBlock& headers() const { return headers_; } + const spdy::Http2HeaderBlock& trailers() const { return trailers_; } + const absl::string_view body() const { return absl::string_view(body_); } void set_response_type(SpecialResponseType response_type) { response_type_ = response_type; } - void set_headers(spdy::SpdyHeaderBlock headers) { + void set_headers(spdy::Http2HeaderBlock headers) { headers_ = std::move(headers); } - void set_trailers(spdy::SpdyHeaderBlock trailers) { + void set_trailers(spdy::Http2HeaderBlock trailers) { trailers_ = std::move(trailers); } - void set_body(quiche::QuicheStringPiece body) { + void set_body(absl::string_view body) { body_.assign(body.data(), body.size()); } private: SpecialResponseType response_type_; - spdy::SpdyHeaderBlock headers_; - spdy::SpdyHeaderBlock trailers_; + spdy::Http2HeaderBlock headers_; + spdy::Http2HeaderBlock trailers_; std::string body_; }; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc index c1d2ea2103c..5d89797f8c9 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc @@ -121,8 +121,8 @@ void QuicClientBase::StartConnect() { session_ = CreateQuicClientSession( client_supported_versions, - new QuicConnection(GetNextConnectionId(), server_address(), helper(), - alarm_factory(), writer, + new QuicConnection(GetNextConnectionId(), QuicSocketAddress(), + server_address(), helper(), alarm_factory(), writer, /* owns_writer= */ false, Perspective::IS_CLIENT, client_supported_versions)); if (connection_debug_visitor_ != nullptr) { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h index 4df3a2bb927..ce2444ce925 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h @@ -10,14 +10,14 @@ #include <string> +#include "absl/base/attributes.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" #include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" #include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_macros.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -104,12 +104,12 @@ class QuicClientBase { // Wait for 1-RTT keys become available. // Returns true once 1-RTT keys are available, false otherwise. - QUIC_MUST_USE_RESULT bool WaitForOneRttKeysAvailable(); + ABSL_MUST_USE_RESULT bool WaitForOneRttKeysAvailable(); // Wait for handshake state proceeds to HANDSHAKE_CONFIRMED. // In QUIC crypto, this does the same as WaitForOneRttKeysAvailable, while in // TLS, this waits for HANDSHAKE_DONE frame is received. - QUIC_MUST_USE_RESULT bool WaitForHandshakeConfirmed(); + ABSL_MUST_USE_RESULT bool WaitForHandshakeConfirmed(); // Wait up to 50ms, and handle any events which occur. // Returns true if there are any outstanding requests. @@ -227,7 +227,7 @@ class QuicClientBase { bool initialized() const { return initialized_; } - void SetPreSharedKey(quiche::QuicheStringPiece key) { + void SetPreSharedKey(absl::string_view key) { crypto_config_.set_pre_shared_key(key); } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc index 80dfd3b2139..e16afe686cf 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc @@ -52,6 +52,8 @@ enum class Feature { // Second row of features (anything else protocol-related) // We switched to a different port and the server migrated to it. kRebinding, + // One endpoint can update keys and its peer responds correctly. + kKeyUpdate, // Third row of features (H3 tests) // An H3 transaction succeeded. @@ -81,6 +83,8 @@ char MatrixLetter(Feature f) { return 'Q'; case Feature::kRebinding: return 'B'; + case Feature::kKeyUpdate: + return 'U'; case Feature::kHttp3: return '3'; case Feature::kDynamicEntryReferenced: @@ -107,15 +111,16 @@ class QuicClientInteropRunner : QuicConnectionDebugVisitor { ParsedQuicVersion version, bool test_version_negotiation, bool attempt_rebind, - bool attempt_multi_packet_chlo); + bool attempt_multi_packet_chlo, + bool attempt_key_update); // Constructs a SpdyHeaderBlock containing the pseudo-headers needed to make a // GET request to "/" on the hostname |authority|. - spdy::SpdyHeaderBlock ConstructHeaderBlock(const std::string& authority); + spdy::Http2HeaderBlock ConstructHeaderBlock(const std::string& authority); // Sends an HTTP request represented by |header_block| using |client|. void SendRequest(QuicClient* client, - const spdy::SpdyHeaderBlock& header_block); + const spdy::Http2HeaderBlock& header_block); void OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override { switch (frame.close_type) { @@ -165,7 +170,7 @@ void QuicClientInteropRunner::AttemptResumption(QuicClient* client, bool zero_rtt_attempt = !client->session()->OneRttKeysAvailable(); - spdy::SpdyHeaderBlock header_block = ConstructHeaderBlock(authority); + spdy::Http2HeaderBlock header_block = ConstructHeaderBlock(authority); SendRequest(client, header_block); if (!client->session()->OneRttKeysAvailable()) { @@ -191,7 +196,8 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, ParsedQuicVersion version, bool test_version_negotiation, bool attempt_rebind, - bool attempt_multi_packet_chlo) { + bool attempt_multi_packet_chlo, + bool attempt_key_update) { ParsedQuicVersionVector versions = {version}; if (test_version_negotiation) { versions.insert(versions.begin(), QuicVersionReservedForNegotiation()); @@ -238,7 +244,7 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, // Failed to negotiate version, retry without version negotiation. AttemptRequest(addr, authority, server_id, version, /*test_version_negotiation=*/false, attempt_rebind, - attempt_multi_packet_chlo); + attempt_multi_packet_chlo, attempt_key_update); return; } if (!client->session()->OneRttKeysAvailable()) { @@ -246,7 +252,7 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, // Failed to handshake with multi-packet client hello, retry without it. AttemptRequest(addr, authority, server_id, version, test_version_negotiation, attempt_rebind, - /*attempt_multi_packet_chlo=*/false); + /*attempt_multi_packet_chlo=*/false, attempt_key_update); return; } return; @@ -256,7 +262,7 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, InsertFeature(Feature::kQuantum); } - spdy::SpdyHeaderBlock header_block = ConstructHeaderBlock(authority); + spdy::Http2HeaderBlock header_block = ConstructHeaderBlock(authority); SendRequest(client.get(), header_block); if (!client->connected()) { @@ -278,7 +284,7 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, // Rebinding does not work, retry without attempting it. AttemptRequest(addr, authority, server_id, version, test_version_negotiation, /*attempt_rebind=*/false, - attempt_multi_packet_chlo); + attempt_multi_packet_chlo, attempt_key_update); return; } InsertFeature(Feature::kRebinding); @@ -290,6 +296,28 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, QUIC_LOG(ERROR) << "Failed to change ephemeral port"; } } + + if (attempt_key_update) { + if (connection->IsKeyUpdateAllowed()) { + if (connection->InitiateKeyUpdate( + KeyUpdateReason::kLocalForInteropRunner)) { + client->SendRequestAndWaitForResponse(header_block, "", /*fin=*/true); + if (!client->connected()) { + // Key update does not work, retry without attempting it. + AttemptRequest(addr, authority, server_id, version, + test_version_negotiation, attempt_rebind, + attempt_multi_packet_chlo, + /*attempt_key_update=*/false); + return; + } + InsertFeature(Feature::kKeyUpdate); + } else { + QUIC_LOG(ERROR) << "Failed to initiate key update"; + } + } else { + QUIC_LOG(ERROR) << "Key update not allowed"; + } + } } if (connection->connected()) { @@ -302,10 +330,10 @@ void QuicClientInteropRunner::AttemptRequest(QuicSocketAddress addr, AttemptResumption(client.get(), authority); } -spdy::SpdyHeaderBlock QuicClientInteropRunner::ConstructHeaderBlock( +spdy::Http2HeaderBlock QuicClientInteropRunner::ConstructHeaderBlock( const std::string& authority) { // Construct and send a request. - spdy::SpdyHeaderBlock header_block; + spdy::Http2HeaderBlock header_block; header_block[":method"] = "GET"; header_block[":scheme"] = "https"; header_block[":authority"] = authority; @@ -315,7 +343,7 @@ spdy::SpdyHeaderBlock QuicClientInteropRunner::ConstructHeaderBlock( void QuicClientInteropRunner::SendRequest( QuicClient* client, - const spdy::SpdyHeaderBlock& header_block) { + const spdy::Http2HeaderBlock& header_block) { client->set_store_response(true); client->SendRequestAndWaitForResponse(header_block, "", /*fin=*/true); @@ -368,7 +396,8 @@ std::set<Feature> ServerSupport(std::string dns_host, runner.AttemptRequest(addr, authority, server_id, version, /*test_version_negotiation=*/true, /*attempt_rebind=*/true, - /*attempt_multi_packet_chlo=*/true); + /*attempt_multi_packet_chlo=*/true, + /*attempt_key_update=*/true); return runner.features(); } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc index b1923b67c7c..034c4dda6ca 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc @@ -10,13 +10,14 @@ #include <memory> #include <utility> +#include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" #include "net/third_party/quiche/src/quic/platform/api/quic_port_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test_loopback.h" #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/quic_client_peer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -40,13 +41,13 @@ size_t NumOpenSocketFDs() { std::unique_ptr<DIR, int (*)(DIR*)> fd_directory(opendir(kPathToFds), closedir); while ((file = readdir(fd_directory.get())) != nullptr) { - quiche::QuicheStringPiece name(file->d_name); + absl::string_view name(file->d_name); if (name == "." || name == "..") { continue; } std::string fd_path = ReadLink(quiche::QuicheStrCat(kPathToFds, "/", name)); - if (quiche::QuicheTextUtils::StartsWith(fd_path, "socket:")) { + if (absl::StartsWith(fd_path, "socket:")) { socket_count++; } } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc index 370eb4aaedb..465e0a9f8bc 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc @@ -6,16 +6,18 @@ #include <utility> +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +using spdy::Http2HeaderBlock; using spdy::kV3LowestPriority; -using spdy::SpdyHeaderBlock; namespace quic { @@ -40,7 +42,7 @@ void QuicMemoryCacheBackend::ResourceFile::Read() { if (file_contents_[pos - 1] == '\r') { len -= 1; } - quiche::QuicheStringPiece line(file_contents_.data() + start, len); + absl::string_view line(file_contents_.data() + start, len); start = pos + 1; // Headers end with an empty line. if (line.empty()) { @@ -83,30 +85,29 @@ void QuicMemoryCacheBackend::ResourceFile::Read() { // stuff as described in https://w3c.github.io/preload/. it = spdy_headers_.find("x-push-url"); if (it != spdy_headers_.end()) { - quiche::QuicheStringPiece push_urls = it->second; + absl::string_view push_urls = it->second; size_t start = 0; while (start < push_urls.length()) { size_t pos = push_urls.find('\0', start); if (pos == std::string::npos) { - push_urls_.push_back(quiche::QuicheStringPiece( - push_urls.data() + start, push_urls.length() - start)); + push_urls_.push_back(absl::string_view(push_urls.data() + start, + push_urls.length() - start)); break; } - push_urls_.push_back( - quiche::QuicheStringPiece(push_urls.data() + start, pos)); + push_urls_.push_back(absl::string_view(push_urls.data() + start, pos)); start += pos + 1; } } - body_ = quiche::QuicheStringPiece(file_contents_.data() + start, - file_contents_.size() - start); + body_ = absl::string_view(file_contents_.data() + start, + file_contents_.size() - start); } void QuicMemoryCacheBackend::ResourceFile::SetHostPathFromBase( - quiche::QuicheStringPiece base) { + absl::string_view base) { DCHECK(base[0] != '/') << base; size_t path_start = base.find_first_of('/'); - if (path_start == quiche::QuicheStringPiece::npos) { + if (path_start == absl::string_view::npos) { host_ = std::string(base); path_ = ""; return; @@ -121,33 +122,32 @@ void QuicMemoryCacheBackend::ResourceFile::SetHostPathFromBase( } } -quiche::QuicheStringPiece QuicMemoryCacheBackend::ResourceFile::RemoveScheme( - quiche::QuicheStringPiece url) { - if (quiche::QuicheTextUtils::StartsWith(url, "https://")) { +absl::string_view QuicMemoryCacheBackend::ResourceFile::RemoveScheme( + absl::string_view url) { + if (absl::StartsWith(url, "https://")) { url.remove_prefix(8); - } else if (quiche::QuicheTextUtils::StartsWith(url, "http://")) { + } else if (absl::StartsWith(url, "http://")) { url.remove_prefix(7); } return url; } void QuicMemoryCacheBackend::ResourceFile::HandleXOriginalUrl() { - quiche::QuicheStringPiece url(x_original_url_); + absl::string_view url(x_original_url_); SetHostPathFromBase(RemoveScheme(url)); } const QuicBackendResponse* QuicMemoryCacheBackend::GetResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path) const { + absl::string_view host, + absl::string_view path) const { QuicWriterMutexLock lock(&response_mutex_); auto it = responses_.find(GetKey(host, path)); if (it == responses_.end()) { uint64_t ignored = 0; if (generate_bytes_response_) { - if (quiche::QuicheTextUtils::StringToUint64( - quiche::QuicheStringPiece(path.data() + 1, path.size() - 1), - &ignored)) { + if (absl::SimpleAtoi(absl::string_view(path.data() + 1, path.size() - 1), + &ignored)) { // The actual parsed length is ignored here and will be recomputed // by the caller. return generate_bytes_response_.get(); @@ -163,14 +163,14 @@ const QuicBackendResponse* QuicMemoryCacheBackend::GetResponse( return it->second.get(); } -typedef QuicBackendResponse::ServerPushInfo ServerPushInfo; -typedef QuicBackendResponse::SpecialResponseType SpecialResponseType; +using ServerPushInfo = QuicBackendResponse::ServerPushInfo; +using SpecialResponseType = QuicBackendResponse::SpecialResponseType; -void QuicMemoryCacheBackend::AddSimpleResponse(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, +void QuicMemoryCacheBackend::AddSimpleResponse(absl::string_view host, + absl::string_view path, int response_code, - quiche::QuicheStringPiece body) { - SpdyHeaderBlock response_headers; + absl::string_view body) { + Http2HeaderBlock response_headers; response_headers[":status"] = quiche::QuicheTextUtils::Uint64ToString(response_code); response_headers["content-length"] = @@ -179,10 +179,10 @@ void QuicMemoryCacheBackend::AddSimpleResponse(quiche::QuicheStringPiece host, } void QuicMemoryCacheBackend::AddSimpleResponseWithServerPushResources( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + absl::string_view host, + absl::string_view path, int response_code, - quiche::QuicheStringPiece body, + absl::string_view body, std::list<ServerPushInfo> push_resources) { AddSimpleResponse(host, path, response_code, body); MaybeAddServerPushResources(host, path, push_resources); @@ -193,43 +193,41 @@ void QuicMemoryCacheBackend::AddDefaultResponse(QuicBackendResponse* response) { default_response_.reset(response); } -void QuicMemoryCacheBackend::AddResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, - SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body) { +void QuicMemoryCacheBackend::AddResponse(absl::string_view host, + absl::string_view path, + Http2HeaderBlock response_headers, + absl::string_view response_body) { AddResponseImpl(host, path, QuicBackendResponse::REGULAR_RESPONSE, std::move(response_headers), response_body, - SpdyHeaderBlock()); + Http2HeaderBlock()); } -void QuicMemoryCacheBackend::AddResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, - SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body, - SpdyHeaderBlock response_trailers) { +void QuicMemoryCacheBackend::AddResponse(absl::string_view host, + absl::string_view path, + Http2HeaderBlock response_headers, + absl::string_view response_body, + Http2HeaderBlock response_trailers) { AddResponseImpl(host, path, QuicBackendResponse::REGULAR_RESPONSE, std::move(response_headers), response_body, std::move(response_trailers)); } void QuicMemoryCacheBackend::AddSpecialResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + absl::string_view host, + absl::string_view path, SpecialResponseType response_type) { - AddResponseImpl(host, path, response_type, SpdyHeaderBlock(), "", - SpdyHeaderBlock()); + AddResponseImpl(host, path, response_type, Http2HeaderBlock(), "", + Http2HeaderBlock()); } void QuicMemoryCacheBackend::AddSpecialResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, - spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body, + absl::string_view host, + absl::string_view path, + spdy::Http2HeaderBlock response_headers, + absl::string_view response_body, SpecialResponseType response_type) { AddResponseImpl(host, path, response_type, std::move(response_headers), - response_body, SpdyHeaderBlock()); + response_body, Http2HeaderBlock()); } QuicMemoryCacheBackend::QuicMemoryCacheBackend() : cache_initialized_(false) {} @@ -294,7 +292,7 @@ bool QuicMemoryCacheBackend::InitializeBackend( void QuicMemoryCacheBackend::GenerateDynamicResponses() { QuicWriterMutexLock lock(&response_mutex_); // Add a generate bytes response. - spdy::SpdyHeaderBlock response_headers; + spdy::Http2HeaderBlock response_headers; response_headers[":status"] = "200"; generate_bytes_response_ = std::make_unique<QuicBackendResponse>(); generate_bytes_response_->set_headers(std::move(response_headers)); @@ -307,7 +305,7 @@ bool QuicMemoryCacheBackend::IsBackendInitialized() const { } void QuicMemoryCacheBackend::FetchResponseFromBackend( - const SpdyHeaderBlock& request_headers, + const Http2HeaderBlock& request_headers, const std::string& /*request_body*/, QuicSimpleServerBackend::RequestHandler* quic_stream) { const QuicBackendResponse* quic_response = nullptr; @@ -353,12 +351,12 @@ QuicMemoryCacheBackend::~QuicMemoryCacheBackend() { } void QuicMemoryCacheBackend::AddResponseImpl( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + absl::string_view host, + absl::string_view path, SpecialResponseType response_type, - SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body, - SpdyHeaderBlock response_trailers) { + Http2HeaderBlock response_headers, + absl::string_view response_body, + Http2HeaderBlock response_trailers) { QuicWriterMutexLock lock(&response_mutex_); DCHECK(!host.empty()) << "Host must be populated, e.g. \"www.google.com\""; @@ -376,9 +374,8 @@ void QuicMemoryCacheBackend::AddResponseImpl( responses_[key] = std::move(new_response); } -std::string QuicMemoryCacheBackend::GetKey( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path) const { +std::string QuicMemoryCacheBackend::GetKey(absl::string_view host, + absl::string_view path) const { std::string host_string = std::string(host); size_t port = host_string.find(':'); if (port != std::string::npos) @@ -387,8 +384,8 @@ std::string QuicMemoryCacheBackend::GetKey( } void QuicMemoryCacheBackend::MaybeAddServerPushResources( - quiche::QuicheStringPiece request_host, - quiche::QuicheStringPiece request_path, + absl::string_view request_host, + absl::string_view request_path, std::list<ServerPushInfo> push_resources) { std::string request_url = GetKey(request_host, request_path); @@ -418,7 +415,7 @@ void QuicMemoryCacheBackend::MaybeAddServerPushResources( } if (!found_existing_response) { // Add a server push response to responses map, if it is not in the map. - quiche::QuicheStringPiece body = push_resource.body; + absl::string_view body = push_resource.body; QUIC_DVLOG(1) << "Add response for push resource: host " << host << " path " << path; AddResponse(host, path, push_resource.headers.Clone(), body); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h index 1c56ce6355e..e43bf60f823 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h @@ -10,13 +10,13 @@ #include <memory> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" #include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" #include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" namespace quic { @@ -40,32 +40,30 @@ class QuicMemoryCacheBackend : public QuicSimpleServerBackend { void Read(); // |base| is |file_name_| with |cache_directory| prefix stripped. - void SetHostPathFromBase(quiche::QuicheStringPiece base); + void SetHostPathFromBase(absl::string_view base); const std::string& file_name() { return file_name_; } - quiche::QuicheStringPiece host() { return host_; } + absl::string_view host() { return host_; } - quiche::QuicheStringPiece path() { return path_; } + absl::string_view path() { return path_; } - const spdy::SpdyHeaderBlock& spdy_headers() { return spdy_headers_; } + const spdy::Http2HeaderBlock& spdy_headers() { return spdy_headers_; } - quiche::QuicheStringPiece body() { return body_; } + absl::string_view body() { return body_; } - const std::vector<quiche::QuicheStringPiece>& push_urls() { - return push_urls_; - } + const std::vector<absl::string_view>& push_urls() { return push_urls_; } private: void HandleXOriginalUrl(); - quiche::QuicheStringPiece RemoveScheme(quiche::QuicheStringPiece url); + absl::string_view RemoveScheme(absl::string_view url); std::string file_name_; std::string file_contents_; - quiche::QuicheStringPiece body_; - spdy::SpdyHeaderBlock spdy_headers_; - quiche::QuicheStringPiece x_original_url_; - std::vector<quiche::QuicheStringPiece> push_urls_; + absl::string_view body_; + spdy::Http2HeaderBlock spdy_headers_; + absl::string_view x_original_url_; + std::vector<absl::string_view> push_urls_; std::string host_; std::string path_; }; @@ -77,51 +75,51 @@ class QuicMemoryCacheBackend : public QuicSimpleServerBackend { // Retrieve a response from this cache for a given host and path.. // If no appropriate response exists, nullptr is returned. - const QuicBackendResponse* GetResponse(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path) const; + const QuicBackendResponse* GetResponse(absl::string_view host, + absl::string_view path) const; // Adds a simple response to the cache. The response headers will // only contain the "content-length" header with the length of |body|. - void AddSimpleResponse(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + void AddSimpleResponse(absl::string_view host, + absl::string_view path, int response_code, - quiche::QuicheStringPiece body); + absl::string_view body); // Add a simple response to the cache as AddSimpleResponse() does, and add // some server push resources(resource path, corresponding response status and // path) associated with it. // Push resource implicitly come from the same host. void AddSimpleResponseWithServerPushResources( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + absl::string_view host, + absl::string_view path, int response_code, - quiche::QuicheStringPiece body, + absl::string_view body, std::list<QuicBackendResponse::ServerPushInfo> push_resources); // Add a response to the cache. - void AddResponse(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, - spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body); + void AddResponse(absl::string_view host, + absl::string_view path, + spdy::Http2HeaderBlock response_headers, + absl::string_view response_body); // Add a response, with trailers, to the cache. - void AddResponse(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, - spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body, - spdy::SpdyHeaderBlock response_trailers); + void AddResponse(absl::string_view host, + absl::string_view path, + spdy::Http2HeaderBlock response_headers, + absl::string_view response_body, + spdy::Http2HeaderBlock response_trailers); // Simulate a special behavior at a particular path. void AddSpecialResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + absl::string_view host, + absl::string_view path, QuicBackendResponse::SpecialResponseType response_type); void AddSpecialResponse( - quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, - spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body, + absl::string_view host, + absl::string_view path, + spdy::Http2HeaderBlock response_headers, + absl::string_view response_body, QuicBackendResponse::SpecialResponseType response_type); // Sets a default response in case of cache misses. Takes ownership of @@ -141,28 +139,27 @@ class QuicMemoryCacheBackend : public QuicSimpleServerBackend { bool InitializeBackend(const std::string& cache_directory) override; bool IsBackendInitialized() const override; void FetchResponseFromBackend( - const spdy::SpdyHeaderBlock& request_headers, + const spdy::Http2HeaderBlock& request_headers, const std::string& request_body, QuicSimpleServerBackend::RequestHandler* quic_server_stream) override; void CloseBackendResponseStream( QuicSimpleServerBackend::RequestHandler* quic_server_stream) override; private: - void AddResponseImpl(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path, + void AddResponseImpl(absl::string_view host, + absl::string_view path, QuicBackendResponse::SpecialResponseType response_type, - spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece response_body, - spdy::SpdyHeaderBlock response_trailers); + spdy::Http2HeaderBlock response_headers, + absl::string_view response_body, + spdy::Http2HeaderBlock response_trailers); - std::string GetKey(quiche::QuicheStringPiece host, - quiche::QuicheStringPiece path) const; + std::string GetKey(absl::string_view host, absl::string_view path) const; // Add some server push urls with given responses for specified // request if these push resources are not associated with this request yet. void MaybeAddServerPushResources( - quiche::QuicheStringPiece request_host, - quiche::QuicheStringPiece request_path, + absl::string_view request_host, + absl::string_view request_path, std::list<QuicBackendResponse::ServerPushInfo> push_resources); // Check if push resource(push_host/push_path) associated with given request diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc index e4b8d8e1f38..5940baaf849 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc @@ -4,6 +4,7 @@ #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" +#include "absl/strings/match.h" #include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" @@ -15,15 +16,15 @@ namespace quic { namespace test { namespace { -typedef QuicBackendResponse Response; -typedef QuicBackendResponse::ServerPushInfo ServerPushInfo; +using Response = QuicBackendResponse; +using ServerPushInfo = QuicBackendResponse::ServerPushInfo; } // namespace class QuicMemoryCacheBackendTest : public QuicTest { protected: void CreateRequest(std::string host, std::string path, - spdy::SpdyHeaderBlock* headers) { + spdy::Http2HeaderBlock* headers) { (*headers)[":method"] = "GET"; (*headers)[":path"] = path; (*headers)[":authority"] = host; @@ -45,7 +46,7 @@ TEST_F(QuicMemoryCacheBackendTest, AddSimpleResponseGetResponse) { std::string response_body("hello response"); cache_.AddSimpleResponse("www.google.com", "/", 200, response_body); - spdy::SpdyHeaderBlock request_headers; + spdy::Http2HeaderBlock request_headers; CreateRequest("www.google.com", "/", &request_headers); const Response* response = cache_.GetResponse("www.google.com", "/"); ASSERT_TRUE(response); @@ -59,12 +60,12 @@ TEST_F(QuicMemoryCacheBackendTest, AddResponse) { const std::string kRequestPath = "/"; const std::string kResponseBody("hello response"); - spdy::SpdyHeaderBlock response_headers; + spdy::Http2HeaderBlock response_headers; response_headers[":status"] = "200"; response_headers["content-length"] = quiche::QuicheTextUtils::Uint64ToString(kResponseBody.size()); - spdy::SpdyHeaderBlock response_trailers; + spdy::Http2HeaderBlock response_trailers; response_trailers["key-1"] = "value-1"; response_trailers["key-2"] = "value-2"; response_trailers["key-3"] = "value-3"; @@ -123,7 +124,7 @@ TEST_F(QuicMemoryCacheBackendTest, UsesOriginalUrlOnly) { std::string dir; std::string path = "map.html"; for (const std::string& file : ReadFileContents(CacheDirectory())) { - if (quiche::QuicheTextUtils::EndsWithIgnoreCase(file, "map.html")) { + if (absl::EndsWithIgnoreCase(file, "map.html")) { dir = file; dir.erase(dir.length() - path.length() - 1); break; @@ -148,7 +149,7 @@ TEST_F(QuicMemoryCacheBackendTest, DefaultResponse) { ASSERT_FALSE(response); // Add a default response. - spdy::SpdyHeaderBlock response_headers; + spdy::Http2HeaderBlock response_headers; response_headers[":status"] = "200"; response_headers["content-length"] = "0"; Response* default_response = new Response; @@ -189,7 +190,7 @@ TEST_F(QuicMemoryCacheBackendTest, AddSimpleResponseWithServerPushResources) { QuicUrl resource_url(url); std::string body = quiche::QuicheStrCat("This is server push response body for ", path); - spdy::SpdyHeaderBlock response_headers; + spdy::Http2HeaderBlock response_headers; response_headers[":status"] = "200"; response_headers["content-length"] = quiche::QuicheTextUtils::Uint64ToString(body.size()); @@ -228,7 +229,7 @@ TEST_F(QuicMemoryCacheBackendTest, GetServerPushResourcesAndPushResponses) { std::string url = scheme + "://" + request_host + path; QuicUrl resource_url(url); std::string body = "This is server push response body for " + path; - spdy::SpdyHeaderBlock response_headers; + spdy::Http2HeaderBlock response_headers; response_headers[":status"] = push_response_status[i]; response_headers["content-length"] = quiche::QuicheTextUtils::Uint64ToString(body.size()); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc index 3efeddec2fb..cfe0b8d0d8c 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc @@ -32,7 +32,8 @@ #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "absl/strings/string_view.h" +#include "absl/strings/escaping.h" DEFINE_QUIC_COMMAND_LINE_FLAG(std::string, quic_version, @@ -65,9 +66,9 @@ class QuicPacketPrinter : public QuicFramerVisitorInterface { } void OnRetryPacket(QuicConnectionId /*original_connection_id*/, QuicConnectionId /*new_connection_id*/, - quiche::QuicheStringPiece /*retry_token*/, - quiche::QuicheStringPiece /*retry_integrity_tag*/, - quiche::QuicheStringPiece /*retry_without_tag*/) override { + absl::string_view /*retry_token*/, + absl::string_view /*retry_integrity_tag*/, + absl::string_view /*retry_without_tag*/) override { std::cerr << "OnRetryPacket\n"; } bool OnUnauthenticatedPublicHeader( @@ -99,16 +100,16 @@ class QuicPacketPrinter : public QuicFramerVisitorInterface { bool OnStreamFrame(const QuicStreamFrame& frame) override { std::cerr << "OnStreamFrame: " << frame; std::cerr << " data: { " - << quiche::QuicheTextUtils::HexEncode(frame.data_buffer, - frame.data_length) + << absl::BytesToHexString( + absl::string_view(frame.data_buffer, frame.data_length)) << " }\n"; return true; } bool OnCryptoFrame(const QuicCryptoFrame& frame) override { std::cerr << "OnCryptoFrame: " << frame; std::cerr << " data: { " - << quiche::QuicheTextUtils::HexEncode(frame.data_buffer, - frame.data_length) + << absl::BytesToHexString( + absl::string_view(frame.data_buffer, frame.data_length)) << " }\n"; return true; } @@ -220,6 +221,21 @@ class QuicPacketPrinter : public QuicFramerVisitorInterface { const QuicIetfStatelessResetPacket& /*packet*/) override { std::cerr << "OnAuthenticatedIetfStatelessResetPacket\n"; } + void OnKeyUpdate(KeyUpdateReason reason) override { + std::cerr << "OnKeyUpdate: " << reason << "\n"; + } + void OnDecryptedFirstPacketInKeyPhase() override { + std::cerr << "OnDecryptedFirstPacketInKeyPhase\n"; + } + std::unique_ptr<QuicDecrypter> AdvanceKeysAndCreateCurrentOneRttDecrypter() + override { + std::cerr << "AdvanceKeysAndCreateCurrentOneRttDecrypter\n"; + return nullptr; + } + std::unique_ptr<QuicEncrypter> CreateCurrentOneRttEncrypter() override { + std::cerr << "CreateCurrentOneRttEncrypter\n"; + return nullptr; + } private: QuicFramer* framer_; // Unowned. @@ -248,7 +264,7 @@ int main(int argc, char* argv[]) { quic::QuicPrintCommandLineFlagHelp(usage); return 1; } - std::string hex = quiche::QuicheTextUtils::HexDecode(args[1]); + std::string hex = absl::HexStringToBytes(args[1]); quic::ParsedQuicVersionVector versions = quic::AllSupportedVersions(); // Fake a time since we're not actually generating acks. quic::QuicTime start(quic::QuicTime::Zero()); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc index f7e3b75eaac..f17cd031715 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc @@ -7,6 +7,7 @@ #include <iostream> +#include "absl/strings/numbers.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" @@ -27,7 +28,7 @@ int main(int argc, char* argv[]) { } uint32_t packed_error = 0; - if (!quiche::QuicheTextUtils::StringToUint32(args[0], &packed_error)) { + if (!absl::SimpleAtoi(args[0], &packed_error)) { std::cerr << "Unable to parse: " << args[0] << "\n"; return 2; } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_server.h b/chromium/net/third_party/quiche/src/quic/tools/quic_server.h index 6059ea08746..bf1555ce3ef 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_server.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_server.h @@ -13,6 +13,7 @@ #include <memory> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" #include "net/third_party/quiche/src/quic/core/quic_config.h" #include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" @@ -24,7 +25,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -81,7 +81,7 @@ class QuicServer : public QuicSpdyServerBase, crypto_config_.set_chlo_multiplier(multiplier); } - void SetPreSharedKey(quiche::QuicheStringPiece key) { + void SetPreSharedKey(absl::string_view key) { crypto_config_.set_pre_shared_key(key); } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc index 3c4372018fb..06aa105dd78 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc @@ -4,6 +4,7 @@ #include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "absl/base/macros.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" #include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" @@ -19,7 +20,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" namespace quic { namespace test { @@ -136,9 +136,9 @@ TEST_F(QuicServerEpollInTest, ProcessBufferedCHLOsOnEpollin) { ASSERT_LT(0, fd); char buf[1024]; - memset(buf, 0, QUICHE_ARRAYSIZE(buf)); + memset(buf, 0, ABSL_ARRAYSIZE(buf)); sockaddr_storage storage = server_address_.generic_address(); - int rc = sendto(fd, buf, QUICHE_ARRAYSIZE(buf), 0, + int rc = sendto(fd, buf, ABSL_ARRAYSIZE(buf), 0, reinterpret_cast<sockaddr*>(&storage), sizeof(storage)); if (rc < 0) { QUIC_DLOG(INFO) << errno << " " << strerror(errno); @@ -202,7 +202,7 @@ TEST_F(QuicServerDispatchPacketTest, DispatchPacket) { }; // clang-format on QuicReceivedPacket encrypted_valid_packet( - reinterpret_cast<char*>(valid_packet), QUICHE_ARRAYSIZE(valid_packet), + reinterpret_cast<char*>(valid_packet), ABSL_ARRAYSIZE(valid_packet), QuicTime::Zero(), false); EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc index eb06dd5a0f0..95d507155d5 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc @@ -4,8 +4,8 @@ #include "net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -50,15 +50,16 @@ void QuicSimpleDispatcher::OnRstStreamReceived( std::unique_ptr<QuicSession> QuicSimpleDispatcher::CreateQuicSession( QuicConnectionId connection_id, - const QuicSocketAddress& /*self_address*/, + const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, - quiche::QuicheStringPiece /*alpn*/, + absl::string_view /*alpn*/, const ParsedQuicVersion& version) { // The QuicServerSessionBase takes ownership of |connection| below. - QuicConnection* connection = new QuicConnection( - connection_id, peer_address, helper(), alarm_factory(), writer(), - /* owns_writer= */ false, Perspective::IS_SERVER, - ParsedQuicVersionVector{version}); + QuicConnection* connection = + new QuicConnection(connection_id, self_address, peer_address, helper(), + alarm_factory(), writer(), + /* owns_writer= */ false, Perspective::IS_SERVER, + ParsedQuicVersionVector{version}); auto session = std::make_unique<QuicSimpleServerSession>( config(), GetSupportedVersions(), connection, this, session_helper(), diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h index c01359d8498..d213814e295 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_DISPATCHER_H_ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_DISPATCHER_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" #include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -35,7 +35,7 @@ class QuicSimpleDispatcher : public QuicDispatcher { QuicConnectionId connection_id, const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, - quiche::QuicheStringPiece alpn, + absl::string_view alpn, const ParsedQuicVersion& version) override; QuicSimpleServerBackend* server_backend() { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h index 968ec66dd09..fad30415a37 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h @@ -7,10 +7,7 @@ #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" - -namespace spdy { -class SpdyHeaderBlock; -} // namespace spdy +#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" namespace quic { @@ -49,7 +46,7 @@ class QuicSimpleServerBackend { // If the response has to be fetched over the network, the function // asynchronously calls |request_handler| with the HTTP response. virtual void FetchResponseFromBackend( - const spdy::SpdyHeaderBlock& request_headers, + const spdy::Http2HeaderBlock& request_headers, const std::string& request_body, RequestHandler* request_handler) = 0; // Clears the state of the backend instance diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc index 0637109d5c0..72d6259fdff 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc @@ -66,13 +66,13 @@ void QuicSimpleServerSession::PromisePushResources( const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, const spdy::SpdyStreamPrecedence& original_precedence, - const spdy::SpdyHeaderBlock& original_request_headers) { + const spdy::Http2HeaderBlock& original_request_headers) { if (!server_push_enabled()) { return; } for (const QuicBackendResponse::ServerPushInfo& resource : resources) { - spdy::SpdyHeaderBlock headers = SynthesizePushRequestHeaders( + spdy::Http2HeaderBlock headers = SynthesizePushRequestHeaders( request_url, resource, original_request_headers); // TODO(b/136295430): Use sequential push IDs for IETF QUIC. auto new_highest_promised_stream_id = @@ -171,13 +171,13 @@ void QuicSimpleServerSession::HandleRstOnValidNonexistentStream( } } -spdy::SpdyHeaderBlock QuicSimpleServerSession::SynthesizePushRequestHeaders( +spdy::Http2HeaderBlock QuicSimpleServerSession::SynthesizePushRequestHeaders( std::string request_url, QuicBackendResponse::ServerPushInfo resource, - const spdy::SpdyHeaderBlock& original_request_headers) { + const spdy::Http2HeaderBlock& original_request_headers) { QuicUrl push_request_url = resource.request_url; - spdy::SpdyHeaderBlock spdy_headers = original_request_headers.Clone(); + spdy::Http2HeaderBlock spdy_headers = original_request_headers.Clone(); // :authority could be different from original request. spdy_headers[":authority"] = push_request_url.host(); spdy_headers[":path"] = push_request_url.path(); @@ -196,7 +196,7 @@ spdy::SpdyHeaderBlock QuicSimpleServerSession::SynthesizePushRequestHeaders( void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, QuicStreamId promised_stream_id, - spdy::SpdyHeaderBlock headers) { + spdy::Http2HeaderBlock headers) { QUIC_DLOG(INFO) << "stream " << original_stream_id << " send PUSH_PROMISE for promised stream " << promised_stream_id; @@ -226,7 +226,7 @@ void QuicSimpleServerSession::HandlePromisedPushRequests() { promised_stream->SetPriority(promised_info.precedence); - spdy::SpdyHeaderBlock request_headers( + spdy::Http2HeaderBlock request_headers( std::move(promised_info.request_headers)); promised_streams_.pop_front(); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h index 9942c7d80ad..6d1bc81e64c 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h @@ -38,14 +38,14 @@ class QuicSimpleServerSession : public QuicServerSessionBase { // stream id with its priority and the headers sent out in PUSH_PROMISE. struct PromisedStreamInfo { public: - PromisedStreamInfo(spdy::SpdyHeaderBlock request_headers, + PromisedStreamInfo(spdy::Http2HeaderBlock request_headers, QuicStreamId stream_id, const spdy::SpdyStreamPrecedence& precedence) : request_headers(std::move(request_headers)), stream_id(stream_id), precedence(precedence), is_cancelled(false) {} - spdy::SpdyHeaderBlock request_headers; + spdy::Http2HeaderBlock request_headers; QuicStreamId stream_id; spdy::SpdyStreamPrecedence precedence; bool is_cancelled; @@ -77,7 +77,7 @@ class QuicSimpleServerSession : public QuicServerSessionBase { const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, const spdy::SpdyStreamPrecedence& original_precedence, - const spdy::SpdyHeaderBlock& original_request_headers); + const spdy::Http2HeaderBlock& original_request_headers); void OnCanCreateNewOutgoingStream(bool unidirectional) override; @@ -113,15 +113,15 @@ class QuicSimpleServerSession : public QuicServerSessionBase { // :authority, :path, :method, :scheme, referer. // Copying the rest headers ensures they are the same as the original // request, especially cookies. - spdy::SpdyHeaderBlock SynthesizePushRequestHeaders( + spdy::Http2HeaderBlock SynthesizePushRequestHeaders( std::string request_url, QuicBackendResponse::ServerPushInfo resource, - const spdy::SpdyHeaderBlock& original_request_headers); + const spdy::Http2HeaderBlock& original_request_headers); // Send PUSH_PROMISE frame on headers stream. void SendPushPromise(QuicStreamId original_stream_id, QuicStreamId promised_stream_id, - spdy::SpdyHeaderBlock headers); + spdy::Http2HeaderBlock headers); // Fetch response from cache for request headers enqueued into // promised_headers_and_streams_ and send them on dedicated stream until diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc index 780ff9df099..66ee8c4591a 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc @@ -8,6 +8,8 @@ #include <memory> #include <utility> +#include "absl/strings/string_view.h" +#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/core/http/http_encoder.h" @@ -35,7 +37,6 @@ #include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using testing::_; @@ -50,7 +51,7 @@ namespace quic { namespace test { namespace { -typedef QuicSimpleServerSession::PromisedStreamInfo PromisedStreamInfo; +using PromisedStreamInfo = QuicSimpleServerSession::PromisedStreamInfo; const QuicByteCount kHeadersFrameHeaderLength = 2; const QuicByteCount kHeadersFramePayloadLength = 9; @@ -187,11 +188,11 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { crypto_config, compressed_certs_cache, quic_simple_server_backend) {} - // Methods taking non-copyable types like SpdyHeaderBlock by value cannot be + // Methods taking non-copyable types like Http2HeaderBlock by value cannot be // mocked directly. void WritePushPromise(QuicStreamId original_stream_id, QuicStreamId promised_stream_id, - spdy::SpdyHeaderBlock headers) override { + spdy::Http2HeaderBlock headers) override { return WritePushPromiseMock(original_stream_id, promised_stream_id, headers); } @@ -199,10 +200,14 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { WritePushPromiseMock, (QuicStreamId original_stream_id, QuicStreamId promised_stream_id, - const spdy::SpdyHeaderBlock& headers), + const spdy::Http2HeaderBlock& headers), ()); MOCK_METHOD(void, SendBlocked, (QuicStreamId), (override)); + MOCK_METHOD(bool, + WriteControlFrame, + (const QuicFrame& frame, TransmissionType type), + (override)); }; class QuicSimpleServerSessionTest @@ -256,6 +261,9 @@ class QuicSimpleServerSessionTest connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>( &helper_, &alarm_factory_, Perspective::IS_SERVER, supported_versions); connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); + connection_->SetEncrypter( + ENCRYPTION_FORWARD_SECURE, + std::make_unique<NullEncrypter>(connection_->perspective())); session_ = std::make_unique<MockQuicSimpleServerSession>( config_, connection_, &owner_, &stream_helper_, &crypto_config_, &compressed_certs_cache_, &memory_cache_backend_); @@ -266,9 +274,8 @@ class QuicSimpleServerSessionTest session_->Initialize(); if (VersionHasIetfQuicFrames(transport_version())) { - EXPECT_CALL(*connection_, SendControlFrame(_)) - .WillRepeatedly(Invoke( - this, &QuicSimpleServerSessionTest::ClearMaxStreamsControlFrame)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); } session_->OnConfigNegotiated(); } @@ -326,7 +333,7 @@ TEST_P(QuicSimpleServerSessionTest, CloseStreamDueToReset) { // Open a stream, then reset it. // Send two bytes of payload to open it. QuicStreamFrame data1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_->OnStreamFrame(data1); EXPECT_EQ(1u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get())); @@ -335,7 +342,8 @@ TEST_P(QuicSimpleServerSessionTest, CloseStreamDueToReset) { GetNthClientInitiatedBidirectionalId(0), QUIC_ERROR_PROCESSING_STREAM, 0); EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); - EXPECT_CALL(*connection_, SendControlFrame(_)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)); + if (!VersionHasIetfQuicFrames(transport_version())) { // For version 99, this is covered in InjectStopSending() EXPECT_CALL(*connection_, @@ -365,7 +373,7 @@ TEST_P(QuicSimpleServerSessionTest, NeverOpenStreamDueToReset) { QUIC_ERROR_PROCESSING_STREAM, 0); EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); if (!VersionHasIetfQuicFrames(transport_version())) { - EXPECT_CALL(*connection_, SendControlFrame(_)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)); // For version 99, this is covered in InjectStopSending() EXPECT_CALL(*connection_, OnStreamReset(GetNthClientInitiatedBidirectionalId(0), @@ -382,7 +390,7 @@ TEST_P(QuicSimpleServerSessionTest, NeverOpenStreamDueToReset) { // Send two bytes of payload. QuicStreamFrame data1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_->OnStreamFrame(data1); // The stream should never be opened, now that the reset is received. @@ -393,9 +401,9 @@ TEST_P(QuicSimpleServerSessionTest, NeverOpenStreamDueToReset) { TEST_P(QuicSimpleServerSessionTest, AcceptClosedStream) { // Send (empty) compressed headers followed by two bytes of data. QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("\1\0\0\0\0\0\0\0HT")); + absl::string_view("\1\0\0\0\0\0\0\0HT")); QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(1), false, 0, - quiche::QuicheStringPiece("\2\0\0\0\0\0\0\0HT")); + absl::string_view("\3\0\0\0\0\0\0\0HT")); session_->OnStreamFrame(frame1); session_->OnStreamFrame(frame2); EXPECT_EQ(2u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get())); @@ -406,7 +414,7 @@ TEST_P(QuicSimpleServerSessionTest, AcceptClosedStream) { QUIC_ERROR_PROCESSING_STREAM, 0); EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); if (!VersionHasIetfQuicFrames(transport_version())) { - EXPECT_CALL(*connection_, SendControlFrame(_)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)); // For version 99, this is covered in InjectStopSending() EXPECT_CALL(*connection_, OnStreamReset(GetNthClientInitiatedBidirectionalId(0), @@ -423,9 +431,9 @@ TEST_P(QuicSimpleServerSessionTest, AcceptClosedStream) { // past the reset point of stream 3. As it's a closed stream we just drop the // data on the floor, but accept the packet because it has data for stream 5. QuicStreamFrame frame3(GetNthClientInitiatedBidirectionalId(0), false, 2, - quiche::QuicheStringPiece("TP")); + absl::string_view("TP")); QuicStreamFrame frame4(GetNthClientInitiatedBidirectionalId(1), false, 2, - quiche::QuicheStringPiece("TP")); + absl::string_view("TP")); session_->OnStreamFrame(frame3); session_->OnStreamFrame(frame4); // The stream should never be opened, now that the reset is received. @@ -502,7 +510,7 @@ TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUptoLimit) { // Receive some data to initiate a incoming stream which should not effect // creating outgoing streams. QuicStreamFrame data1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_->OnStreamFrame(data1); EXPECT_EQ(1u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get())); EXPECT_EQ(0u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get()) - @@ -551,7 +559,7 @@ TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUptoLimit) { // Create peer initiated stream should have no problem. QuicStreamFrame data2(GetNthClientInitiatedBidirectionalId(1), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_->OnStreamFrame(data2); EXPECT_EQ(2u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get()) - /*outcoming=*/kMaxStreamsForTest); @@ -559,7 +567,7 @@ TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUptoLimit) { TEST_P(QuicSimpleServerSessionTest, OnStreamFrameWithEvenStreamId) { QuicStreamFrame frame(GetNthServerInitiatedUnidirectionalId(0), false, 0, - quiche::QuicheStringPiece()); + absl::string_view()); EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, "Client sent data on server push stream", _)); @@ -622,6 +630,9 @@ class QuicSimpleServerSessionServerPushTest ParsedQuicVersionVector supported_versions = SupportedVersions(GetParam()); connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>( &helper_, &alarm_factory_, Perspective::IS_SERVER, supported_versions); + connection_->SetEncrypter( + ENCRYPTION_FORWARD_SECURE, + std::make_unique<NullEncrypter>(connection_->perspective())); session_ = std::make_unique<MockQuicSimpleServerSession>( config_, connection_, &owner_, &stream_helper_, &crypto_config_, &compressed_certs_cache_, &memory_cache_backend_); @@ -629,9 +640,8 @@ class QuicSimpleServerSessionServerPushTest // Needed to make new session flow control window and server push work. if (VersionHasIetfQuicFrames(transport_version())) { - EXPECT_CALL(*connection_, SendControlFrame(_)) - .WillRepeatedly(Invoke(this, &QuicSimpleServerSessionServerPushTest:: - ClearMaxStreamsControlFrame)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); } session_->OnConfigNegotiated(); @@ -676,7 +686,7 @@ class QuicSimpleServerSessionServerPushTest size_t body_size = 2 * kStreamFlowControlWindowSize; // 64KB. std::string request_url = "mail.google.com/"; - spdy::SpdyHeaderBlock request_headers; + spdy::Http2HeaderBlock request_headers; std::string resource_host = "www.google.com"; std::string partial_push_resource_path = "/server_push_src"; std::list<QuicBackendResponse::ServerPushInfo> push_resources; @@ -708,7 +718,7 @@ class QuicSimpleServerSessionServerPushTest memory_cache_backend_.AddSimpleResponse(resource_host, path, 200, data); push_resources.push_back(QuicBackendResponse::ServerPushInfo( - resource_url, spdy::SpdyHeaderBlock(), QuicStream::kDefaultPriority, + resource_url, spdy::Http2HeaderBlock(), QuicStream::kDefaultPriority, body)); // PUSH_PROMISED are sent for all the resources. EXPECT_CALL(*session_, @@ -881,8 +891,8 @@ TEST_P(QuicSimpleServerSessionServerPushTest, // V99 will send out a STREAMS_BLOCKED frame when it tries to exceed the // limit. This will clear the frames so that they do not block the later // rst-stream frame. - EXPECT_CALL(*connection_, SendControlFrame(_)) - .WillOnce(Invoke(&ClearControlFrame)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .WillOnce(Invoke(&ClearControlFrameWithTransmissionType)); } QuicByteCount data_frame_header_length = PromisePushResources(num_resources); @@ -898,8 +908,8 @@ TEST_P(QuicSimpleServerSessionServerPushTest, QuicRstStreamFrame rst(kInvalidControlFrameId, stream_got_reset, QUIC_STREAM_CANCELLED, 0); EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); - EXPECT_CALL(*connection_, SendControlFrame(_)) - .WillOnce(Invoke(&ClearControlFrame)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .WillOnce(Invoke(&ClearControlFrameWithTransmissionType)); EXPECT_CALL(*connection_, OnStreamReset(stream_got_reset, QUIC_RST_ACKNOWLEDGEMENT)); session_->OnRstStream(rst); @@ -968,8 +978,8 @@ TEST_P(QuicSimpleServerSessionServerPushTest, // V99 will send out a stream-id-blocked frame when the we desired to exceed // the limit. This will clear the frames so that they do not block the later // rst-stream frame. - EXPECT_CALL(*connection_, SendControlFrame(_)) - .WillOnce(Invoke(&ClearControlFrame)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .WillOnce(Invoke(&ClearControlFrameWithTransmissionType)); } QuicByteCount data_frame_header_length = PromisePushResources(num_resources); QuicStreamId stream_to_open; @@ -983,7 +993,7 @@ TEST_P(QuicSimpleServerSessionServerPushTest, // Resetting an open stream will close the stream and give space for extra // stream to be opened. QuicStreamId stream_got_reset = GetNthServerInitiatedUnidirectionalId(3); - EXPECT_CALL(*connection_, SendControlFrame(_)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)); if (!VersionHasIetfQuicFrames(transport_version())) { EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); // For version 99, this is covered in InjectStopSending() diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc index 84ddb055aa7..93b43562842 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc @@ -7,6 +7,8 @@ #include <list> #include <utility> +#include "absl/strings/numbers.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" @@ -15,11 +17,10 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" -using spdy::SpdyHeaderBlock; +using spdy::Http2HeaderBlock; namespace quic { @@ -109,7 +110,7 @@ void QuicSimpleServerStream::OnBodyAvailable() { } void QuicSimpleServerStream::PushResponse( - SpdyHeaderBlock push_request_headers) { + Http2HeaderBlock push_request_headers) { if (QuicUtils::IsClientInitiatedStreamId(session()->transport_version(), id())) { QUIC_BUG << "Client initiated stream shouldn't be used as promised stream."; @@ -208,7 +209,7 @@ void QuicSimpleServerStream::OnResponseBackendComplete( std::string request_url = request_headers_[":authority"].as_string() + request_headers_[":path"].as_string(); int response_code; - const SpdyHeaderBlock& response_headers = response->headers(); + const Http2HeaderBlock& response_headers = response->headers(); if (!ParseHeaderStatusCode(response_headers, &response_code)) { auto status = response_headers.find(":status"); if (status == response_headers.end()) { @@ -257,13 +258,12 @@ void QuicSimpleServerStream::OnResponseBackendComplete( if (response->response_type() == QuicBackendResponse::GENERATE_BYTES) { QUIC_DVLOG(1) << "Stream " << id() << " sending a generate bytes response."; std::string path = request_headers_[":path"].as_string().substr(1); - if (!quiche::QuicheTextUtils::StringToUint64(path, - &generate_bytes_length_)) { + if (!absl::SimpleAtoi(path, &generate_bytes_length_)) { QUIC_LOG(ERROR) << "Path is not a number."; SendNotFoundResponse(); return; } - SpdyHeaderBlock headers = response->headers().Clone(); + Http2HeaderBlock headers = response->headers().Clone(); headers["content-length"] = quiche::QuicheTextUtils::Uint64ToString(generate_bytes_length_); @@ -297,7 +297,7 @@ void QuicSimpleServerStream::WriteGeneratedBytes() { void QuicSimpleServerStream::SendNotFoundResponse() { QUIC_DVLOG(1) << "Stream " << id() << " sending not found response."; - SpdyHeaderBlock headers; + Http2HeaderBlock headers; headers[":status"] = "404"; headers["content-length"] = quiche::QuicheTextUtils::Uint64ToString(strlen(kNotFoundResponseBody)); @@ -310,7 +310,7 @@ void QuicSimpleServerStream::SendErrorResponse() { void QuicSimpleServerStream::SendErrorResponse(int resp_code) { QUIC_DVLOG(1) << "Stream " << id() << " sending error response."; - SpdyHeaderBlock headers; + Http2HeaderBlock headers; if (resp_code <= 0) { headers[":status"] = "500"; } else { @@ -322,8 +322,8 @@ void QuicSimpleServerStream::SendErrorResponse(int resp_code) { } void QuicSimpleServerStream::SendIncompleteResponse( - SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece body) { + Http2HeaderBlock response_headers, + absl::string_view body) { QUIC_DLOG(INFO) << "Stream " << id() << " writing headers (fin = false) : " << response_headers.DebugString(); WriteHeaders(std::move(response_headers), /*fin=*/false, nullptr); @@ -336,16 +336,16 @@ void QuicSimpleServerStream::SendIncompleteResponse( } void QuicSimpleServerStream::SendHeadersAndBody( - SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece body) { + Http2HeaderBlock response_headers, + absl::string_view body) { SendHeadersAndBodyAndTrailers(std::move(response_headers), body, - SpdyHeaderBlock()); + Http2HeaderBlock()); } void QuicSimpleServerStream::SendHeadersAndBodyAndTrailers( - SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece body, - SpdyHeaderBlock response_trailers) { + Http2HeaderBlock response_headers, + absl::string_view body, + Http2HeaderBlock response_trailers) { // Send the headers, with a FIN if there's nothing else to send. bool send_fin = (body.empty() && response_trailers.empty()); QUIC_DLOG(INFO) << "Stream " << id() << " writing headers (fin = " << send_fin diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h index add4a12875d..6b8826cd866 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h @@ -5,11 +5,11 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_STREAM_H_ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_STREAM_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" #include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" namespace quic { @@ -47,7 +47,7 @@ class QuicSimpleServerStream : public QuicSpdyServerStreamBase, // Make this stream start from as if it just finished parsing an incoming // request whose headers are equivalent to |push_request_headers|. // Doing so will trigger this toy stream to fetch response and send it back. - virtual void PushResponse(spdy::SpdyHeaderBlock push_request_headers); + virtual void PushResponse(spdy::Http2HeaderBlock push_request_headers); // The response body of error responses. static const char* const kErrorResponseBody; @@ -76,16 +76,16 @@ class QuicSimpleServerStream : public QuicSpdyServerStreamBase, void SendNotFoundResponse(); // Sends the response header and body, but not the fin. - void SendIncompleteResponse(spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece body); + void SendIncompleteResponse(spdy::Http2HeaderBlock response_headers, + absl::string_view body); - void SendHeadersAndBody(spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece body); - void SendHeadersAndBodyAndTrailers(spdy::SpdyHeaderBlock response_headers, - quiche::QuicheStringPiece body, - spdy::SpdyHeaderBlock response_trailers); + void SendHeadersAndBody(spdy::Http2HeaderBlock response_headers, + absl::string_view body); + void SendHeadersAndBodyAndTrailers(spdy::Http2HeaderBlock response_headers, + absl::string_view body, + spdy::Http2HeaderBlock response_trailers); - spdy::SpdyHeaderBlock* request_headers() { return &request_headers_; } + spdy::Http2HeaderBlock* request_headers() { return &request_headers_; } const std::string& body() { return body_; } @@ -93,7 +93,7 @@ class QuicSimpleServerStream : public QuicSpdyServerStreamBase, void WriteGeneratedBytes(); // The parsed headers received from the client. - spdy::SpdyHeaderBlock request_headers_; + spdy::Http2HeaderBlock request_headers_; int64_t content_length_; std::string body_; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc index f5c1b53dde1..4b21ccaded1 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc @@ -8,8 +8,13 @@ #include <memory> #include <utility> +#include "absl/base/macros.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/http/http_encoder.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" +#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" @@ -26,9 +31,6 @@ #include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_optional.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using testing::_; using testing::AnyNumber; @@ -58,7 +60,7 @@ class TestStream : public QuicSimpleServerStream { MOCK_METHOD(void, WriteHeadersMock, (bool fin), ()); - size_t WriteHeaders(spdy::SpdyHeaderBlock /*header_block*/, + size_t WriteHeaders(spdy::Http2HeaderBlock /*header_block*/, bool fin, QuicReferenceCountedPointer<QuicAckListenerInterface> /*ack_listener*/) override { @@ -70,12 +72,12 @@ class TestStream : public QuicSimpleServerStream { void DoSendResponse() { SendResponse(); } void DoSendErrorResponse() { SendErrorResponse(); } - spdy::SpdyHeaderBlock* mutable_headers() { return &request_headers_; } + spdy::Http2HeaderBlock* mutable_headers() { return &request_headers_; } void set_body(std::string body) { body_ = std::move(body); } const std::string& body() const { return body_; } int content_length() const { return content_length_; } - quiche::QuicheStringPiece GetHeader(quiche::QuicheStringPiece key) const { + absl::string_view GetHeader(absl::string_view key) const { auto it = request_headers_.find(key); DCHECK(it != request_headers_.end()); return it->second; @@ -137,7 +139,7 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { QuicStreamOffset offset, StreamSendingState state, TransmissionType type, - quiche::QuicheOptional<EncryptionLevel> level), + absl::optional<EncryptionLevel> level), (override)); MOCK_METHOD(void, OnStreamHeaderList, @@ -158,13 +160,23 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { QuicStreamOffset bytes_written, bool send_rst_only), (override)); - // Matchers cannot be used on non-copyable types like SpdyHeaderBlock. + MOCK_METHOD(void, + MaybeSendRstStreamFrame, + (QuicStreamId stream_id, + QuicRstStreamErrorCode error, + QuicStreamOffset bytes_written), + (override)); + MOCK_METHOD(void, + MaybeSendStopSendingFrame, + (QuicStreamId stream_id, QuicRstStreamErrorCode error), + (override)); + // Matchers cannot be used on non-copyable types like Http2HeaderBlock. void PromisePushResources( const std::string& request_url, const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, const spdy::SpdyStreamPrecedence& original_precedence, - const spdy::SpdyHeaderBlock& original_request_headers) override { + const spdy::Http2HeaderBlock& original_request_headers) override { original_request_headers_ = original_request_headers.Clone(); PromisePushResourcesMock(request_url, resources, original_stream_id, original_precedence, original_request_headers); @@ -175,18 +187,17 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { const std::list<QuicBackendResponse::ServerPushInfo>&, QuicStreamId, const spdy::SpdyStreamPrecedence&, - const spdy::SpdyHeaderBlock&), + const spdy::Http2HeaderBlock&), ()); using QuicSession::ActivateStream; - QuicConsumedData ConsumeData( - QuicStreamId id, - size_t write_length, - QuicStreamOffset offset, - StreamSendingState state, - TransmissionType /*type*/, - quiche::QuicheOptional<EncryptionLevel> /*level*/) { + QuicConsumedData ConsumeData(QuicStreamId id, + size_t write_length, + QuicStreamOffset offset, + StreamSendingState state, + TransmissionType /*type*/, + absl::optional<EncryptionLevel> /*level*/) { if (write_length > 0) { auto buf = std::make_unique<char[]>(write_length); QuicStream* stream = GetOrCreateStream(id); @@ -199,7 +210,7 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { return QuicConsumedData(write_length, state != NO_FIN); } - spdy::SpdyHeaderBlock original_request_headers_; + spdy::Http2HeaderBlock original_request_headers_; }; class QuicSimpleServerStreamTest : public QuicTestWithParam<ParsedQuicVersion> { @@ -241,6 +252,9 @@ class QuicSimpleServerStreamTest : public QuicTestWithParam<ParsedQuicVersion> { session_.config()->SetInitialSessionFlowControlWindowToSend( kInitialSessionFlowControlWindowForTest); session_.Initialize(); + connection_->SetEncrypter( + quic::ENCRYPTION_FORWARD_SECURE, + std::make_unique<quic::NullEncrypter>(connection_->perspective())); if (connection_->version().SupportsAntiAmplificationLimit()) { QuicConnectionPeer::SetAddressValidated(connection_); } @@ -273,7 +287,7 @@ class QuicSimpleServerStreamTest : public QuicTestWithParam<ParsedQuicVersion> { return VersionUsesHttp3(connection_->transport_version()); } - spdy::SpdyHeaderBlock response_headers_; + spdy::Http2HeaderBlock response_headers_; MockQuicConnectionHelper helper_; MockAlarmFactory alarm_factory_; StrictMock<MockQuicConnection>* connection_; @@ -342,7 +356,18 @@ TEST_P(QuicSimpleServerStreamTest, SendQuicRstStreamNoErrorInStopReading) { QuicStreamPeer::SetFinSent(stream_); stream_->CloseWriteSide(); - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(1); + if (!session_.split_up_send_rst()) { + EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)) + .Times(1); + } else { + if (session_.version().UsesHttp3()) { + EXPECT_CALL(session_, MaybeSendStopSendingFrame(_, QUIC_STREAM_NO_ERROR)) + .Times(1); + } else { + EXPECT_CALL(session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_NO_ERROR, _)) + .Times(1); + } + } stream_->StopReading(); } @@ -384,7 +409,7 @@ TEST_P(QuicSimpleServerStreamTest, TestFramingExtraData) { TEST_P(QuicSimpleServerStreamTest, SendResponseWithIllegalResponseStatus) { // Send an illegal response with response status not supported by HTTP/2. - spdy::SpdyHeaderBlock* request_headers = stream_->mutable_headers(); + spdy::Http2HeaderBlock* request_headers = stream_->mutable_headers(); (*request_headers)[":path"] = "/bar"; (*request_headers)[":authority"] = "www.google.com"; (*request_headers)[":method"] = "GET"; @@ -416,7 +441,7 @@ TEST_P(QuicSimpleServerStreamTest, SendResponseWithIllegalResponseStatus) { TEST_P(QuicSimpleServerStreamTest, SendResponseWithIllegalResponseStatus2) { // Send an illegal response with response status not supported by HTTP/2. - spdy::SpdyHeaderBlock* request_headers = stream_->mutable_headers(); + spdy::Http2HeaderBlock* request_headers = stream_->mutable_headers(); (*request_headers)[":path"] = "/bar"; (*request_headers)[":authority"] = "www.google.com"; (*request_headers)[":method"] = "GET"; @@ -457,7 +482,7 @@ TEST_P(QuicSimpleServerStreamTest, SendPushResponseWith404Response) { // Send a push response with response status 404, which will be regarded as // invalid server push response. - spdy::SpdyHeaderBlock* request_headers = promised_stream->mutable_headers(); + spdy::Http2HeaderBlock* request_headers = promised_stream->mutable_headers(); (*request_headers)[":path"] = "/bar"; (*request_headers)[":authority"] = "www.google.com"; (*request_headers)[":method"] = "GET"; @@ -470,15 +495,23 @@ TEST_P(QuicSimpleServerStreamTest, SendPushResponseWith404Response) { std::move(response_headers_), body); InSequence s; - EXPECT_CALL(session_, SendRstStream(promised_stream->id(), - QUIC_STREAM_CANCELLED, 0, _)); + if (!session_.split_up_send_rst()) { + EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_CANCELLED, 0, _)); + } else { + if (session_.version().UsesHttp3()) { + EXPECT_CALL(session_, MaybeSendStopSendingFrame(promised_stream->id(), + QUIC_STREAM_CANCELLED)); + } + EXPECT_CALL(session_, MaybeSendRstStreamFrame(promised_stream->id(), + QUIC_STREAM_CANCELLED, 0)); + } promised_stream->DoSendResponse(); } TEST_P(QuicSimpleServerStreamTest, SendResponseWithValidHeaders) { // Add a request and response with valid headers. - spdy::SpdyHeaderBlock* request_headers = stream_->mutable_headers(); + spdy::Http2HeaderBlock* request_headers = stream_->mutable_headers(); (*request_headers)[":path"] = "/bar"; (*request_headers)[":authority"] = "www.google.com"; (*request_headers)[":method"] = "GET"; @@ -519,14 +552,14 @@ TEST_P(QuicSimpleServerStreamTest, SendResponseWithPushResources) { QuicByteCount header_length = HttpEncoder::SerializeDataFrameHeader(body.length(), &buffer); QuicBackendResponse::ServerPushInfo push_info( - QuicUrl(host, "/bar"), spdy::SpdyHeaderBlock(), + QuicUrl(host, "/bar"), spdy::Http2HeaderBlock(), QuicStream::kDefaultPriority, "Push body"); std::list<QuicBackendResponse::ServerPushInfo> push_resources; push_resources.push_back(push_info); memory_cache_backend_.AddSimpleResponseWithServerPushResources( host, request_path, 200, body, push_resources); - spdy::SpdyHeaderBlock* request_headers = stream_->mutable_headers(); + spdy::Http2HeaderBlock* request_headers = stream_->mutable_headers(); (*request_headers)[":path"] = request_path; (*request_headers)[":authority"] = host; (*request_headers)[":method"] = "GET"; @@ -555,7 +588,7 @@ TEST_P(QuicSimpleServerStreamTest, PushResponseOnClientInitiatedStream) { // Calling PushResponse() on a client initialted stream is never supposed to // happen. - EXPECT_QUIC_BUG(stream_->PushResponse(spdy::SpdyHeaderBlock()), + EXPECT_QUIC_BUG(stream_->PushResponse(spdy::Http2HeaderBlock()), "Client initiated stream" " shouldn't be used as promised stream."); } @@ -576,7 +609,7 @@ TEST_P(QuicSimpleServerStreamTest, PushResponseOnServerInitiatedStream) { const std::string kHost = "www.foo.com"; const std::string kPath = "/bar"; - spdy::SpdyHeaderBlock headers; + spdy::Http2HeaderBlock headers; headers[":path"] = kPath; headers[":authority"] = kHost; headers[":method"] = "GET"; @@ -627,10 +660,9 @@ TEST_P(QuicSimpleServerStreamTest, TestSendErrorResponse) { TEST_P(QuicSimpleServerStreamTest, InvalidMultipleContentLength) { EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - spdy::SpdyHeaderBlock request_headers; + spdy::Http2HeaderBlock request_headers; // \000 is a way to write the null byte when followed by a literal digit. - header_list_.OnHeader("content-length", - quiche::QuicheStringPiece("11\00012", 5)); + header_list_.OnHeader("content-length", absl::string_view("11\00012", 5)); EXPECT_CALL(*stream_, WriteHeadersMock(false)); EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) @@ -646,10 +678,9 @@ TEST_P(QuicSimpleServerStreamTest, InvalidMultipleContentLength) { TEST_P(QuicSimpleServerStreamTest, InvalidLeadingNullContentLength) { EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - spdy::SpdyHeaderBlock request_headers; + spdy::Http2HeaderBlock request_headers; // \000 is a way to write the null byte when followed by a literal digit. - header_list_.OnHeader("content-length", - quiche::QuicheStringPiece("\00012", 3)); + header_list_.OnHeader("content-length", absl::string_view("\00012", 3)); EXPECT_CALL(*stream_, WriteHeadersMock(false)); EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) @@ -663,10 +694,9 @@ TEST_P(QuicSimpleServerStreamTest, InvalidLeadingNullContentLength) { } TEST_P(QuicSimpleServerStreamTest, ValidMultipleContentLength) { - spdy::SpdyHeaderBlock request_headers; + spdy::Http2HeaderBlock request_headers; // \000 is a way to write the null byte when followed by a literal digit. - header_list_.OnHeader("content-length", - quiche::QuicheStringPiece("11\00011", 5)); + header_list_.OnHeader("content-length", absl::string_view("11\00011", 5)); stream_->OnStreamHeaderList(false, kFakeFrameLen, header_list_); @@ -678,7 +708,6 @@ TEST_P(QuicSimpleServerStreamTest, ValidMultipleContentLength) { TEST_P(QuicSimpleServerStreamTest, DoNotSendQuicRstStreamNoErrorWithRstReceived) { - InSequence s; EXPECT_FALSE(stream_->reading_stopped()); EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); @@ -691,16 +720,33 @@ TEST_P(QuicSimpleServerStreamTest, EXPECT_CALL(session_, WritevData(qpack_decoder_stream->id(), _, _, _, _, _)) .Times(AnyNumber()); } - EXPECT_CALL(session_, SendRstStream(_, QUIC_RST_ACKNOWLEDGEMENT, _, _)) - .Times(1); + + if (!session_.split_up_send_rst()) { + EXPECT_CALL(session_, SendRstStream(_, + session_.version().UsesHttp3() + ? QUIC_STREAM_CANCELLED + : QUIC_RST_ACKNOWLEDGEMENT, + _, _)) + .Times(1); + } else { + EXPECT_CALL(session_, + MaybeSendRstStreamFrame(_, + session_.version().UsesHttp3() + ? QUIC_STREAM_CANCELLED + : QUIC_RST_ACKNOWLEDGEMENT, + _)) + .Times(1); + } QuicRstStreamFrame rst_frame(kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 1234); stream_->OnStreamReset(rst_frame); if (VersionHasIetfQuicFrames(connection_->transport_version())) { - // For V99 receiving a RST_STREAM causes a 1-way close; the test requires - // a full close. A CloseWriteSide closes the other half of the stream. - // Everything should then work properly. - stream_->CloseWriteSide(); + EXPECT_CALL(session_owner_, OnStopSendingReceived(_)); + // Create and inject a STOP SENDING frame to complete the close + // of the stream. This is only needed for version 99/IETF QUIC. + QuicStopSendingFrame stop_sending(kInvalidControlFrameId, stream_->id(), + QUIC_STREAM_CANCELLED); + session_.OnStopSendingFrame(stop_sending); } EXPECT_TRUE(stream_->reading_stopped()); EXPECT_TRUE(stream_->write_side_closed()); @@ -730,7 +776,7 @@ TEST_P(QuicSimpleServerStreamTest, InvalidHeadersWithFin) { 0x54, 0x54, 0x50, 0x2f, // TTP/ 0x31, 0x2e, 0x31, // 1.1 }; - quiche::QuicheStringPiece data(arr, QUICHE_ARRAYSIZE(arr)); + absl::string_view data(arr, ABSL_ARRAYSIZE(arr)); QuicStreamFrame frame(stream_->id(), true, 0, data); // Verify that we don't crash when we get a invalid headers in stream frame. stream_->OnStreamFrame(frame); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc index 212e605f298..134e673dd9f 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc @@ -6,15 +6,16 @@ #include <utility> +#include "absl/strings/numbers.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/core/quic_server_id.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -using spdy::SpdyHeaderBlock; +using spdy::Http2HeaderBlock; namespace quic { @@ -24,8 +25,8 @@ void QuicSpdyClientBase::ClientQuicDataToResend::Resend() { } QuicSpdyClientBase::QuicDataToResend::QuicDataToResend( - std::unique_ptr<SpdyHeaderBlock> headers, - quiche::QuicheStringPiece body, + std::unique_ptr<Http2HeaderBlock> headers, + absl::string_view body, bool fin) : headers_(std::move(headers)), body_(body), fin_(fin) {} @@ -80,7 +81,7 @@ void QuicSpdyClientBase::OnClose(QuicSpdyStream* stream) { QuicSpdyClientStream* client_stream = static_cast<QuicSpdyClientStream*>(stream); - const SpdyHeaderBlock& response_headers = client_stream->response_headers(); + const Http2HeaderBlock& response_headers = client_stream->response_headers(); if (response_listener_ != nullptr) { response_listener_->OnCompleteResponse(stream->id(), response_headers, client_stream->data()); @@ -91,8 +92,7 @@ void QuicSpdyClientBase::OnClose(QuicSpdyStream* stream) { auto status = response_headers.find(":status"); if (status == response_headers.end()) { QUIC_LOG(ERROR) << "Missing :status response header"; - } else if (!quiche::QuicheTextUtils::StringToInt(status->second, - &latest_response_code_)) { + } else if (!absl::SimpleAtoi(status->second, &latest_response_code_)) { QUIC_LOG(ERROR) << "Invalid :status response header: " << status->second; } latest_response_headers_ = response_headers.DebugString(); @@ -113,12 +113,12 @@ std::unique_ptr<QuicSession> QuicSpdyClientBase::CreateQuicClientSession( &push_promise_index_); } -void QuicSpdyClientBase::SendRequest(const SpdyHeaderBlock& headers, - quiche::QuicheStringPiece body, +void QuicSpdyClientBase::SendRequest(const Http2HeaderBlock& headers, + absl::string_view body, bool fin) { if (GetQuicFlag(FLAGS_quic_client_convert_http_header_name_to_lowercase)) { QUIC_CODE_COUNT(quic_client_convert_http_header_name_to_lowercase); - SpdyHeaderBlock sanitized_headers; + Http2HeaderBlock sanitized_headers; for (const auto& p : headers) { sanitized_headers[quiche::QuicheTextUtils::ToLower(p.first)] = p.second; } @@ -129,8 +129,8 @@ void QuicSpdyClientBase::SendRequest(const SpdyHeaderBlock& headers, } } -void QuicSpdyClientBase::SendRequestInternal(SpdyHeaderBlock sanitized_headers, - quiche::QuicheStringPiece body, +void QuicSpdyClientBase::SendRequestInternal(Http2HeaderBlock sanitized_headers, + absl::string_view body, bool fin) { QuicClientPushPromiseIndex::TryHandle* handle; QuicAsyncStatus rv = @@ -153,8 +153,8 @@ void QuicSpdyClientBase::SendRequestInternal(SpdyHeaderBlock sanitized_headers, } void QuicSpdyClientBase::SendRequestAndWaitForResponse( - const SpdyHeaderBlock& headers, - quiche::QuicheStringPiece body, + const Http2HeaderBlock& headers, + absl::string_view body, bool fin) { SendRequest(headers, body, fin); while (WaitForEvents()) { @@ -164,7 +164,7 @@ void QuicSpdyClientBase::SendRequestAndWaitForResponse( void QuicSpdyClientBase::SendRequestsAndWaitForResponse( const std::vector<std::string>& url_list) { for (size_t i = 0; i < url_list.size(); ++i) { - SpdyHeaderBlock headers; + Http2HeaderBlock headers; if (!SpdyUtils::PopulateHeaderBlockFromUrl(url_list[i], &headers)) { QUIC_BUG << "Unable to create request"; continue; @@ -232,19 +232,19 @@ void QuicSpdyClientBase::ResendSavedData() { } } -void QuicSpdyClientBase::AddPromiseDataToResend(const SpdyHeaderBlock& headers, - quiche::QuicheStringPiece body, +void QuicSpdyClientBase::AddPromiseDataToResend(const Http2HeaderBlock& headers, + absl::string_view body, bool fin) { - std::unique_ptr<SpdyHeaderBlock> new_headers( - new SpdyHeaderBlock(headers.Clone())); + std::unique_ptr<Http2HeaderBlock> new_headers( + new Http2HeaderBlock(headers.Clone())); push_promise_data_to_resend_.reset( new ClientQuicDataToResend(std::move(new_headers), body, fin, this)); } bool QuicSpdyClientBase::CheckVary( - const SpdyHeaderBlock& /*client_request*/, - const SpdyHeaderBlock& /*promise_request*/, - const SpdyHeaderBlock& /*promise_response*/) { + const Http2HeaderBlock& /*client_request*/, + const Http2HeaderBlock& /*promise_request*/, + const Http2HeaderBlock& /*promise_response*/) { return true; } @@ -274,7 +274,7 @@ const std::string& QuicSpdyClientBase::preliminary_response_headers() const { return preliminary_response_headers_; } -const SpdyHeaderBlock& QuicSpdyClientBase::latest_response_header_block() +const Http2HeaderBlock& QuicSpdyClientBase::latest_response_header_block() const { QUIC_BUG_IF(!store_response_) << "Response not stored!"; return latest_response_header_block_; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h index fdd67fbc3b5..90dfe8a92d2 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h @@ -10,6 +10,7 @@ #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" #include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" @@ -17,7 +18,6 @@ #include "net/third_party/quiche/src/quic/core/quic_config.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" #include "net/third_party/quiche/src/quic/tools/quic_client_base.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -36,7 +36,7 @@ class QuicSpdyClientBase : public QuicClientBase, virtual ~ResponseListener() {} virtual void OnCompleteResponse( QuicStreamId id, - const spdy::SpdyHeaderBlock& response_headers, + const spdy::Http2HeaderBlock& response_headers, const std::string& response_body) = 0; }; @@ -46,8 +46,8 @@ class QuicSpdyClientBase : public QuicClientBase, class QuicDataToResend { public: // |headers| may be null, since it's possible to send data without headers. - QuicDataToResend(std::unique_ptr<spdy::SpdyHeaderBlock> headers, - quiche::QuicheStringPiece body, + QuicDataToResend(std::unique_ptr<spdy::Http2HeaderBlock> headers, + absl::string_view body, bool fin); QuicDataToResend(const QuicDataToResend&) = delete; QuicDataToResend& operator=(const QuicDataToResend&) = delete; @@ -59,8 +59,8 @@ class QuicSpdyClientBase : public QuicClientBase, virtual void Resend() = 0; protected: - std::unique_ptr<spdy::SpdyHeaderBlock> headers_; - quiche::QuicheStringPiece body_; + std::unique_ptr<spdy::Http2HeaderBlock> headers_; + absl::string_view body_; bool fin_; }; @@ -85,13 +85,13 @@ class QuicSpdyClientBase : public QuicClientBase, void InitializeSession() override; // Sends an HTTP request and does not wait for response before returning. - void SendRequest(const spdy::SpdyHeaderBlock& headers, - quiche::QuicheStringPiece body, + void SendRequest(const spdy::Http2HeaderBlock& headers, + absl::string_view body, bool fin); // Sends an HTTP request and waits for response before returning. - void SendRequestAndWaitForResponse(const spdy::SpdyHeaderBlock& headers, - quiche::QuicheStringPiece body, + void SendRequestAndWaitForResponse(const spdy::Http2HeaderBlock& headers, + absl::string_view body, bool fin); // Sends a request simple GET for each URL in |url_list|, and then waits for @@ -110,9 +110,9 @@ class QuicSpdyClientBase : public QuicClientBase, return &push_promise_index_; } - bool CheckVary(const spdy::SpdyHeaderBlock& client_request, - const spdy::SpdyHeaderBlock& promise_request, - const spdy::SpdyHeaderBlock& promise_response) override; + bool CheckVary(const spdy::Http2HeaderBlock& client_request, + const spdy::Http2HeaderBlock& promise_request, + const spdy::Http2HeaderBlock& promise_response) override; void OnRendezvousResult(QuicSpdyStream*) override; // If the crypto handshake has not yet been confirmed, adds the data to the @@ -126,7 +126,7 @@ class QuicSpdyClientBase : public QuicClientBase, int latest_response_code() const; const std::string& latest_response_headers() const; const std::string& preliminary_response_headers() const; - const spdy::SpdyHeaderBlock& latest_response_header_block() const; + const spdy::Http2HeaderBlock& latest_response_header_block() const; const std::string& latest_response_body() const; const std::string& latest_response_trailers() const; @@ -161,8 +161,8 @@ class QuicSpdyClientBase : public QuicClientBase, void ResendSavedData() override; - void AddPromiseDataToResend(const spdy::SpdyHeaderBlock& headers, - quiche::QuicheStringPiece body, + void AddPromiseDataToResend(const spdy::Http2HeaderBlock& headers, + absl::string_view body, bool fin); bool HasActiveRequests() override; @@ -170,8 +170,8 @@ class QuicSpdyClientBase : public QuicClientBase, // Specific QuicClient class for storing data to resend. class ClientQuicDataToResend : public QuicDataToResend { public: - ClientQuicDataToResend(std::unique_ptr<spdy::SpdyHeaderBlock> headers, - quiche::QuicheStringPiece body, + ClientQuicDataToResend(std::unique_ptr<spdy::Http2HeaderBlock> headers, + absl::string_view body, bool fin, QuicSpdyClientBase* client) : QuicDataToResend(std::move(headers), body, fin), client_(client) { @@ -189,8 +189,8 @@ class QuicSpdyClientBase : public QuicClientBase, QuicSpdyClientBase* client_; }; - void SendRequestInternal(spdy::SpdyHeaderBlock sanitized_headers, - quiche::QuicheStringPiece body, + void SendRequestInternal(spdy::Http2HeaderBlock sanitized_headers, + absl::string_view body, bool fin); // Index of pending promised streams. Must outlive |session_|. @@ -205,7 +205,7 @@ class QuicSpdyClientBase : public QuicClientBase, // preliminary 100 Continue HTTP/2 headers from most recent response, if any. std::string preliminary_response_headers_; // HTTP/2 headers from most recent response. - spdy::SpdyHeaderBlock latest_response_header_block_; + spdy::Http2HeaderBlock latest_response_header_block_; // Body of most recent response. std::string latest_response_body_; // HTTP/2 trailers from most recent response. diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc index 582f3c7cd4a..c25411d9bb5 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc @@ -48,6 +48,9 @@ #include <utility> #include <vector> +#include "absl/strings/escaping.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" #include "net/third_party/quiche/src/quic/core/quic_server_id.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" @@ -58,13 +61,11 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_system_event_loop.h" #include "net/third_party/quiche/src/quic/tools/fake_proof_verifier.h" #include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace { using quic::QuicUrl; -using quiche::QuicheStringPiece; using quiche::QuicheTextUtils; } // namespace @@ -322,11 +323,11 @@ int QuicToyClient::SendRequestsAndPrintResponses( if (!GetQuicFlag(FLAGS_body_hex).empty()) { DCHECK(GetQuicFlag(FLAGS_body).empty()) << "Only set one of --body and --body_hex."; - body = QuicheTextUtils::HexDecode(GetQuicFlag(FLAGS_body_hex)); + body = absl::HexStringToBytes(GetQuicFlag(FLAGS_body_hex)); } // Construct a GET or POST request for supplied URL. - spdy::SpdyHeaderBlock header_block; + spdy::Http2HeaderBlock header_block; header_block[":method"] = body.empty() ? "GET" : "POST"; header_block[":scheme"] = url.scheme(); header_block[":authority"] = url.HostPort(); @@ -334,12 +335,12 @@ int QuicToyClient::SendRequestsAndPrintResponses( // Append any additional headers supplied on the command line. const std::string headers = GetQuicFlag(FLAGS_headers); - for (QuicheStringPiece sp : QuicheTextUtils::Split(headers, ';')) { + for (absl::string_view sp : absl::StrSplit(headers, ';')) { QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&sp); if (sp.empty()) { continue; } - std::vector<QuicheStringPiece> kv = QuicheTextUtils::Split(sp, ':'); + std::vector<absl::string_view> kv = absl::StrSplit(sp, ':'); QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[0]); QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&kv[1]); header_block[kv[0]] = kv[1]; @@ -359,8 +360,8 @@ int QuicToyClient::SendRequestsAndPrintResponses( if (!GetQuicFlag(FLAGS_body_hex).empty()) { // Print the user provided hex, rather than binary body. std::cout << "body:\n" - << QuicheTextUtils::HexDump(QuicheTextUtils::HexDecode( - GetQuicFlag(FLAGS_body_hex))) + << QuicheTextUtils::HexDump( + absl::HexStringToBytes(GetQuicFlag(FLAGS_body_hex))) << std::endl; } else { std::cout << "body: " << body << std::endl; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc index d445b548a8c..ec52d3a35ca 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc @@ -6,12 +6,12 @@ #include <memory> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_connection.h" #include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -36,12 +36,13 @@ QuicTransportSimpleServerDispatcher::QuicTransportSimpleServerDispatcher( std::unique_ptr<QuicSession> QuicTransportSimpleServerDispatcher::CreateQuicSession( QuicConnectionId server_connection_id, - const QuicSocketAddress& /*self_address*/, + const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, - quiche::QuicheStringPiece /*alpn*/, + absl::string_view /*alpn*/, const ParsedQuicVersion& version) { auto connection = std::make_unique<QuicConnection>( - server_connection_id, peer_address, helper(), alarm_factory(), writer(), + server_connection_id, self_address, peer_address, helper(), + alarm_factory(), writer(), /*owns_writer=*/false, Perspective::IS_SERVER, ParsedQuicVersionVector{version}); auto session = std::make_unique<QuicTransportSimpleServerSession>( diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h index da27585e28c..62e4432a2d6 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_TRANSPORT_SIMPLE_SERVER_DISPATCHER_H_ #define QUICHE_QUIC_TOOLS_QUIC_TRANSPORT_SIMPLE_SERVER_DISPATCHER_H_ +#include "absl/strings/string_view.h" #include "url/origin.h" #include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" #include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -31,7 +31,7 @@ class QuicTransportSimpleServerDispatcher : public QuicDispatcher { QuicConnectionId server_connection_id, const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, - quiche::QuicheStringPiece alpn, + absl::string_view alpn, const ParsedQuicVersion& version) override; std::vector<url::Origin> accepted_origins_; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc index d07da11672b..386bd0056fa 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc @@ -226,7 +226,7 @@ bool QuicTransportSimpleServerSession::ProcessPath(const GURL& url) { } void QuicTransportSimpleServerSession::OnMessageReceived( - quiche::QuicheStringPiece message) { + absl::string_view message) { if (mode_ != ECHO) { return; } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h index 7cfd1975c4e..fc018fbd5a1 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h @@ -58,7 +58,7 @@ class QuicTransportSimpleServerSession void OnCanCreateNewOutgoingStream(bool unidirectional) override; bool CheckOrigin(url::Origin origin) override; bool ProcessPath(const GURL& url) override; - void OnMessageReceived(quiche::QuicheStringPiece message) override; + void OnMessageReceived(absl::string_view message) override; void EchoStreamBack(const std::string& data) { streams_to_echo_back_.push_back(data); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc index 438847c35f8..9f9e98aeaf5 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc @@ -4,18 +4,16 @@ #include "net/third_party/quiche/src/quic/tools/quic_url.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { static constexpr size_t kMaxHostNameLength = 256; -QuicUrl::QuicUrl(quiche::QuicheStringPiece url) - : url_(static_cast<std::string>(url)) {} +QuicUrl::QuicUrl(absl::string_view url) : url_(static_cast<std::string>(url)) {} -QuicUrl::QuicUrl(quiche::QuicheStringPiece url, - quiche::QuicheStringPiece default_scheme) +QuicUrl::QuicUrl(absl::string_view url, absl::string_view default_scheme) : QuicUrl(url) { if (url_.has_scheme()) { return; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_url.h b/chromium/net/third_party/quiche/src/quic/tools/quic_url.h index 4b057db3b3a..ca4ac8e346f 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_url.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_url.h @@ -7,9 +7,9 @@ #include <string> +#include "absl/strings/string_view.h" #include "url/gurl.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -24,12 +24,11 @@ class QuicUrl { // NOTE: If |url| doesn't have a scheme, it will have an empty scheme // field. If that's not what you want, use the QuicUrlImpl(url, // default_scheme) form below. - explicit QuicUrl(quiche::QuicheStringPiece url); + explicit QuicUrl(absl::string_view url); // Constructs a QuicUrlImpl from |url|, assuming that the scheme for the URL // is |default_scheme| if there is no scheme specified in |url|. - QuicUrl(quiche::QuicheStringPiece url, - quiche::QuicheStringPiece default_scheme); + QuicUrl(absl::string_view url, absl::string_view default_scheme); // Returns false if the URL is not valid. bool IsValid() const; diff --git a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc index 3da114e5526..b742dbff322 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc @@ -38,8 +38,7 @@ size_t SimpleTicketCrypter::MaxOverhead() { return kEpochSize + kIVSize + kAuthTagSize; } -std::vector<uint8_t> SimpleTicketCrypter::Encrypt( - quiche::QuicheStringPiece in) { +std::vector<uint8_t> SimpleTicketCrypter::Encrypt(absl::string_view in) { MaybeRotateKeys(); std::vector<uint8_t> out(in.size() + MaxOverhead()); out[0] = key_epoch_; @@ -56,8 +55,7 @@ std::vector<uint8_t> SimpleTicketCrypter::Encrypt( return out; } -std::vector<uint8_t> SimpleTicketCrypter::Decrypt( - quiche::QuicheStringPiece in) { +std::vector<uint8_t> SimpleTicketCrypter::Decrypt(absl::string_view in) { MaybeRotateKeys(); if (in.size() < kMessageOffset) { return std::vector<uint8_t>(); @@ -83,7 +81,7 @@ std::vector<uint8_t> SimpleTicketCrypter::Decrypt( } void SimpleTicketCrypter::Decrypt( - quiche::QuicheStringPiece in, + absl::string_view in, std::unique_ptr<quic::ProofSource::DecryptCallback> callback) { callback->Run(Decrypt(in)); } diff --git a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h index 330c5091094..c150ae24579 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h +++ b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h @@ -24,13 +24,13 @@ class QUIC_NO_EXPORT SimpleTicketCrypter ~SimpleTicketCrypter() override; size_t MaxOverhead() override; - std::vector<uint8_t> Encrypt(quiche::QuicheStringPiece in) override; + std::vector<uint8_t> Encrypt(absl::string_view in) override; void Decrypt( - quiche::QuicheStringPiece in, + absl::string_view in, std::unique_ptr<quic::ProofSource::DecryptCallback> callback) override; private: - std::vector<uint8_t> Decrypt(quiche::QuicheStringPiece in); + std::vector<uint8_t> Decrypt(absl::string_view in); void MaybeRotateKeys(); diff --git a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc index e609dc03571..568fa2b846c 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc @@ -26,9 +26,8 @@ class DecryptCallback : public quic::ProofSource::DecryptCallback { std::vector<uint8_t>* out_; }; -quiche::QuicheStringPiece StringPiece(const std::vector<uint8_t>& in) { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(in.data()), - in.size()); +absl::string_view StringPiece(const std::vector<uint8_t>& in) { + return absl::string_view(reinterpret_cast<const char*>(in.data()), in.size()); } class SimpleTicketCrypterTest : public QuicTest { @@ -81,7 +80,7 @@ TEST_F(SimpleTicketCrypterTest, DecryptionFailureWithModifiedCiphertext) { TEST_F(SimpleTicketCrypterTest, DecryptionFailureWithEmptyCiphertext) { std::vector<uint8_t> out_plaintext; - ticket_crypter_.Decrypt(quiche::QuicheStringPiece(), + ticket_crypter_.Decrypt(absl::string_view(), std::make_unique<DecryptCallback>(&out_plaintext)); EXPECT_TRUE(out_plaintext.empty()); } |