Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable use of QUIC for Cobalt #2967

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions net/http/http_network_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ void HttpNetworkSession::DisableQuic() {
void HttpNetworkSession::SetEnableQuic(bool enable_quic) {
params_.enable_quic = enable_quic;
}

bool HttpNetworkSession::UseQuicForUnknownOrigin() const {
return params_.use_quic_for_unknown_origins;
}
#endif // defined(STARBOARD)

void HttpNetworkSession::ClearSSLSessionCache() {
Expand Down
5 changes: 4 additions & 1 deletion net/http/http_network_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct NET_EXPORT HttpNetworkSessionParams {
#if defined(STARBOARD)
// If true, request to an origin without recorded alt-svc info will
// try to establish both QUIC and TCP connections and use the faster one.
bool use_quic_for_unknown_origins;
bool use_quic_for_unknown_origins = false;
#endif

// If non-empty, QUIC will only be spoken to hosts in this list.
Expand Down Expand Up @@ -315,6 +315,9 @@ class NET_EXPORT HttpNetworkSession {

#if defined(STARBOARD)
void SetEnableQuic(bool enable_quic);

// Whether to try QUIC connection for origins without alt-svc on record.
bool UseQuicForUnknownOrigin() const;
#endif // defined(STARBOARD)

// Clear the SSL session cache.
Expand Down
23 changes: 23 additions & 0 deletions net/http/http_stream_factory_job_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ namespace net {

namespace {

#if defined(STARBOARD)
const int kDefaultQUICServerPort = 443;
#endif

// Returns parameters associated with the proxy resolution.
base::Value::Dict NetLogHttpStreamJobProxyServerResolved(
const ProxyServer& proxy_server) {
Expand Down Expand Up @@ -1198,8 +1202,27 @@ HttpStreamFactory::JobController::GetAlternativeServiceInfoInternal(
http_server_properties.GetAlternativeServiceInfos(
url::SchemeHostPort(original_url),
request_info.network_anonymization_key);
#if defined(STARBOARD)
// This block of code suggests QUIC connection for initial requests to a
// new host. This method is proven to provide performance benefit while still
// enabling Cobalt network module to fall back on TCP connection when QUIC
// fails or is too slow.
if (alternative_service_info_vector.empty() && session_->IsQuicEnabled() &&
session_->UseQuicForUnknownOrigin()) {
url::SchemeHostPort origin(original_url);
if (origin.port() == kDefaultQUICServerPort) {
quic::ParsedQuicVersionVector versions = quic::AllSupportedVersions();
return AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
AlternativeService(net::kProtoQUIC, origin.host(),
kDefaultQUICServerPort),
base::Time::Max(), versions);
}
return AlternativeServiceInfo();
}
#else
if (alternative_service_info_vector.empty())
return AlternativeServiceInfo();
#endif

bool quic_advertised = false;
bool quic_all_broken = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,15 @@ QuicConnection::QuicConnection(
QUICHE_DCHECK(perspective_ == Perspective::IS_CLIENT ||
default_path_.self_address.IsInitialized());

#if defined(STARBOARD)
LOG(INFO) << "Created QUIC connection for address: "
<< peer_address().ToString()
<< " with version: " << ParsedQuicVersionToString(version());
#else
QUIC_DLOG(INFO) << ENDPOINT << "Created connection with server connection ID "
<< server_connection_id
<< " and version: " << ParsedQuicVersionToString(version());
#endif

QUIC_BUG_IF(quic_bug_12714_2, !QuicUtils::IsConnectionIdValidForVersion(
server_connection_id, transport_version()))
Expand Down
Loading