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

Side by Side Diff: net/quic/quic_session.cc

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 years, 9 months 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/quic/quic_session.h ('k') | net/quic/quic_session_test.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/quic/quic_session.h" 5 #include "net/quic/quic_session.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/proof_verifier.h" 8 #include "net/quic/crypto/proof_verifier.h"
9 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_flow_controller.h" 10 #include "net/quic/quic_flow_controller.h"
11 #include "net/quic/quic_headers_stream.h" 11 #include "net/quic/quic_headers_stream.h"
12 #include "net/ssl/ssl_info.h" 12 #include "net/ssl/ssl_info.h"
13 13
14 using base::StringPiece; 14 using base::StringPiece;
15 using base::hash_map; 15 using base::hash_map;
16 using base::hash_set; 16 using base::hash_set;
17 using std::make_pair; 17 using std::make_pair;
18 using std::map; 18 using std::map;
19 using std::max; 19 using std::max;
20 using std::string; 20 using std::string;
21 using std::vector; 21 using std::vector;
22 22
23 namespace net { 23 namespace net {
24 24
25 #define ENDPOINT (is_server() ? "Server: " : " Client: ") 25 #define ENDPOINT \
26 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ")
26 27
27 // We want to make sure we delete any closed streams in a safe manner. 28 // We want to make sure we delete any closed streams in a safe manner.
28 // To avoid deleting a stream in mid-operation, we have a simple shim between 29 // To avoid deleting a stream in mid-operation, we have a simple shim between
29 // us and the stream, so we can delete any streams when we return from 30 // us and the stream, so we can delete any streams when we return from
30 // processing. 31 // processing.
31 // 32 //
32 // We could just override the base methods, but this makes it easier to make 33 // We could just override the base methods, but this makes it easier to make
33 // sure we don't miss any. 34 // sure we don't miss any.
34 class VisitorShim : public QuicConnectionVisitorInterface { 35 class VisitorShim : public QuicConnectionVisitorInterface {
35 public: 36 public:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 private: 96 private:
96 QuicSession* session_; 97 QuicSession* session_;
97 }; 98 };
98 99
99 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config) 100 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config)
100 : connection_(connection), 101 : connection_(connection),
101 visitor_shim_(new VisitorShim(this)), 102 visitor_shim_(new VisitorShim(this)),
102 config_(config), 103 config_(config),
103 max_open_streams_(config_.MaxStreamsPerConnection()), 104 max_open_streams_(config_.MaxStreamsPerConnection()),
104 next_stream_id_(is_server() ? 2 : 5), 105 next_stream_id_(perspective() == Perspective::IS_SERVER ? 2 : 5),
105 write_blocked_streams_(true), 106 write_blocked_streams_(true),
106 largest_peer_created_stream_id_(0), 107 largest_peer_created_stream_id_(0),
107 error_(QUIC_NO_ERROR), 108 error_(QUIC_NO_ERROR),
108 flow_controller_(new QuicFlowController( 109 flow_controller_(new QuicFlowController(
109 connection_.get(), 110 connection_.get(),
110 0, 111 0,
111 is_server(), 112 perspective(),
112 kMinimumFlowControlSendWindow, 113 kMinimumFlowControlSendWindow,
113 config_.GetInitialSessionFlowControlWindowToSend(), 114 config_.GetInitialSessionFlowControlWindowToSend(),
114 config_.GetInitialSessionFlowControlWindowToSend())), 115 config_.GetInitialSessionFlowControlWindowToSend())),
115 goaway_received_(false), 116 goaway_received_(false),
116 goaway_sent_(false), 117 goaway_sent_(false),
117 has_pending_handshake_(false) { 118 has_pending_handshake_(false) {
118 } 119 }
119 120
120 void QuicSession::InitializeSession() { 121 void QuicSession::InitializeSession() {
121 connection_->set_visitor(visitor_shim_.get()); 122 connection_->set_visitor(visitor_shim_.get());
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 455 }
455 456
456 bool QuicSession::IsCryptoHandshakeConfirmed() { 457 bool QuicSession::IsCryptoHandshakeConfirmed() {
457 return GetCryptoStream()->handshake_confirmed(); 458 return GetCryptoStream()->handshake_confirmed();
458 } 459 }
459 460
460 void QuicSession::OnConfigNegotiated() { 461 void QuicSession::OnConfigNegotiated() {
461 connection_->SetFromConfig(config_); 462 connection_->SetFromConfig(config_);
462 463
463 uint32 max_streams = config_.MaxStreamsPerConnection(); 464 uint32 max_streams = config_.MaxStreamsPerConnection();
464 if (is_server()) { 465 if (perspective() == Perspective::IS_SERVER) {
465 // A server should accept a small number of additional streams beyond the 466 // A server should accept a small number of additional streams beyond the
466 // limit sent to the client. This helps avoid early connection termination 467 // limit sent to the client. This helps avoid early connection termination
467 // when FIN/RSTs for old streams are lost or arrive out of order. 468 // when FIN/RSTs for old streams are lost or arrive out of order.
468 // Use a minimum number of additional streams, or a percentage increase, 469 // Use a minimum number of additional streams, or a percentage increase,
469 // whichever is larger. 470 // whichever is larger.
470 max_streams = 471 max_streams =
471 max(max_streams + kMaxStreamsMinimumIncrement, 472 max(max_streams + kMaxStreamsMinimumIncrement,
472 static_cast<uint32>(max_streams * kMaxStreamsMultiplier)); 473 static_cast<uint32>(max_streams * kMaxStreamsMultiplier));
473 } 474 }
474 set_max_open_streams(max_streams); 475 set_max_open_streams(max_streams);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if (connection()->connected()) { 627 if (connection()->connected()) {
627 LOG(ERROR) << "Trying to get stream: " << stream_id 628 LOG(ERROR) << "Trying to get stream: " << stream_id
628 << ", largest peer created stream: " 629 << ", largest peer created stream: "
629 << largest_peer_created_stream_id_ 630 << largest_peer_created_stream_id_
630 << ", max delta: " << kMaxStreamIdDelta; 631 << ", max delta: " << kMaxStreamIdDelta;
631 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); 632 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID);
632 } 633 }
633 return nullptr; 634 return nullptr;
634 } 635 }
635 if (largest_peer_created_stream_id_ == 0) { 636 if (largest_peer_created_stream_id_ == 0) {
636 if (is_server()) { 637 if (perspective() == Perspective::IS_SERVER) {
637 largest_peer_created_stream_id_ = 3; 638 largest_peer_created_stream_id_ = 3;
638 } else { 639 } else {
639 largest_peer_created_stream_id_ = 1; 640 largest_peer_created_stream_id_ = 1;
640 } 641 }
641 } 642 }
642 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; 643 for (QuicStreamId id = largest_peer_created_stream_id_ + 2;
643 id < stream_id; 644 id < stream_id;
644 id += 2) { 645 id += 2) {
645 implicitly_created_streams_.insert(id); 646 implicitly_created_streams_.insert(id);
646 } 647 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 for (DataStreamMap::iterator it = stream_map_.begin(); 744 for (DataStreamMap::iterator it = stream_map_.begin();
744 it != stream_map_.end(); ++it) { 745 it != stream_map_.end(); ++it) {
745 if (it->second->flow_controller()->IsBlocked()) { 746 if (it->second->flow_controller()->IsBlocked()) {
746 return true; 747 return true;
747 } 748 }
748 } 749 }
749 return false; 750 return false;
750 } 751 }
751 752
752 } // namespace net 753 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.h ('k') | net/quic/quic_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698