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

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

Issue 47283002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_client.h ('k') | net/tools/quic/quic_client_bin.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/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>
(...skipping 14 matching lines...) Expand all
25 #define SO_RXQ_OVFL 40 25 #define SO_RXQ_OVFL 40
26 #endif 26 #endif
27 27
28 namespace net { 28 namespace net {
29 namespace tools { 29 namespace tools {
30 30
31 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; 31 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET;
32 32
33 QuicClient::QuicClient(IPEndPoint server_address, 33 QuicClient::QuicClient(IPEndPoint server_address,
34 const string& server_hostname, 34 const string& server_hostname,
35 const QuicVersion version, 35 const QuicVersionVector& supported_versions,
36 bool print_response) 36 bool print_response)
37 : server_address_(server_address), 37 : server_address_(server_address),
38 server_hostname_(server_hostname), 38 server_hostname_(server_hostname),
39 local_port_(0), 39 local_port_(0),
40 fd_(-1), 40 fd_(-1),
41 helper_(CreateQuicConnectionHelper()), 41 helper_(CreateQuicConnectionHelper()),
42 initialized_(false), 42 initialized_(false),
43 packets_dropped_(0), 43 packets_dropped_(0),
44 overflow_supported_(false), 44 overflow_supported_(false),
45 version_(version), 45 supported_versions_(supported_versions),
46 print_response_(print_response) { 46 print_response_(print_response) {
47 config_.SetDefaults(); 47 config_.SetDefaults();
48 } 48 }
49 49
50 QuicClient::QuicClient(IPEndPoint server_address, 50 QuicClient::QuicClient(IPEndPoint server_address,
51 const string& server_hostname, 51 const string& server_hostname,
52 const QuicConfig& config, 52 const QuicConfig& config,
53 const QuicVersion version) 53 const QuicVersionVector& supported_versions)
54 : server_address_(server_address), 54 : server_address_(server_address),
55 server_hostname_(server_hostname), 55 server_hostname_(server_hostname),
56 config_(config), 56 config_(config),
57 local_port_(0), 57 local_port_(0),
58 fd_(-1), 58 fd_(-1),
59 helper_(CreateQuicConnectionHelper()), 59 helper_(CreateQuicConnectionHelper()),
60 initialized_(false), 60 initialized_(false),
61 packets_dropped_(0), 61 packets_dropped_(0),
62 overflow_supported_(false), 62 overflow_supported_(false),
63 version_(version), 63 supported_versions_(supported_versions),
64 print_response_(false) { 64 print_response_(false) {
65 } 65 }
66 66
67 QuicClient::~QuicClient() { 67 QuicClient::~QuicClient() {
68 if (connected()) { 68 if (connected()) {
69 session()->connection()->SendConnectionClosePacket( 69 session()->connection()->SendConnectionClosePacket(
70 QUIC_PEER_GOING_AWAY, ""); 70 QUIC_PEER_GOING_AWAY, "");
71 } 71 }
72 } 72 }
73 73
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 while (EncryptionBeingEstablished()) { 149 while (EncryptionBeingEstablished()) {
150 WaitForEvents(); 150 WaitForEvents();
151 } 151 }
152 return session_->connection()->connected(); 152 return session_->connection()->connected();
153 } 153 }
154 154
155 bool QuicClient::StartConnect() { 155 bool QuicClient::StartConnect() {
156 DCHECK(!connected() && initialized_); 156 DCHECK(!connected() && initialized_);
157 157
158 if (!writer_.get()) { 158 QuicPacketWriter* writer = CreateQuicPacketWriter();
159 writer_.reset(CreateQuicPacketWriter()); 159 if (writer_.get() != writer) {
160 writer_.reset(writer);
160 } 161 }
162
161 session_.reset(new QuicClientSession( 163 session_.reset(new QuicClientSession(
162 server_hostname_, 164 server_hostname_,
163 config_, 165 config_,
164 new QuicConnection(GenerateGuid(), server_address_, helper_.get(), 166 new QuicConnection(GenerateGuid(), server_address_, helper_.get(),
165 writer_.get(), false, version_), 167 writer_.get(), false, supported_versions_),
166 &crypto_config_)); 168 &crypto_config_));
167 return session_->CryptoConnect(); 169 return session_->CryptoConnect();
168 } 170 }
169 171
170 bool QuicClient::EncryptionBeingEstablished() { 172 bool QuicClient::EncryptionBeingEstablished() {
171 return !session_->IsEncryptionEstablished() && 173 return !session_->IsEncryptionEstablished() &&
172 session_->connection()->connected(); 174 session_->connection()->connected();
173 } 175 }
174 176
175 void QuicClient::Disconnect() { 177 void QuicClient::Disconnect() {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 316 }
315 317
316 IPEndPoint client_address(client_ip, client_address_.port()); 318 IPEndPoint client_address(client_ip, client_address_.port());
317 session_->connection()->ProcessUdpPacket( 319 session_->connection()->ProcessUdpPacket(
318 client_address, server_address, packet); 320 client_address, server_address, packet);
319 return true; 321 return true;
320 } 322 }
321 323
322 } // namespace tools 324 } // namespace tools
323 } // namespace net 325 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client.h ('k') | net/tools/quic/quic_client_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698