Commit 01447c87 authored by Renjie Tang's avatar Renjie Tang Committed by Commit Bot

Add netlog support for HTTP/3 unidirectional streams and SETTINGS.

A sample netlog that I captured inter-opting with quic.rocks:4433
https://drive.google.com/file/d/1kad8a5-7Rxow-o1eEwckKWLipeLR0as9/view?usp=sharing
Search HTTP3 for entries.

Change-Id: I3ab02c9b49ebc82ee8ceb040beaacac1a4dea32c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816823
Commit-Queue: Renjie Tang <renjietang@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Reviewed-by: default avatarRenjie Tang <renjietang@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699452}
parent 386b3788
...@@ -1060,6 +1060,8 @@ component("net") { ...@@ -1060,6 +1060,8 @@ component("net") {
"quic/quic_crypto_client_stream_factory.cc", "quic/quic_crypto_client_stream_factory.cc",
"quic/quic_crypto_client_stream_factory.h", "quic/quic_crypto_client_stream_factory.h",
"quic/quic_flags_list.h", "quic/quic_flags_list.h",
"quic/quic_http3_logger.cc",
"quic/quic_http3_logger.h",
"quic/quic_http_stream.cc", "quic/quic_http_stream.cc",
"quic/quic_http_stream.h", "quic/quic_http_stream.h",
"quic/quic_http_utils.cc", "quic/quic_http_utils.cc",
......
...@@ -3234,3 +3234,18 @@ EVENT_TYPE(COOKIE_GET_BLOCKED_BY_NETWORK_DELEGATE) ...@@ -3234,3 +3234,18 @@ EVENT_TYPE(COOKIE_GET_BLOCKED_BY_NETWORK_DELEGATE)
// { // {
// } // }
EVENT_TYPE(COOKIE_SET_BLOCKED_BY_NETWORK_DELEGATE) EVENT_TYPE(COOKIE_SET_BLOCKED_BY_NETWORK_DELEGATE)
//
// HTTP/3 events.
//
// Event emitted when peer created control stream type is received.
EVENT_TYPE(HTTP3_PEER_CONTROL_STREAM_CREATED)
// Event emitted when peer created QPACK encoder stream type is received.
EVENT_TYPE(HTTP3_PEER_QPACK_ENCODER_STREAM_CREATED)
// Event emitted when peer created QPACK decoder stream type is received.
EVENT_TYPE(HTTP3_PEER_QPACK_DECODER_STREAM_CREATED)
// Event emitted when SETTINGS frame is received.
EVENT_TYPE(HTTP3_SETTINGS_RECEIVED)
...@@ -43,3 +43,4 @@ SOURCE_TYPE(HOST_CACHE_PERSISTENCE_MANAGER) ...@@ -43,3 +43,4 @@ SOURCE_TYPE(HOST_CACHE_PERSISTENCE_MANAGER)
SOURCE_TYPE(TRIAL_CERT_VERIFIER_JOB) SOURCE_TYPE(TRIAL_CERT_VERIFIER_JOB)
SOURCE_TYPE(COOKIE_STORE) SOURCE_TYPE(COOKIE_STORE)
SOURCE_TYPE(HTTP_AUTH_CONTROLLER) SOURCE_TYPE(HTTP_AUTH_CONTROLLER)
SOURCE_TYPE(HTTP3_SESSION)
...@@ -766,6 +766,9 @@ QuicChromiumClientSession::QuicChromiumClientSession( ...@@ -766,6 +766,9 @@ QuicChromiumClientSession::QuicChromiumClientSession(
connection_description, connection_description,
std::move(socket_performance_watcher), std::move(socket_performance_watcher),
net_log_)), net_log_)),
http3_logger_(VersionHasStreamType(connection->transport_version())
? new QuicHttp3Logger(net_log_)
: nullptr),
going_away_(false), going_away_(false),
port_migration_detected_(false), port_migration_detected_(false),
push_delegate_(push_delegate), push_delegate_(push_delegate),
...@@ -800,6 +803,8 @@ QuicChromiumClientSession::QuicChromiumClientSession( ...@@ -800,6 +803,8 @@ QuicChromiumClientSession::QuicChromiumClientSession(
std::make_unique<ProofVerifyContextChromium>(cert_verify_flags, std::make_unique<ProofVerifyContextChromium>(cert_verify_flags,
net_log_), net_log_),
crypto_config_->GetConfig())); crypto_config_->GetConfig()));
if (VersionHasStreamType(transport_version()))
set_debug_visitor(http3_logger_.get());
connection->set_debug_visitor(logger_.get()); connection->set_debug_visitor(logger_.get());
connection->set_creator_debug_delegate(logger_.get()); connection->set_creator_debug_delegate(logger_.get());
migrate_back_to_default_timer_.SetTaskRunner(task_runner_); migrate_back_to_default_timer_.SetTaskRunner(task_runner_);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "net/quic/quic_connection_logger.h" #include "net/quic/quic_connection_logger.h"
#include "net/quic/quic_connectivity_probing_manager.h" #include "net/quic/quic_connectivity_probing_manager.h"
#include "net/quic/quic_crypto_client_config_handle.h" #include "net/quic/quic_crypto_client_config_handle.h"
#include "net/quic/quic_http3_logger.h"
#include "net/quic/quic_session_key.h" #include "net/quic/quic_session_key.h"
#include "net/socket/socket_performance_watcher.h" #include "net/socket/socket_performance_watcher.h"
#include "net/spdy/http2_priority_dependencies.h" #include "net/spdy/http2_priority_dependencies.h"
...@@ -822,6 +823,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession ...@@ -822,6 +823,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
std::vector<std::unique_ptr<QuicChromiumPacketReader>> packet_readers_; std::vector<std::unique_ptr<QuicChromiumPacketReader>> packet_readers_;
LoadTimingInfo::ConnectTiming connect_timing_; LoadTimingInfo::ConnectTiming connect_timing_;
std::unique_ptr<QuicConnectionLogger> logger_; std::unique_ptr<QuicConnectionLogger> logger_;
std::unique_ptr<QuicHttp3Logger> http3_logger_;
// True when the session is going away, and streams may no longer be created // True when the session is going away, and streams may no longer be created
// on this session. Existing stream will continue to be processed. // on this session. Existing stream will continue to be processed.
bool going_away_; bool going_away_;
......
// Copyright (c) 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/quic/quic_http3_logger.h"
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
#include "base/strings/string_number_conversions.h"
#include "net/log/net_log_capture_mode.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_values.h"
namespace net {
namespace {
base::Value NetLogPeerControlStreamParams(quic::QuicStreamId id) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", id);
return std::move(dict);
}
base::Value NetLogPeerQpackEncoderStreamParams(quic::QuicStreamId id) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", id);
return std::move(dict);
}
base::Value NetLogPeerQpackDecoderStreamParams(quic::QuicStreamId id) {
base::DictionaryValue dict;
dict.SetInteger("stream_id", id);
return std::move(dict);
}
base::Value NetLogSettingsParams(const quic::SettingsFrame& frame) {
base::DictionaryValue dict;
// TODO(renjietang): Use string literal for setting identifiers.
for (auto setting : frame.values) {
dict.SetInteger(base::NumberToString(setting.first), setting.second);
}
return std::move(dict);
}
} // namespace
QuicHttp3Logger::QuicHttp3Logger(const NetLogWithSource& net_log)
: net_log_(net_log) {}
QuicHttp3Logger::~QuicHttp3Logger() {}
void QuicHttp3Logger::OnPeerControlStreamCreated(quic::QuicStreamId stream_id) {
if (!net_log_.IsCapturing())
return;
net_log_.AddEvent(NetLogEventType::HTTP3_PEER_CONTROL_STREAM_CREATED,
[&] { return NetLogPeerControlStreamParams(stream_id); });
}
void QuicHttp3Logger::OnPeerQpackEncoderStreamCreated(
quic::QuicStreamId stream_id) {
if (!net_log_.IsCapturing())
return;
net_log_.AddEvent(
NetLogEventType::HTTP3_PEER_QPACK_ENCODER_STREAM_CREATED,
[&] { return NetLogPeerQpackEncoderStreamParams(stream_id); });
}
void QuicHttp3Logger::OnPeerQpackDecoderStreamCreated(
quic::QuicStreamId stream_id) {
if (!net_log_.IsCapturing())
return;
net_log_.AddEvent(
NetLogEventType::HTTP3_PEER_QPACK_DECODER_STREAM_CREATED,
[&] { return NetLogPeerQpackDecoderStreamParams(stream_id); });
}
void QuicHttp3Logger::OnSettingsFrame(const quic::SettingsFrame& frame) {
if (!net_log_.IsCapturing())
return;
net_log_.AddEvent(NetLogEventType::HTTP3_SETTINGS_RECEIVED,
[&] { return NetLogSettingsParams(frame); });
}
} // namespace net
// Copyright (c) 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_QUIC_QUIC_HTTP3_LOGGER_H_
#define NET_QUIC_QUIC_HTTP3_LOGGER_H_
#include <stddef.h>
#include <bitset>
#include <string>
#include "base/macros.h"
#include "base/timer/timer.h"
#include "net/log/net_log_with_source.h"
#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h"
namespace net {
// This class is a debug visitor of a quic::QuicSpdySession which logs events
// to |net_log|.
class NET_EXPORT_PRIVATE QuicHttp3Logger : public quic::Http3DebugVisitor {
public:
QuicHttp3Logger(const NetLogWithSource& net_log);
~QuicHttp3Logger() override;
// Implementation of Http3DebugVisitor.
void OnPeerControlStreamCreated(quic::QuicStreamId stream_id) override;
void OnPeerQpackEncoderStreamCreated(quic::QuicStreamId stream_id) override;
void OnPeerQpackDecoderStreamCreated(quic::QuicStreamId stream_id) override;
void OnSettingsFrame(const quic::SettingsFrame& frame) override;
private:
NetLogWithSource net_log_;
DISALLOW_COPY_AND_ASSIGN(QuicHttp3Logger);
};
} // namespace net
#endif // NET_QUIC_QUIC_HTTP3_LOGGER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment