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

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

Issue 724523002: Support HTTP/2 drafts 14 and 15 simultaneously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename CONNECTION_INFO_SPDY4 to CONNECTION_INFO_HTTP2. 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_proxy_client_socket_unittest.cc ('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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 certificate_error_code_ = certificate_error_code; 714 certificate_error_code_ = certificate_error_code;
715 715
716 NextProto protocol_negotiated = 716 NextProto protocol_negotiated =
717 connection_->socket()->GetNegotiatedProtocol(); 717 connection_->socket()->GetNegotiatedProtocol();
718 if (protocol_negotiated != kProtoUnknown) { 718 if (protocol_negotiated != kProtoUnknown) {
719 protocol_ = protocol_negotiated; 719 protocol_ = protocol_negotiated;
720 } 720 }
721 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); 721 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion);
722 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); 722 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion);
723 723
724 if (protocol_ == kProtoSPDY4) 724 if ((protocol_ >= kProtoSPDY4MinimumVersion) &&
725 (protocol_ <= kProtoSPDY4MaximumVersion))
725 send_connection_header_prefix_ = true; 726 send_connection_header_prefix_ = true;
726 727
727 if (protocol_ >= kProtoSPDY31) { 728 if (protocol_ >= kProtoSPDY31) {
728 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; 729 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION;
729 session_send_window_size_ = kSpdySessionInitialWindowSize; 730 session_send_window_size_ = kSpdySessionInitialWindowSize;
730 session_recv_window_size_ = kSpdySessionInitialWindowSize; 731 session_recv_window_size_ = kSpdySessionInitialWindowSize;
731 } else if (protocol_ >= kProtoSPDY3) { 732 } else if (protocol_ >= kProtoSPDY3) {
732 flow_control_state_ = FLOW_CONTROL_STREAM; 733 flow_control_state_ = FLOW_CONTROL_STREAM;
733 } else { 734 } else {
734 flow_control_state_ = FLOW_CONTROL_NONE; 735 flow_control_state_ = FLOW_CONTROL_NONE;
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 } 2451 }
2451 2452
2452 void SpdySession::OnPing(SpdyPingId unique_id, bool is_ack) { 2453 void SpdySession::OnPing(SpdyPingId unique_id, bool is_ack) {
2453 CHECK(in_io_loop_); 2454 CHECK(in_io_loop_);
2454 2455
2455 net_log_.AddEvent( 2456 net_log_.AddEvent(
2456 NetLog::TYPE_SPDY_SESSION_PING, 2457 NetLog::TYPE_SPDY_SESSION_PING,
2457 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "received")); 2458 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "received"));
2458 2459
2459 // Send response to a PING from server. 2460 // Send response to a PING from server.
2460 if ((protocol_ >= kProtoSPDY4 && !is_ack) || 2461 if ((protocol_ >= kProtoSPDY4MinimumVersion && !is_ack) ||
2461 (protocol_ < kProtoSPDY4 && unique_id % 2 == 0)) { 2462 (protocol_ < kProtoSPDY4MinimumVersion && unique_id % 2 == 0)) {
2462 WritePingFrame(unique_id, true); 2463 WritePingFrame(unique_id, true);
2463 return; 2464 return;
2464 } 2465 }
2465 2466
2466 --pings_in_flight_; 2467 --pings_in_flight_;
2467 if (pings_in_flight_ < 0) { 2468 if (pings_in_flight_ < 0) {
2468 RecordProtocolErrorHistogram(PROTOCOL_ERROR_UNEXPECTED_PING); 2469 RecordProtocolErrorHistogram(PROTOCOL_ERROR_UNEXPECTED_PING);
2469 DoDrainSession(ERR_SPDY_PROTOCOL_ERROR, "pings_in_flight_ is < 0."); 2470 DoDrainSession(ERR_SPDY_PROTOCOL_ERROR, "pings_in_flight_ is < 0.");
2470 pings_in_flight_ = 0; 2471 pings_in_flight_ = 0;
2471 return; 2472 return;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 CHECK(it != active_streams_.end()); 2738 CHECK(it != active_streams_.end());
2738 CHECK_EQ(it->second.stream->stream_id(), stream_id); 2739 CHECK_EQ(it->second.stream->stream_id(), stream_id);
2739 SendWindowUpdateFrame( 2740 SendWindowUpdateFrame(
2740 stream_id, delta_window_size, it->second.stream->priority()); 2741 stream_id, delta_window_size, it->second.stream->priority());
2741 } 2742 }
2742 2743
2743 void SpdySession::SendInitialData() { 2744 void SpdySession::SendInitialData() {
2744 DCHECK(enable_sending_initial_data_); 2745 DCHECK(enable_sending_initial_data_);
2745 2746
2746 if (send_connection_header_prefix_) { 2747 if (send_connection_header_prefix_) {
2747 DCHECK_EQ(protocol_, kProtoSPDY4); 2748 DCHECK_GE(protocol_, kProtoSPDY4MinimumVersion);
2749 DCHECK_LE(protocol_, kProtoSPDY4MaximumVersion);
2748 scoped_ptr<SpdyFrame> connection_header_prefix_frame( 2750 scoped_ptr<SpdyFrame> connection_header_prefix_frame(
2749 new SpdyFrame(const_cast<char*>(kHttp2ConnectionHeaderPrefix), 2751 new SpdyFrame(const_cast<char*>(kHttp2ConnectionHeaderPrefix),
2750 kHttp2ConnectionHeaderPrefixSize, 2752 kHttp2ConnectionHeaderPrefixSize,
2751 false /* take_ownership */)); 2753 false /* take_ownership */));
2752 // Count the prefix as part of the subsequent SETTINGS frame. 2754 // Count the prefix as part of the subsequent SETTINGS frame.
2753 EnqueueSessionWrite(HIGHEST, SETTINGS, 2755 EnqueueSessionWrite(HIGHEST, SETTINGS,
2754 connection_header_prefix_frame.Pass()); 2756 connection_header_prefix_frame.Pass());
2755 } 2757 }
2756 2758
2757 // First, notify the server about the settings they should use when 2759 // First, notify the server about the settings they should use when
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 if (!queue->empty()) { 3258 if (!queue->empty()) {
3257 SpdyStreamId stream_id = queue->front(); 3259 SpdyStreamId stream_id = queue->front();
3258 queue->pop_front(); 3260 queue->pop_front();
3259 return stream_id; 3261 return stream_id;
3260 } 3262 }
3261 } 3263 }
3262 return 0; 3264 return 0;
3263 } 3265 }
3264 3266
3265 } // namespace net 3267 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698