Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: net/spdy/spdy_session.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 case RST_STREAM_INVALID_CREDENTIALS: 391 case RST_STREAM_INVALID_CREDENTIALS:
392 return STATUS_CODE_INVALID_CREDENTIALS; 392 return STATUS_CODE_INVALID_CREDENTIALS;
393 case RST_STREAM_FRAME_SIZE_ERROR: 393 case RST_STREAM_FRAME_SIZE_ERROR:
394 return STATUS_CODE_FRAME_SIZE_ERROR; 394 return STATUS_CODE_FRAME_SIZE_ERROR;
395 case RST_STREAM_SETTINGS_TIMEOUT: 395 case RST_STREAM_SETTINGS_TIMEOUT:
396 return STATUS_CODE_SETTINGS_TIMEOUT; 396 return STATUS_CODE_SETTINGS_TIMEOUT;
397 case RST_STREAM_CONNECT_ERROR: 397 case RST_STREAM_CONNECT_ERROR:
398 return STATUS_CODE_CONNECT_ERROR; 398 return STATUS_CODE_CONNECT_ERROR;
399 case RST_STREAM_ENHANCE_YOUR_CALM: 399 case RST_STREAM_ENHANCE_YOUR_CALM:
400 return STATUS_CODE_ENHANCE_YOUR_CALM; 400 return STATUS_CODE_ENHANCE_YOUR_CALM;
401 case RST_STREAM_INADEQUATE_SECURITY:
402 return STATUS_CODE_INADEQUATE_SECURITY;
403 case RST_STREAM_HTTP_1_1_REQUIRED:
404 return STATUS_CODE_HTTP_1_1_REQUIRED;
401 default: 405 default:
402 NOTREACHED(); 406 NOTREACHED();
403 return static_cast<SpdyProtocolErrorDetails>(-1); 407 return static_cast<SpdyProtocolErrorDetails>(-1);
404 } 408 }
405 } 409 }
406 410
407 SpdyGoAwayStatus MapNetErrorToGoAwayStatus(Error err) { 411 SpdyGoAwayStatus MapNetErrorToGoAwayStatus(Error err) {
408 switch (err) { 412 switch (err) {
409 case OK: 413 case OK:
410 return GOAWAY_NO_ERROR; 414 return GOAWAY_NO_ERROR;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 certificate_error_code_ = certificate_error_code; 718 certificate_error_code_ = certificate_error_code;
715 719
716 NextProto protocol_negotiated = 720 NextProto protocol_negotiated =
717 connection_->socket()->GetNegotiatedProtocol(); 721 connection_->socket()->GetNegotiatedProtocol();
718 if (protocol_negotiated != kProtoUnknown) { 722 if (protocol_negotiated != kProtoUnknown) {
719 protocol_ = protocol_negotiated; 723 protocol_ = protocol_negotiated;
720 } 724 }
721 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); 725 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion);
722 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); 726 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion);
723 727
724 if (protocol_ == kProtoSPDY4) 728 if ((protocol_ >= kProtoSPDY4MinimumVersion) &&
729 (protocol_ <= kProtoSPDY4MaximumVersion))
725 send_connection_header_prefix_ = true; 730 send_connection_header_prefix_ = true;
726 731
727 if (protocol_ >= kProtoSPDY31) { 732 if (protocol_ >= kProtoSPDY31) {
728 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; 733 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION;
729 session_send_window_size_ = kSpdySessionInitialWindowSize; 734 session_send_window_size_ = kSpdySessionInitialWindowSize;
730 session_recv_window_size_ = kSpdySessionInitialWindowSize; 735 session_recv_window_size_ = kSpdySessionInitialWindowSize;
731 } else if (protocol_ >= kProtoSPDY3) { 736 } else if (protocol_ >= kProtoSPDY3) {
732 flow_control_state_ = FLOW_CONTROL_STREAM; 737 flow_control_state_ = FLOW_CONTROL_STREAM;
733 } else { 738 } else {
734 flow_control_state_ = FLOW_CONTROL_NONE; 739 flow_control_state_ = FLOW_CONTROL_NONE;
735 } 740 }
736 741
737 buffered_spdy_framer_.reset( 742 buffered_spdy_framer_.reset(
738 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), 743 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_),
739 enable_compression_)); 744 enable_compression_));
740 buffered_spdy_framer_->set_visitor(this); 745 buffered_spdy_framer_->set_visitor(this);
741 buffered_spdy_framer_->set_debug_visitor(this); 746 buffered_spdy_framer_->set_debug_visitor(this);
742 UMA_HISTOGRAM_ENUMERATION( 747 UMA_HISTOGRAM_ENUMERATION(
743 "Net.SpdyVersion2", 748 "Net.SpdyVersion2",
744 protocol_ - kProtoSPDYMinimumVersion, 749 protocol_ - kProtoSPDYHistogramOffset,
745 kProtoSPDYMaximumVersion - kProtoSPDYMinimumVersion + 1); 750 kProtoSPDYMaximumVersion - kProtoSPDYMinimumVersion + 1);
746 751
747 net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_INITIALIZED, 752 net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_INITIALIZED,
748 base::Bind(&NetLogSpdyInitializedCallback, 753 base::Bind(&NetLogSpdyInitializedCallback,
749 connection_->socket()->NetLog().source(), 754 connection_->socket()->NetLog().source(),
750 protocol_)); 755 protocol_));
751 756
752 DCHECK_EQ(availability_state_, STATE_AVAILABLE); 757 DCHECK_EQ(availability_state_, STATE_AVAILABLE);
753 connection_->AddHigherLayeredPool(this); 758 connection_->AddHigherLayeredPool(this);
754 if (enable_sending_initial_data_) 759 if (enable_sending_initial_data_)
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 } 2203 }
2199 2204
2200 void SpdySession::OnSynStream(SpdyStreamId stream_id, 2205 void SpdySession::OnSynStream(SpdyStreamId stream_id,
2201 SpdyStreamId associated_stream_id, 2206 SpdyStreamId associated_stream_id,
2202 SpdyPriority priority, 2207 SpdyPriority priority,
2203 bool fin, 2208 bool fin,
2204 bool unidirectional, 2209 bool unidirectional,
2205 const SpdyHeaderBlock& headers) { 2210 const SpdyHeaderBlock& headers) {
2206 CHECK(in_io_loop_); 2211 CHECK(in_io_loop_);
2207 2212
2208 if (GetProtocolVersion() >= SPDY4) { 2213 DCHECK_LE(GetProtocolVersion(), SPDY3);
2209 DCHECK_EQ(0u, associated_stream_id);
2210 OnHeaders(stream_id, fin, headers);
2211 return;
2212 }
2213 2214
2214 base::Time response_time = base::Time::Now(); 2215 base::Time response_time = base::Time::Now();
2215 base::TimeTicks recv_first_byte_time = time_func_(); 2216 base::TimeTicks recv_first_byte_time = time_func_();
2216 2217
2217 if (net_log_.IsLogging()) { 2218 if (net_log_.IsLogging()) {
2218 net_log_.AddEvent( 2219 net_log_.AddEvent(
2219 NetLog::TYPE_SPDY_SESSION_PUSHED_SYN_STREAM, 2220 NetLog::TYPE_SPDY_SESSION_PUSHED_SYN_STREAM,
2220 base::Bind(&NetLogSpdySynStreamReceivedCallback, 2221 base::Bind(&NetLogSpdySynStreamReceivedCallback,
2221 &headers, fin, unidirectional, priority, 2222 &headers, fin, unidirectional, priority,
2222 stream_id, associated_stream_id)); 2223 stream_id, associated_stream_id));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); 2326 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error);
2326 return; 2327 return;
2327 } 2328 }
2328 it->second.waiting_for_syn_reply = false; 2329 it->second.waiting_for_syn_reply = false;
2329 2330
2330 ignore_result(OnInitialResponseHeadersReceived( 2331 ignore_result(OnInitialResponseHeadersReceived(
2331 headers, response_time, recv_first_byte_time, stream)); 2332 headers, response_time, recv_first_byte_time, stream));
2332 } 2333 }
2333 2334
2334 void SpdySession::OnHeaders(SpdyStreamId stream_id, 2335 void SpdySession::OnHeaders(SpdyStreamId stream_id,
2336 bool has_priority,
2337 SpdyPriority priority,
2335 bool fin, 2338 bool fin,
2336 const SpdyHeaderBlock& headers) { 2339 const SpdyHeaderBlock& headers) {
2337 CHECK(in_io_loop_); 2340 CHECK(in_io_loop_);
2338 2341
2339 if (net_log().IsLogging()) { 2342 if (net_log().IsLogging()) {
2340 net_log().AddEvent( 2343 net_log().AddEvent(
2341 NetLog::TYPE_SPDY_SESSION_RECV_HEADERS, 2344 NetLog::TYPE_SPDY_SESSION_RECV_HEADERS,
2342 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, 2345 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback,
2343 &headers, fin, stream_id)); 2346 &headers, fin, stream_id));
2344 } 2347 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 } 2455 }
2453 2456
2454 void SpdySession::OnPing(SpdyPingId unique_id, bool is_ack) { 2457 void SpdySession::OnPing(SpdyPingId unique_id, bool is_ack) {
2455 CHECK(in_io_loop_); 2458 CHECK(in_io_loop_);
2456 2459
2457 net_log_.AddEvent( 2460 net_log_.AddEvent(
2458 NetLog::TYPE_SPDY_SESSION_PING, 2461 NetLog::TYPE_SPDY_SESSION_PING,
2459 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "received")); 2462 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "received"));
2460 2463
2461 // Send response to a PING from server. 2464 // Send response to a PING from server.
2462 if ((protocol_ >= kProtoSPDY4 && !is_ack) || 2465 if ((protocol_ >= kProtoSPDY4MinimumVersion && !is_ack) ||
2463 (protocol_ < kProtoSPDY4 && unique_id % 2 == 0)) { 2466 (protocol_ < kProtoSPDY4MinimumVersion && unique_id % 2 == 0)) {
2464 WritePingFrame(unique_id, true); 2467 WritePingFrame(unique_id, true);
2465 return; 2468 return;
2466 } 2469 }
2467 2470
2468 --pings_in_flight_; 2471 --pings_in_flight_;
2469 if (pings_in_flight_ < 0) { 2472 if (pings_in_flight_ < 0) {
2470 RecordProtocolErrorHistogram(PROTOCOL_ERROR_UNEXPECTED_PING); 2473 RecordProtocolErrorHistogram(PROTOCOL_ERROR_UNEXPECTED_PING);
2471 DoDrainSession(ERR_SPDY_PROTOCOL_ERROR, "pings_in_flight_ is < 0."); 2474 DoDrainSession(ERR_SPDY_PROTOCOL_ERROR, "pings_in_flight_ is < 0.");
2472 pings_in_flight_ = 0; 2475 pings_in_flight_ = 0;
2473 return; 2476 return;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 CHECK(it != active_streams_.end()); 2742 CHECK(it != active_streams_.end());
2740 CHECK_EQ(it->second.stream->stream_id(), stream_id); 2743 CHECK_EQ(it->second.stream->stream_id(), stream_id);
2741 SendWindowUpdateFrame( 2744 SendWindowUpdateFrame(
2742 stream_id, delta_window_size, it->second.stream->priority()); 2745 stream_id, delta_window_size, it->second.stream->priority());
2743 } 2746 }
2744 2747
2745 void SpdySession::SendInitialData() { 2748 void SpdySession::SendInitialData() {
2746 DCHECK(enable_sending_initial_data_); 2749 DCHECK(enable_sending_initial_data_);
2747 2750
2748 if (send_connection_header_prefix_) { 2751 if (send_connection_header_prefix_) {
2749 DCHECK_EQ(protocol_, kProtoSPDY4); 2752 DCHECK_GE(protocol_, kProtoSPDY4MinimumVersion);
2753 DCHECK_LE(protocol_, kProtoSPDY4MaximumVersion);
2750 scoped_ptr<SpdyFrame> connection_header_prefix_frame( 2754 scoped_ptr<SpdyFrame> connection_header_prefix_frame(
2751 new SpdyFrame(const_cast<char*>(kHttp2ConnectionHeaderPrefix), 2755 new SpdyFrame(const_cast<char*>(kHttp2ConnectionHeaderPrefix),
2752 kHttp2ConnectionHeaderPrefixSize, 2756 kHttp2ConnectionHeaderPrefixSize,
2753 false /* take_ownership */)); 2757 false /* take_ownership */));
2754 // Count the prefix as part of the subsequent SETTINGS frame. 2758 // Count the prefix as part of the subsequent SETTINGS frame.
2755 EnqueueSessionWrite(HIGHEST, SETTINGS, 2759 EnqueueSessionWrite(HIGHEST, SETTINGS,
2756 connection_header_prefix_frame.Pass()); 2760 connection_header_prefix_frame.Pass());
2757 } 2761 }
2758 2762
2759 // First, notify the server about the settings they should use when 2763 // First, notify the server about the settings they should use when
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 if (!queue->empty()) { 3262 if (!queue->empty()) {
3259 SpdyStreamId stream_id = queue->front(); 3263 SpdyStreamId stream_id = queue->front();
3260 queue->pop_front(); 3264 queue->pop_front();
3261 return stream_id; 3265 return stream_id;
3262 } 3266 }
3263 } 3267 }
3264 return 0; 3268 return 0;
3265 } 3269 }
3266 3270
3267 } // namespace net 3271 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698