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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 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
« no previous file with comments | « net/tools/quic/quic_client.h ('k') | net/tools/quic/quic_epoll_clock.h » ('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 21 matching lines...) Expand all
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 : server_address_(server_address), 35 : server_address_(server_address),
36 server_hostname_(server_hostname), 36 server_hostname_(server_hostname),
37 local_port_(0), 37 local_port_(0),
38 fd_(-1), 38 fd_(-1),
39 initialized_(false), 39 initialized_(false),
40 packets_dropped_(0), 40 packets_dropped_(0),
41 overflow_supported_(false) { 41 overflow_supported_(false) {
42 epoll_server_.set_timeout_in_us(50 * 1000);
43 config_.SetDefaults(); 42 config_.SetDefaults();
44 crypto_config_.SetDefaults(); 43 }
44
45 QuicClient::QuicClient(IPEndPoint server_address,
46 const string& server_hostname,
47 const QuicConfig& config)
48 : server_address_(server_address),
49 server_hostname_(server_hostname),
50 config_(config),
51 local_port_(0),
52 fd_(-1),
53 initialized_(false),
54 packets_dropped_(0),
55 overflow_supported_(false) {
45 } 56 }
46 57
47 QuicClient::~QuicClient() { 58 QuicClient::~QuicClient() {
48 if (connected()) { 59 if (connected()) {
49 session()->connection() 60 session()->connection()
50 ->SendConnectionClosePacket(QUIC_PEER_GOING_AWAY, std::string()); 61 ->SendConnectionClosePacket(QUIC_PEER_GOING_AWAY, std::string());
51 } 62 }
52 } 63 }
53 64
54 bool QuicClient::Initialize() { 65 bool QuicClient::Initialize() {
66 epoll_server_.set_timeout_in_us(50 * 1000);
67 crypto_config_.SetDefaults();
55 int address_family = server_address_.GetSockAddrFamily(); 68 int address_family = server_address_.GetSockAddrFamily();
69
56 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); 70 fd_ = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
57 if (fd_ < 0) { 71 if (fd_ < 0) {
58 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); 72 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno);
59 return false; 73 return false;
60 } 74 }
61 75
62 int get_overflow = 1; 76 int get_overflow = 1;
63 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow, 77 int rc = setsockopt(fd_, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
64 sizeof(get_overflow)); 78 sizeof(get_overflow));
65 if (rc < 0) { 79 if (rc < 0) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 258 }
245 259
246 IPEndPoint client_address(client_ip, client_address_.port()); 260 IPEndPoint client_address(client_ip, client_address_.port());
247 session_->connection()->ProcessUdpPacket( 261 session_->connection()->ProcessUdpPacket(
248 client_address, server_address, packet); 262 client_address, server_address, packet);
249 return true; 263 return true;
250 } 264 }
251 265
252 } // namespace tools 266 } // namespace tools
253 } // namespace net 267 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client.h ('k') | net/tools/quic/quic_epoll_clock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698