Improve MasqueConnectionPool visitor callback Renamed to avoid conflict, and switch to an rvalue reference to allow modifications such as moving the response body. PiperOrigin-RevId: 843842242
diff --git a/quiche/quic/masque/masque_connection_pool.cc b/quiche/quic/masque/masque_connection_pool.cc index 68da082..2460541 100644 --- a/quiche/quic/masque/masque_connection_pool.cc +++ b/quiche/quic/masque/masque_connection_pool.cc
@@ -80,7 +80,7 @@ Message response; response.headers = headers.Clone(); response.body = body; - visitor_->OnResponse(this, request_id, std::move(response)); + visitor_->OnPoolResponse(this, request_id, std::move(response)); found = true; break; } @@ -170,8 +170,8 @@ pending_request.request.body); if (stream_id < 0) { QUICHE_LOG(ERROR) << "Failed to send request"; - visitor_->OnResponse(this, request_id, - absl::InternalError("Failed to send request")); + visitor_->OnPoolResponse(this, request_id, + absl::InternalError("Failed to send request")); pending_requests_.erase(it++); continue; } @@ -189,7 +189,7 @@ ++it; continue; } - visitor_->OnResponse(this, request_id, error); + visitor_->OnPoolResponse(this, request_id, error); pending_requests_.erase(it++); } } @@ -280,7 +280,9 @@ } static constexpr uint8_t kAlpnProtocols[] = { + // clang-format off 0x02, 'h', '2', // h2 + // clang-format on }; if (SSL_set_alpn_protos(ssl_.get(), kAlpnProtocols, sizeof(kAlpnProtocols)) != 0) {
diff --git a/quiche/quic/masque/masque_connection_pool.h b/quiche/quic/masque/masque_connection_pool.h index 709b44e..773ef11 100644 --- a/quiche/quic/masque/masque_connection_pool.h +++ b/quiche/quic/masque/masque_connection_pool.h
@@ -56,8 +56,9 @@ class QUIC_NO_EXPORT Visitor { public: virtual ~Visitor() = default; - virtual void OnResponse(MasqueConnectionPool* pool, RequestId request_id, - const absl::StatusOr<Message>& response) = 0; + virtual void OnPoolResponse(MasqueConnectionPool* pool, + RequestId request_id, + absl::StatusOr<Message>&& response) = 0; }; // If the request fails immediately, the error will be returned. Otherwise, a
diff --git a/quiche/quic/masque/masque_ohttp_client.cc b/quiche/quic/masque/masque_ohttp_client.cc index b9c8b87..a0546da 100644 --- a/quiche/quic/masque/masque_ohttp_client.cc +++ b/quiche/quic/masque/masque_ohttp_client.cc
@@ -303,9 +303,9 @@ return status; } -void MasqueOhttpClient::OnResponse(MasqueConnectionPool* /*pool*/, - RequestId request_id, - const absl::StatusOr<Message>& response) { +void MasqueOhttpClient::OnPoolResponse(MasqueConnectionPool* /*pool*/, + RequestId request_id, + absl::StatusOr<Message>&& response) { if (key_fetch_request_id_.has_value() && *key_fetch_request_id_ == request_id) { auto status = HandleKeyResponse(response);
diff --git a/quiche/quic/masque/masque_ohttp_client.h b/quiche/quic/masque/masque_ohttp_client.h index 216c2bf..b364702 100644 --- a/quiche/quic/masque/masque_ohttp_client.h +++ b/quiche/quic/masque/masque_ohttp_client.h
@@ -57,8 +57,9 @@ protected: // From quic::MasqueConnectionPool::Visitor. - void OnResponse(quic::MasqueConnectionPool* /*pool*/, RequestId request_id, - const absl::StatusOr<Message>& response) override; + void OnPoolResponse(quic::MasqueConnectionPool* /*pool*/, + RequestId request_id, + absl::StatusOr<Message>&& response) override; // Fetch key from the key URL. absl::Status StartKeyFetch(const std::string& url_string);