diff options
Diffstat (limited to 'chromium/net/spdy/spdy_session.cc')
-rw-r--r-- | chromium/net/spdy/spdy_session.cc | 156 |
1 files changed, 72 insertions, 84 deletions
diff --git a/chromium/net/spdy/spdy_session.cc b/chromium/net/spdy/spdy_session.cc index b61963f6716..eef09df91ed 100644 --- a/chromium/net/spdy/spdy_session.cc +++ b/chromium/net/spdy/spdy_session.cc @@ -27,6 +27,7 @@ #include "base/trace_event/memory_usage_estimator.h" #include "base/trace_event/trace_event.h" #include "base/values.h" +#include "net/base/features.h" #include "net/base/url_util.h" #include "net/cert/asn1_util.h" #include "net/cert/cert_verify_result.h" @@ -836,11 +837,13 @@ void SpdyStreamRequest::OnConfirmHandshakeComplete(int rv) { } // static -bool SpdySession::CanPool(TransportSecurityState* transport_security_state, - const SSLInfo& ssl_info, - const SSLConfigService& ssl_config_service, - const std::string& old_hostname, - const std::string& new_hostname) { +bool SpdySession::CanPool( + TransportSecurityState* transport_security_state, + const SSLInfo& ssl_info, + const SSLConfigService& ssl_config_service, + const std::string& old_hostname, + const std::string& new_hostname, + const net::NetworkIsolationKey& network_isolation_key) { // Pooling is prohibited if the server cert is not valid for the new domain, // and for connections on which client certs were sent. It is also prohibited // when channel ID was sent if the hosts are from different eTLDs+1. @@ -875,7 +878,7 @@ bool SpdySession::CanPool(TransportSecurityState* transport_security_state, ssl_info.public_key_hashes, ssl_info.cert.get(), ssl_info.unverified_cert.get(), ssl_info.signed_certificate_timestamps, TransportSecurityState::DISABLE_EXPECT_CT_REPORTS, - ssl_info.ct_policy_compliance)) { + ssl_info.ct_policy_compliance, network_isolation_key)) { case TransportSecurityState::CT_REQUIREMENTS_NOT_MET: return false; case TransportSecurityState::CT_REQUIREMENTS_MET: @@ -1098,7 +1101,8 @@ bool SpdySession::VerifyDomainAuthentication(const std::string& domain) const { return true; // This is not a secure session, so all domains are okay. return CanPool(transport_security_state_, ssl_info, *ssl_config_service_, - host_port_pair().host(), domain); + host_port_pair().host(), domain, + spdy_session_key_.network_isolation_key()); } void SpdySession::EnqueueStreamWrite( @@ -1165,15 +1169,13 @@ std::unique_ptr<spdy::SpdySerializedFrame> SpdySession::CreateHeaders( priority_dependency_state_.OnStreamCreation( stream_id, spdy_priority, &parent_stream_id, &weight, &exclusive); - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_SEND_HEADERS, - [&](NetLogCaptureMode capture_mode) { - return NetLogSpdyHeadersSentParams( - &block, (flags & spdy::CONTROL_FLAG_FIN) != 0, - stream_id, has_priority, weight, parent_stream_id, - exclusive, source_dependency, capture_mode); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_SEND_HEADERS, + [&](NetLogCaptureMode capture_mode) { + return NetLogSpdyHeadersSentParams( + &block, (flags & spdy::CONTROL_FLAG_FIN) != 0, + stream_id, has_priority, weight, parent_stream_id, + exclusive, source_dependency, capture_mode); + }); spdy::SpdyHeadersIR headers(stream_id, std::move(block)); headers.set_has_priority(has_priority); @@ -1241,7 +1243,7 @@ std::unique_ptr<SpdyBuffer> SpdySession::CreateDataBuffer( // Even though we're currently stalled only by the stream, we // might end up being stalled by the session also. QueueSendStalledStream(*stream); - net_log().AddEventWithIntParams( + net_log_.AddEventWithIntParams( NetLogEventType::HTTP2_SESSION_STREAM_STALLED_BY_STREAM_SEND_WINDOW, "stream_id", stream_id); return std::unique_ptr<SpdyBuffer>(); @@ -1253,7 +1255,7 @@ std::unique_ptr<SpdyBuffer> SpdySession::CreateDataBuffer( if (send_stalled_by_session) { stream->set_send_stalled_by_flow_control(true); QueueSendStalledStream(*stream); - net_log().AddEventWithIntParams( + net_log_.AddEventWithIntParams( NetLogEventType::HTTP2_SESSION_STREAM_STALLED_BY_SESSION_SEND_WINDOW, "stream_id", stream_id); return std::unique_ptr<SpdyBuffer>(); @@ -1268,12 +1270,10 @@ std::unique_ptr<SpdyBuffer> SpdySession::CreateDataBuffer( if (effective_len < len) flags = static_cast<spdy::SpdyDataFlags>(flags & ~spdy::DATA_FLAG_FIN); - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_SEND_DATA, [&] { - return NetLogSpdyDataParams(stream_id, effective_len, - (flags & spdy::DATA_FLAG_FIN) != 0); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_SEND_DATA, [&] { + return NetLogSpdyDataParams(stream_id, effective_len, + (flags & spdy::DATA_FLAG_FIN) != 0); + }); // Send PrefacePing for DATA_FRAMEs with nonzero payload size. if (effective_len > 0) @@ -1316,6 +1316,9 @@ void SpdySession::UpdateStreamPriority(SpdyStream* stream, DCHECK(IsStreamActive(stream_id)); + if (base::FeatureList::IsEnabled(features::kAvoidH2Reprioritization)) + return; + auto updates = priority_dependency_state_.OnStreamUpdate( stream_id, ConvertRequestPriorityToSpdyPriority(new_priority)); for (auto u : updates) { @@ -1745,13 +1748,12 @@ int SpdySession::TryCreateStream( return CreateStream(*request, stream); } - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_STALLED_MAX_STREAMS, [&] { - return NetLogSpdySessionStalledParams( - active_streams_.size(), created_streams_.size(), num_pushed_streams_, - max_concurrent_streams_, request->url().spec()); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_STALLED_MAX_STREAMS, [&] { + return NetLogSpdySessionStalledParams( + active_streams_.size(), created_streams_.size(), num_pushed_streams_, + max_concurrent_streams_, request->url().spec()); + }); + RequestPriority priority = request->priority(); CHECK_GE(priority, MINIMUM_PRIORITY); CHECK_LE(priority, MAXIMUM_PRIORITY); @@ -1999,7 +2001,8 @@ void SpdySession::TryCreatePushStream(spdy::SpdyStreamId stream_id, SSLInfo ssl_info; CHECK(GetSSLInfo(&ssl_info)); if (!CanPool(transport_security_state_, ssl_info, *ssl_config_service_, - associated_url.host(), gurl.host())) { + associated_url.host(), gurl.host(), + spdy_session_key_.network_isolation_key())) { RecordSpdyPushedStreamFateHistogram( SpdyPushedStreamFate::kCertificateMismatch); EnqueueResetStreamFrame(stream_id, request_priority, @@ -2167,7 +2170,7 @@ void SpdySession::EnqueueResetStreamFrame(spdy::SpdyStreamId stream_id, const std::string& description) { DCHECK_NE(stream_id, 0u); - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_SEND_RST_STREAM, [&] { + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_SEND_RST_STREAM, [&] { return NetLogSpdySendRstStreamParams(stream_id, error_code, description); }); @@ -2184,7 +2187,7 @@ void SpdySession::EnqueuePriorityFrame(spdy::SpdyStreamId stream_id, spdy::SpdyStreamId dependency_id, int weight, bool exclusive) { - net_log().AddEvent(NetLogEventType::HTTP2_STREAM_SEND_PRIORITY, [&] { + net_log_.AddEvent(NetLogEventType::HTTP2_STREAM_SEND_PRIORITY, [&] { return NetLogSpdyPriorityParams(stream_id, dependency_id, weight, exclusive); }); @@ -2600,7 +2603,7 @@ void SpdySession::HandleSetting(uint32_t id, uint32_t value) { break; case spdy::SETTINGS_INITIAL_WINDOW_SIZE: { if (value > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) { - net_log().AddEventWithIntParams( + net_log_.AddEventWithIntParams( NetLogEventType::HTTP2_SESSION_INITIAL_WINDOW_SIZE_OUT_OF_RANGE, "initial_window_size", value); return; @@ -2612,7 +2615,7 @@ void SpdySession::HandleSetting(uint32_t id, uint32_t value) { static_cast<int32_t>(value) - stream_initial_send_window_size_; stream_initial_send_window_size_ = static_cast<int32_t>(value); UpdateStreamsSendWindowSize(delta_window_size); - net_log().AddEventWithIntParams( + net_log_.AddEventWithIntParams( NetLogEventType::HTTP2_SESSION_UPDATE_STREAMS_SEND_WINDOW_SIZE, "delta_window_size", delta_window_size); break; @@ -2697,11 +2700,10 @@ void SpdySession::WritePingFrame(spdy::SpdyPingId unique_id, bool is_ack) { EnqueueSessionWrite(HIGHEST, spdy::SpdyFrameType::PING, std::move(ping_frame)); - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_PING, [&] { - return NetLogSpdyPingParams(unique_id, is_ack, "sent"); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_PING, [&] { + return NetLogSpdyPingParams(unique_id, is_ack, "sent"); + }); + if (!is_ack) { DCHECK(!ping_in_flight_); @@ -3078,7 +3080,7 @@ void SpdySession::OnRstStream(spdy::SpdyStreamId stream_id, spdy::SpdyErrorCode error_code) { CHECK(in_io_loop_); - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_RECV_RST_STREAM, [&] { + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_RST_STREAM, [&] { return NetLogSpdyRecvRstStreamParams(stream_id, error_code); }); @@ -3101,19 +3103,15 @@ void SpdySession::OnRstStream(spdy::SpdyStreamId stream_id, CloseActiveStreamIterator(it, ERR_HTTP2_SERVER_REFUSED_STREAM); } else if (error_code == spdy::ERROR_CODE_HTTP_1_1_REQUIRED) { // TODO(bnc): Record histogram with number of open streams capped at 50. - if (net_log().IsCapturing()) { - it->second->LogStreamError(ERR_HTTP_1_1_REQUIRED, - "Closing session because server reset stream " - "with ERR_HTTP_1_1_REQUIRED."); - } + it->second->LogStreamError(ERR_HTTP_1_1_REQUIRED, + "Closing session because server reset stream " + "with ERR_HTTP_1_1_REQUIRED."); DoDrainSession(ERR_HTTP_1_1_REQUIRED, "HTTP_1_1_REQUIRED for stream."); } else { RecordProtocolErrorHistogram( PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM); - if (net_log().IsCapturing()) { - it->second->LogStreamError(ERR_HTTP2_PROTOCOL_ERROR, - "Server reset stream."); - } + it->second->LogStreamError(ERR_HTTP2_PROTOCOL_ERROR, + "Server reset stream."); // TODO(mbelshe): Map from Spdy-protocol errors to something sensical. // For now, it doesn't matter much - it is a protocol error. CloseActiveStreamIterator(it, ERR_HTTP2_PROTOCOL_ERROR); @@ -3142,7 +3140,7 @@ void SpdySession::OnGoAway(spdy::SpdyStreamId last_accepted_stream_id, } else if (error_code == spdy::ERROR_CODE_NO_ERROR) { StartGoingAway(last_accepted_stream_id, ERR_HTTP2_SERVER_REFUSED_STREAM); } else { - StartGoingAway(last_accepted_stream_id, ERR_ABORTED); + StartGoingAway(last_accepted_stream_id, ERR_HTTP2_PROTOCOL_ERROR); } // This is to handle the case when we already don't have any active // streams (i.e., StartGoingAway() did nothing). Otherwise, we have @@ -3174,11 +3172,10 @@ void SpdySession::OnStreamFrameData(spdy::SpdyStreamId stream_id, size_t len) { CHECK(in_io_loop_); DCHECK_LT(len, 1u << 24); - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_RECV_DATA, [&] { - return NetLogSpdyDataParams(stream_id, len, false); - }); - } + + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_DATA, [&] { + return NetLogSpdyDataParams(stream_id, len, false); + }); // Build the buffer as early as possible so that we go through the // session flow control checks and update @@ -3213,11 +3210,8 @@ void SpdySession::OnStreamFrameData(spdy::SpdyStreamId stream_id, void SpdySession::OnStreamEnd(spdy::SpdyStreamId stream_id) { CHECK(in_io_loop_); - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_RECV_DATA, [&] { - return NetLogSpdyDataParams(stream_id, 0, true); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_DATA, + [&] { return NetLogSpdyDataParams(stream_id, 0, true); }); auto it = active_streams_.find(stream_id); // By the time data comes in, the stream may already be inactive. @@ -3249,10 +3243,8 @@ void SpdySession::OnStreamPadding(spdy::SpdyStreamId stream_id, size_t len) { void SpdySession::OnSettings() { CHECK(in_io_loop_); - if (net_log_.IsCapturing()) { - net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_SETTINGS); - net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_SEND_SETTINGS_ACK); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_SETTINGS); + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_SEND_SETTINGS_ACK); // Send an acknowledgment of the setting. spdy::SpdySettingsIR settings_ir; @@ -3265,8 +3257,7 @@ void SpdySession::OnSettings() { void SpdySession::OnSettingsAck() { CHECK(in_io_loop_); - if (net_log_.IsCapturing()) - net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_SETTINGS_ACK); + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_SETTINGS_ACK); } void SpdySession::OnSetting(spdy::SpdySettingsId id, uint32_t value) { @@ -3329,14 +3320,12 @@ void SpdySession::OnPushPromise(spdy::SpdyStreamId stream_id, spdy::SpdyHeaderBlock headers) { CHECK(in_io_loop_); - if (net_log_.IsCapturing()) { - net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_PUSH_PROMISE, - [&](NetLogCaptureMode capture_mode) { - return NetLogSpdyPushPromiseReceivedParams( - &headers, stream_id, promised_stream_id, - capture_mode); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_PUSH_PROMISE, + [&](NetLogCaptureMode capture_mode) { + return NetLogSpdyPushPromiseReceivedParams( + &headers, stream_id, promised_stream_id, + capture_mode); + }); TryCreatePushStream(promised_stream_id, stream_id, std::move(headers)); } @@ -3351,13 +3340,11 @@ void SpdySession::OnHeaders(spdy::SpdyStreamId stream_id, base::TimeTicks recv_first_byte_time) { CHECK(in_io_loop_); - if (net_log().IsCapturing()) { - net_log().AddEvent(NetLogEventType::HTTP2_SESSION_RECV_HEADERS, - [&](NetLogCaptureMode capture_mode) { - return NetLogSpdyHeadersReceivedParams( - &headers, fin, stream_id, capture_mode); - }); - } + net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_RECV_HEADERS, + [&](NetLogCaptureMode capture_mode) { + return NetLogSpdyHeadersReceivedParams( + &headers, fin, stream_id, capture_mode); + }); auto it = active_streams_.find(stream_id); if (it == active_streams_.end()) { @@ -3412,7 +3399,8 @@ void SpdySession::OnAltSvc( if (!GetSSLInfo(&ssl_info)) return; if (!CanPool(transport_security_state_, ssl_info, *ssl_config_service_, - host_port_pair().host(), gurl.host())) { + host_port_pair().host(), gurl.host(), + spdy_session_key_.network_isolation_key())) { return; } scheme_host_port = url::SchemeHostPort(gurl); |