| OLD | NEW |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 local_port_(0), | 51 local_port_(0), |
| 52 fd_(-1), | 52 fd_(-1), |
| 53 initialized_(false), | 53 initialized_(false), |
| 54 packets_dropped_(0), | 54 packets_dropped_(0), |
| 55 overflow_supported_(false) { | 55 overflow_supported_(false) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 QuicClient::~QuicClient() { | 58 QuicClient::~QuicClient() { |
| 59 if (connected()) { | 59 if (connected()) { |
| 60 session()->connection()->SendConnectionClosePacket( | 60 session()->connection()->SendConnectionClosePacket( |
| 61 QUIC_PEER_GOING_AWAY, string()); | 61 QUIC_PEER_GOING_AWAY, ""); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool QuicClient::Initialize() { | 65 bool QuicClient::Initialize() { |
| 66 DCHECK(!initialized_); | 66 DCHECK(!initialized_); |
| 67 | 67 |
| 68 epoll_server_.set_timeout_in_us(50 * 1000); | 68 epoll_server_.set_timeout_in_us(50 * 1000); |
| 69 crypto_config_.SetDefaults(); | 69 crypto_config_.SetDefaults(); |
| 70 | 70 |
| 71 int address_family = server_address_.GetSockAddrFamily(); | 71 int address_family = server_address_.GetSockAddrFamily(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 for (int i = 1; i < argc; ++i) { | 176 for (int i = 1; i < argc; ++i) { |
| 177 BalsaHeaders headers; | 177 BalsaHeaders headers; |
| 178 headers.SetRequestFirstlineFromStringPieces("GET", argv[i], "HTTP/1.1"); | 178 headers.SetRequestFirstlineFromStringPieces("GET", argv[i], "HTTP/1.1"); |
| 179 CreateReliableClientStream()->SendRequest(headers, "", true); | 179 CreateReliableClientStream()->SendRequest(headers, "", true); |
| 180 } | 180 } |
| 181 | 181 |
| 182 while (WaitForEvents()) { } | 182 while (WaitForEvents()) { } |
| 183 } | 183 } |
| 184 | 184 |
| 185 QuicReliableClientStream* QuicClient::CreateReliableClientStream() { | 185 QuicReliableClientStream* QuicClient::CreateReliableClientStream() { |
| 186 DCHECK(connected()); | 186 if (!connected()) { |
| 187 return NULL; |
| 188 } |
| 187 | 189 |
| 188 return session_->CreateOutgoingReliableStream(); | 190 return session_->CreateOutgoingReliableStream(); |
| 189 } | 191 } |
| 190 | 192 |
| 191 void QuicClient::WaitForStreamToClose(QuicStreamId id) { | 193 void QuicClient::WaitForStreamToClose(QuicStreamId id) { |
| 192 DCHECK(connected()); | 194 DCHECK(connected()); |
| 193 | 195 |
| 194 while (!session_->IsClosedStream(id)) { | 196 while (!session_->IsClosedStream(id)) { |
| 195 epoll_server_.WaitForEventsAndExecuteCallbacks(); | 197 epoll_server_.WaitForEventsAndExecuteCallbacks(); |
| 196 } | 198 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 263 } |
| 262 | 264 |
| 263 IPEndPoint client_address(client_ip, client_address_.port()); | 265 IPEndPoint client_address(client_ip, client_address_.port()); |
| 264 session_->connection()->ProcessUdpPacket( | 266 session_->connection()->ProcessUdpPacket( |
| 265 client_address, server_address, packet); | 267 client_address, server_address, packet); |
| 266 return true; | 268 return true; |
| 267 } | 269 } |
| 268 | 270 |
| 269 } // namespace tools | 271 } // namespace tools |
| 270 } // namespace net | 272 } // namespace net |
| OLD | NEW |