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

Side by Side Diff: net/tools/quic/quic_client.cc

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 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 | 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/tools/quic/quic_client.h" 5 #include "net/tools/quic/quic_client.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <netinet/in.h> 8 #include <netinet/in.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/epoll.h> 10 #include <sys/epoll.h>
11 #include <sys/socket.h> 11 #include <sys/socket.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "net/quic/crypto/quic_random.h" 15 #include "net/quic/crypto/quic_random.h"
16 #include "net/quic/quic_connection.h" 16 #include "net/quic/quic_connection.h"
17 #include "net/quic/quic_data_reader.h" 17 #include "net/quic/quic_data_reader.h"
18 #include "net/quic/quic_protocol.h" 18 #include "net/quic/quic_protocol.h"
19 #include "net/quic/quic_session_key.h"
19 #include "net/tools/balsa/balsa_headers.h" 20 #include "net/tools/balsa/balsa_headers.h"
20 #include "net/tools/quic/quic_epoll_connection_helper.h" 21 #include "net/tools/quic/quic_epoll_connection_helper.h"
21 #include "net/tools/quic/quic_socket_utils.h" 22 #include "net/tools/quic/quic_socket_utils.h"
22 #include "net/tools/quic/quic_spdy_client_stream.h" 23 #include "net/tools/quic/quic_spdy_client_stream.h"
23 24
24 #ifndef SO_RXQ_OVFL 25 #ifndef SO_RXQ_OVFL
25 #define SO_RXQ_OVFL 40 26 #define SO_RXQ_OVFL 40
26 #endif 27 #endif
27 28
28 namespace net { 29 namespace net {
29 namespace tools { 30 namespace tools {
30 31
31 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; 32 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET;
32 33
33 QuicClient::QuicClient(IPEndPoint server_address, 34 QuicClient::QuicClient(IPEndPoint server_address,
34 const string& server_hostname, 35 const QuicSessionKey& server_key,
35 const QuicVersionVector& supported_versions, 36 const QuicVersionVector& supported_versions,
36 bool print_response) 37 bool print_response)
37 : server_address_(server_address), 38 : server_address_(server_address),
38 server_hostname_(server_hostname), 39 server_key_(server_key),
39 local_port_(0), 40 local_port_(0),
40 fd_(-1), 41 fd_(-1),
41 helper_(CreateQuicConnectionHelper()), 42 helper_(CreateQuicConnectionHelper()),
42 initialized_(false), 43 initialized_(false),
43 packets_dropped_(0), 44 packets_dropped_(0),
44 overflow_supported_(false), 45 overflow_supported_(false),
45 supported_versions_(supported_versions), 46 supported_versions_(supported_versions),
46 print_response_(print_response) { 47 print_response_(print_response) {
47 config_.SetDefaults(); 48 config_.SetDefaults();
48 } 49 }
49 50
50 QuicClient::QuicClient(IPEndPoint server_address, 51 QuicClient::QuicClient(IPEndPoint server_address,
51 const string& server_hostname, 52 const QuicSessionKey& server_key,
52 const QuicConfig& config, 53 const QuicConfig& config,
53 const QuicVersionVector& supported_versions) 54 const QuicVersionVector& supported_versions)
54 : server_address_(server_address), 55 : server_address_(server_address),
55 server_hostname_(server_hostname), 56 server_key_(server_key),
56 config_(config), 57 config_(config),
57 local_port_(0), 58 local_port_(0),
58 fd_(-1), 59 fd_(-1),
59 helper_(CreateQuicConnectionHelper()), 60 helper_(CreateQuicConnectionHelper()),
60 initialized_(false), 61 initialized_(false),
61 packets_dropped_(0), 62 packets_dropped_(0),
62 overflow_supported_(false), 63 overflow_supported_(false),
63 supported_versions_(supported_versions), 64 supported_versions_(supported_versions),
64 print_response_(false) { 65 print_response_(false) {
65 } 66 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool QuicClient::StartConnect() { 156 bool QuicClient::StartConnect() {
156 DCHECK(initialized_); 157 DCHECK(initialized_);
157 DCHECK(!connected()); 158 DCHECK(!connected());
158 159
159 QuicPacketWriter* writer = CreateQuicPacketWriter(); 160 QuicPacketWriter* writer = CreateQuicPacketWriter();
160 if (writer_.get() != writer) { 161 if (writer_.get() != writer) {
161 writer_.reset(writer); 162 writer_.reset(writer);
162 } 163 }
163 164
164 session_.reset(new QuicClientSession( 165 session_.reset(new QuicClientSession(
165 server_hostname_, 166 server_key_,
166 config_, 167 config_,
167 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(), 168 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(),
168 writer_.get(), false, supported_versions_), 169 writer_.get(), false, supported_versions_),
169 &crypto_config_)); 170 &crypto_config_));
170 return session_->CryptoConnect(); 171 return session_->CryptoConnect();
171 } 172 }
172 173
173 bool QuicClient::EncryptionBeingEstablished() { 174 bool QuicClient::EncryptionBeingEstablished() {
174 return !session_->IsEncryptionEstablished() && 175 return !session_->IsEncryptionEstablished() &&
175 session_->connection()->connected(); 176 session_->connection()->connected();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 QuicEncryptedPacket packet(buf, bytes_read, false); 314 QuicEncryptedPacket packet(buf, bytes_read, false);
314 315
315 IPEndPoint client_address(client_ip, client_address_.port()); 316 IPEndPoint client_address(client_ip, client_address_.port());
316 session_->connection()->ProcessUdpPacket( 317 session_->connection()->ProcessUdpPacket(
317 client_address, server_address, packet); 318 client_address, server_address, packet);
318 return true; 319 return true;
319 } 320 }
320 321
321 } // namespace tools 322 } // namespace tools
322 } // namespace net 323 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698