0

Record NetLog event for WebTransport client state change

Most QUIC related events are already recorded by QuicEventLogger but
there are some missing events which are useful for debugging. For
example, when QuicSpdySession::SupportsWebTransport() returns false
DedicatedWebTransportHttp3Client terminates the connection without any
NetLog event associated with the WEB_TRANSPORT_CLIENT source type.
This CL adds a NetLog event which records WebTransport client state
changes to improve the situation.

Bug: N/A
Change-Id: I4c2ff2ef5c73167d77446fee2ed02f18b941e708
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3256623
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Victor Vasiliev <vasilvv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#938100}
This commit is contained in:
Kenichi Ishibashi
2021-11-04 01:51:44 +00:00
committed by Chromium LUCI CQ
parent 9103806477
commit 1d2ddb9564
4 changed files with 47 additions and 14 deletions

@ -2097,6 +2097,14 @@ EVENT_TYPE(QUIC_SESSION_TRANSPORT_PARAMETERS_SENT)
// }
EVENT_TYPE(QUIC_SESSION_TRANSPORT_PARAMETERS_RESUMED)
// A WebTransport client state has changed.
// {
// "last_state": <The last client state>
// "next_state": <The next client state>
// "error": <Optionally, error codes and details when an error happened>
// }
EVENT_TYPE(QUIC_SESSION_WEBTRANSPORT_CLIENT_STATE_CHANGED)
// QUIC with TLS gets 0-RTT rejected.
EVENT_TYPE(QUIC_SESSION_ZERO_RTT_REJECTED)

@ -11,6 +11,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "net/base/port_util.h"
#include "net/base/url_util.h"
#include "net/log/net_log_values.h"
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include "net/proxy_resolution/proxy_resolution_request.h"
#include "net/quic/address_utils.h"
@ -68,6 +69,27 @@ std::unique_ptr<quic::ProofVerifier> CreateProofVerifier(
return verifier;
}
void RecordNetLogQuicSessionClientStateChanged(
NetLogWithSource& net_log,
WebTransportState last_state,
WebTransportState next_state,
const absl::optional<WebTransportError>& error) {
net_log.AddEvent(
NetLogEventType::QUIC_SESSION_WEBTRANSPORT_CLIENT_STATE_CHANGED, [&] {
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("last_state", WebTransportStateString(last_state));
dict.SetStringKey("next_state", WebTransportStateString(next_state));
if (error.has_value()) {
base::Value error_dict(base::Value::Type::DICTIONARY);
error_dict.SetIntKey("net_error", error->net_error);
error_dict.SetIntKey("quic_error", error->quic_error);
error_dict.SetStringKey("details", error->details);
dict.SetKey("error", std::move(error_dict));
}
return dict;
});
}
// The stream associated with an extended CONNECT request for the WebTransport
// session.
class ConnectStream : public quic::QuicSpdyClientStream {
@ -581,6 +603,8 @@ void DedicatedWebTransportHttp3Client::TransitionToState(
DCHECK_NE(state_, next_state);
const WebTransportState last_state = state_;
state_ = next_state;
RecordNetLogQuicSessionClientStateChanged(net_log_, last_state, next_state,
error_);
switch (next_state) {
case WebTransportState::CONNECTING:
DCHECK_EQ(last_state, WebTransportState::NEW);

@ -33,27 +33,25 @@ class FailedWebTransportClient : public WebTransportClient {
} // namespace
std::ostream& operator<<(std::ostream& os, WebTransportState state) {
os << WebTransportStateString(state);
return os;
}
const char* WebTransportStateString(WebTransportState state) {
switch (state) {
case WebTransportState::NEW:
os << "NEW";
break;
return "NEW";
case WebTransportState::CONNECTING:
os << "CONNECTING";
break;
return "CONNECTING";
case WebTransportState::CONNECTED:
os << "CONNECTED";
break;
return "CONNECTED";
case WebTransportState::CLOSED:
os << "CLOSED";
break;
return "CLOSED";
case WebTransportState::FAILED:
os << "FAILED";
break;
default:
os << "[" << static_cast<int>(state) << "]";
break;
return "FAILED";
case WebTransportState::NUM_STATES:
return "UNKNOWN";
}
return os;
}
WebTransportCloseInfo::WebTransportCloseInfo() = default;

@ -64,6 +64,9 @@ struct NET_EXPORT WebTransportCloseInfo final {
bool operator==(const WebTransportCloseInfo& other) const;
};
// Returns the string representation of `state`.
const char* WebTransportStateString(WebTransportState state);
// A visitor that gets notified about events that happen to a WebTransport
// client.
class NET_EXPORT WebTransportClientVisitor {