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

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

Issue 498373002: Refactor pooling logic into a helper method Disable pooling when there are cert errors. Disable poo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: 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
« no previous file with comments | « net/quic/quic_client_session.h ('k') | net/quic/quic_client_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_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/transport_security_state.h"
16 #include "net/quic/crypto/proof_verifier_chromium.h" 17 #include "net/quic/crypto/proof_verifier_chromium.h"
17 #include "net/quic/crypto/quic_server_info.h" 18 #include "net/quic/crypto/quic_server_info.h"
18 #include "net/quic/quic_connection_helper.h" 19 #include "net/quic/quic_connection_helper.h"
19 #include "net/quic/quic_crypto_client_stream_factory.h" 20 #include "net/quic/quic_crypto_client_stream_factory.h"
20 #include "net/quic/quic_default_packet_writer.h" 21 #include "net/quic/quic_default_packet_writer.h"
21 #include "net/quic/quic_server_id.h" 22 #include "net/quic/quic_server_id.h"
22 #include "net/quic/quic_stream_factory.h" 23 #include "net/quic/quic_stream_factory.h"
24 #include "net/spdy/spdy_session.h"
23 #include "net/ssl/channel_id_service.h" 25 #include "net/ssl/channel_id_service.h"
24 #include "net/ssl/ssl_connection_status_flags.h" 26 #include "net/ssl/ssl_connection_status_flags.h"
25 #include "net/ssl/ssl_info.h" 27 #include "net/ssl/ssl_info.h"
26 #include "net/udp/datagram_client_socket.h" 28 #include "net/udp/datagram_client_socket.h"
27 29
28 namespace net { 30 namespace net {
29 31
30 namespace { 32 namespace {
31 33
32 // The length of time to wait for a 0-RTT handshake to complete 34 // 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(); 133 session_.reset();
132 ResetAndReturn(&callback_).Run(rv); 134 ResetAndReturn(&callback_).Run(rv);
133 } 135 }
134 136
135 QuicClientSession::QuicClientSession( 137 QuicClientSession::QuicClientSession(
136 QuicConnection* connection, 138 QuicConnection* connection,
137 scoped_ptr<DatagramClientSocket> socket, 139 scoped_ptr<DatagramClientSocket> socket,
138 scoped_ptr<QuicDefaultPacketWriter> writer, 140 scoped_ptr<QuicDefaultPacketWriter> writer,
139 QuicStreamFactory* stream_factory, 141 QuicStreamFactory* stream_factory,
140 QuicCryptoClientStreamFactory* crypto_client_stream_factory, 142 QuicCryptoClientStreamFactory* crypto_client_stream_factory,
143 TransportSecurityState* transport_security_state,
141 scoped_ptr<QuicServerInfo> server_info, 144 scoped_ptr<QuicServerInfo> server_info,
142 const QuicServerId& server_id, 145 const QuicServerId& server_id,
143 const QuicConfig& config, 146 const QuicConfig& config,
144 QuicCryptoClientConfig* crypto_config, 147 QuicCryptoClientConfig* crypto_config,
145 base::TaskRunner* task_runner, 148 base::TaskRunner* task_runner,
146 NetLog* net_log) 149 NetLog* net_log)
147 : QuicClientSessionBase(connection, config), 150 : QuicClientSessionBase(connection, config),
148 server_host_port_(server_id.host_port_pair()), 151 server_host_port_(server_id.host_port_pair()),
149 require_confirmation_(false), 152 require_confirmation_(false),
150 stream_factory_(stream_factory), 153 stream_factory_(stream_factory),
151 socket_(socket.Pass()), 154 socket_(socket.Pass()),
152 writer_(writer.Pass()), 155 writer_(writer.Pass()),
153 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), 156 read_buffer_(new IOBufferWithSize(kMaxPacketSize)),
157 transport_security_state_(transport_security_state),
154 server_info_(server_info.Pass()), 158 server_info_(server_info.Pass()),
155 read_pending_(false), 159 read_pending_(false),
156 num_total_streams_(0), 160 num_total_streams_(0),
157 task_runner_(task_runner), 161 task_runner_(task_runner),
158 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), 162 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)),
159 logger_(new QuicConnectionLogger(net_log_)), 163 logger_(new QuicConnectionLogger(net_log_)),
160 num_packets_read_(0), 164 num_packets_read_(0),
161 going_away_(false), 165 going_away_(false),
162 weak_factory_(this) { 166 weak_factory_(this) {
163 crypto_stream_.reset( 167 crypto_stream_.reset(
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 486 }
483 487
484 bool QuicClientSession::CanPool(const std::string& hostname) const { 488 bool QuicClientSession::CanPool(const std::string& hostname) const {
485 DCHECK(connection()->connected()); 489 DCHECK(connection()->connected());
486 SSLInfo ssl_info; 490 SSLInfo ssl_info;
487 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) { 491 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) {
488 // We can always pool with insecure QUIC sessions. 492 // We can always pool with insecure QUIC sessions.
489 return true; 493 return true;
490 } 494 }
491 495
492 // Disable pooling for secure sessions. 496 return SpdySession::CanPool(transport_security_state_, ssl_info,
493 // TODO(rch): re-enable this. 497 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 } 498 }
515 499
516 QuicDataStream* QuicClientSession::CreateIncomingDataStream( 500 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
517 QuicStreamId id) { 501 QuicStreamId id) {
518 DLOG(ERROR) << "Server push not supported"; 502 DLOG(ERROR) << "Server push not supported";
519 return NULL; 503 return NULL;
520 } 504 }
521 505
522 void QuicClientSession::CloseStream(QuicStreamId stream_id) { 506 void QuicClientSession::CloseStream(QuicStreamId stream_id) {
523 ReliableQuicStream* stream = GetStream(stream_id); 507 ReliableQuicStream* stream = GetStream(stream_id);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 return; 841 return;
858 842
859 // TODO(rch): re-enable this code once beta is cut. 843 // TODO(rch): re-enable this code once beta is cut.
860 // if (stream_factory_) 844 // if (stream_factory_)
861 // stream_factory_->OnSessionConnectTimeout(this); 845 // stream_factory_->OnSessionConnectTimeout(this);
862 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); 846 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED);
863 // DCHECK_EQ(0u, GetNumOpenStreams()); 847 // DCHECK_EQ(0u, GetNumOpenStreams());
864 } 848 }
865 849
866 } // namespace net 850 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_client_session.h ('k') | net/quic/quic_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698