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

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

Issue 425803014: Refactor pooling logic into a helper method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add QUIC test Created 6 years, 4 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 | Annotate | Revision Log
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_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/http/http_util.h"
Ryan Sleevi 2014/08/11 18:45:17 No longer needed
Ryan Hamilton 2014/08/12 14:39:06 Done.
17 #include "net/http/transport_security_state.h"
16 #include "net/quic/crypto/proof_verifier_chromium.h" 18 #include "net/quic/crypto/proof_verifier_chromium.h"
17 #include "net/quic/crypto/quic_server_info.h" 19 #include "net/quic/crypto/quic_server_info.h"
18 #include "net/quic/quic_connection_helper.h" 20 #include "net/quic/quic_connection_helper.h"
19 #include "net/quic/quic_crypto_client_stream_factory.h" 21 #include "net/quic/quic_crypto_client_stream_factory.h"
20 #include "net/quic/quic_default_packet_writer.h" 22 #include "net/quic/quic_default_packet_writer.h"
21 #include "net/quic/quic_server_id.h" 23 #include "net/quic/quic_server_id.h"
22 #include "net/quic/quic_stream_factory.h" 24 #include "net/quic/quic_stream_factory.h"
25 #include "net/spdy/spdy_session.h"
23 #include "net/ssl/channel_id_service.h" 26 #include "net/ssl/channel_id_service.h"
24 #include "net/ssl/ssl_connection_status_flags.h" 27 #include "net/ssl/ssl_connection_status_flags.h"
25 #include "net/ssl/ssl_info.h" 28 #include "net/ssl/ssl_info.h"
26 #include "net/udp/datagram_client_socket.h" 29 #include "net/udp/datagram_client_socket.h"
27 30
28 namespace net { 31 namespace net {
29 32
30 namespace { 33 namespace {
31 34
32 // The length of time to wait for a 0-RTT handshake to complete 35 // The length of time to wait for a 0-RTT handshake to complete
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 session_.reset(); 134 session_.reset();
132 ResetAndReturn(&callback_).Run(rv); 135 ResetAndReturn(&callback_).Run(rv);
133 } 136 }
134 137
135 QuicClientSession::QuicClientSession( 138 QuicClientSession::QuicClientSession(
136 QuicConnection* connection, 139 QuicConnection* connection,
137 scoped_ptr<DatagramClientSocket> socket, 140 scoped_ptr<DatagramClientSocket> socket,
138 scoped_ptr<QuicDefaultPacketWriter> writer, 141 scoped_ptr<QuicDefaultPacketWriter> writer,
139 QuicStreamFactory* stream_factory, 142 QuicStreamFactory* stream_factory,
140 QuicCryptoClientStreamFactory* crypto_client_stream_factory, 143 QuicCryptoClientStreamFactory* crypto_client_stream_factory,
144 TransportSecurityState* transport_security_state,
141 scoped_ptr<QuicServerInfo> server_info, 145 scoped_ptr<QuicServerInfo> server_info,
142 const QuicServerId& server_id, 146 const QuicServerId& server_id,
143 const QuicConfig& config, 147 const QuicConfig& config,
144 QuicCryptoClientConfig* crypto_config, 148 QuicCryptoClientConfig* crypto_config,
145 base::TaskRunner* task_runner, 149 base::TaskRunner* task_runner,
146 NetLog* net_log) 150 NetLog* net_log)
147 : QuicClientSessionBase(connection, config), 151 : QuicClientSessionBase(connection, config),
148 server_host_port_(server_id.host_port_pair()), 152 server_host_port_(server_id.host_port_pair()),
149 require_confirmation_(false), 153 require_confirmation_(false),
150 stream_factory_(stream_factory), 154 stream_factory_(stream_factory),
151 socket_(socket.Pass()), 155 socket_(socket.Pass()),
152 writer_(writer.Pass()), 156 writer_(writer.Pass()),
153 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), 157 read_buffer_(new IOBufferWithSize(kMaxPacketSize)),
158 transport_security_state_(transport_security_state),
154 server_info_(server_info.Pass()), 159 server_info_(server_info.Pass()),
155 read_pending_(false), 160 read_pending_(false),
156 num_total_streams_(0), 161 num_total_streams_(0),
157 task_runner_(task_runner), 162 task_runner_(task_runner),
158 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), 163 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)),
159 logger_(new QuicConnectionLogger(net_log_)), 164 logger_(new QuicConnectionLogger(net_log_)),
160 num_packets_read_(0), 165 num_packets_read_(0),
161 going_away_(false), 166 going_away_(false),
162 weak_factory_(this) { 167 weak_factory_(this) {
163 crypto_stream_.reset( 168 crypto_stream_.reset(
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 487 }
483 488
484 bool QuicClientSession::CanPool(const std::string& hostname) const { 489 bool QuicClientSession::CanPool(const std::string& hostname) const {
485 DCHECK(connection()->connected()); 490 DCHECK(connection()->connected());
486 SSLInfo ssl_info; 491 SSLInfo ssl_info;
487 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) { 492 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) {
488 // We can always pool with insecure QUIC sessions. 493 // We can always pool with insecure QUIC sessions.
489 return true; 494 return true;
490 } 495 }
491 496
492 // Disable pooling for secure sessions. 497 return SpdySession::CanPool(transport_security_state_, ssl_info,
493 // TODO(rch): re-enable this. 498 server_host_port_.host(), hostname);
494 return false;
495 #if 0
496 bool unused = false;
497 // Pooling is prohibited if the server cert is not valid for the new domain,
498 // and for connections on which client certs were sent. It is also prohibited
499 // when channel ID was sent if the hosts are from different eTLDs+1.
500 if (!ssl_info.cert->VerifyNameMatch(hostname, &unused))
501 return false;
502
503 if (ssl_info.client_cert_sent)
504 return false;
505
506 if (ssl_info.channel_id_sent &&
507 ChannelIDService::GetDomainForHost(hostname) !=
508 ChannelIDService::GetDomainForHost(server_host_port_.host())) {
509 return false;
510 }
511
512 return true;
513 #endif
514 } 499 }
515 500
516 QuicDataStream* QuicClientSession::CreateIncomingDataStream( 501 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
517 QuicStreamId id) { 502 QuicStreamId id) {
518 DLOG(ERROR) << "Server push not supported"; 503 DLOG(ERROR) << "Server push not supported";
519 return NULL; 504 return NULL;
520 } 505 }
521 506
522 void QuicClientSession::CloseStream(QuicStreamId stream_id) { 507 void QuicClientSession::CloseStream(QuicStreamId stream_id) {
523 ReliableQuicStream* stream = GetStream(stream_id); 508 ReliableQuicStream* stream = GetStream(stream_id);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 return; 842 return;
858 843
859 // TODO(rch): re-enable this code once beta is cut. 844 // TODO(rch): re-enable this code once beta is cut.
860 // if (stream_factory_) 845 // if (stream_factory_)
861 // stream_factory_->OnSessionConnectTimeout(this); 846 // stream_factory_->OnSessionConnectTimeout(this);
862 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); 847 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED);
863 // DCHECK_EQ(0u, GetNumOpenStreams()); 848 // DCHECK_EQ(0u, GetNumOpenStreams());
864 } 849 }
865 850
866 } // namespace net 851 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698