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

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

Issue 283693002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 QUIC_PEER_GOING_AWAY, ""); 76 QUIC_PEER_GOING_AWAY, "");
77 } 77 }
78 } 78 }
79 79
80 bool QuicClient::Initialize() { 80 bool QuicClient::Initialize() {
81 DCHECK(!initialized_); 81 DCHECK(!initialized_);
82 82
83 epoll_server_.set_timeout_in_us(50 * 1000); 83 epoll_server_.set_timeout_in_us(50 * 1000);
84 crypto_config_.SetDefaults(); 84 crypto_config_.SetDefaults();
85 85
86 if (!CreateUDPSocket()) {
87 return false;
88 }
89
90 epoll_server_.RegisterFD(fd_, this, kEpollFlags);
91 initialized_ = true;
92 return true;
93 }
94
95 bool QuicClient::CreateUDPSocket() {
86 int address_family = server_address_.GetSockAddrFamily(); 96 int address_family = server_address_.GetSockAddrFamily();
87 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); 97 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
88 if (fd_ < 0) { 98 if (fd_ < 0) {
89 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); 99 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno);
90 return false; 100 return false;
91 } 101 }
92 102
93 int get_overflow = 1; 103 int get_overflow = 1;
94 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow, 104 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
95 sizeof(get_overflow)); 105 sizeof(get_overflow));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 LOG(ERROR) << "Bind failed: " << strerror(errno); 156 LOG(ERROR) << "Bind failed: " << strerror(errno);
147 return false; 157 return false;
148 } 158 }
149 159
150 SockaddrStorage storage; 160 SockaddrStorage storage;
151 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || 161 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 ||
152 !client_address_.FromSockAddr(storage.addr, storage.addr_len)) { 162 !client_address_.FromSockAddr(storage.addr, storage.addr_len)) {
153 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); 163 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno);
154 } 164 }
155 165
156 epoll_server_.RegisterFD(fd_, this, kEpollFlags);
157 initialized_ = true;
158 return true; 166 return true;
159 } 167 }
160 168
161 bool QuicClient::Connect() { 169 bool QuicClient::Connect() {
162 if (!StartConnect()) { 170 if (!StartConnect()) {
163 return false; 171 return false;
164 } 172 }
165 while (EncryptionBeingEstablished()) { 173 while (EncryptionBeingEstablished()) {
166 WaitForEvents(); 174 WaitForEvents();
167 } 175 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 QuicEncryptedPacket packet(buf, bytes_read, false); 345 QuicEncryptedPacket packet(buf, bytes_read, false);
338 346
339 IPEndPoint client_address(client_ip, client_address_.port()); 347 IPEndPoint client_address(client_ip, client_address_.port());
340 session_->connection()->ProcessUdpPacket( 348 session_->connection()->ProcessUdpPacket(
341 client_address, server_address, packet); 349 client_address, server_address, packet);
342 return true; 350 return true;
343 } 351 }
344 352
345 } // namespace tools 353 } // namespace tools
346 } // namespace net 354 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698