| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 initialized_ = false; | 228 initialized_ = false; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void QuicClient::SendRequestsAndWaitForResponse( | 231 void QuicClient::SendRequestsAndWaitForResponse( |
| 232 const base::CommandLine::StringVector& args) { | 232 const base::CommandLine::StringVector& args) { |
| 233 for (size_t i = 0; i < args.size(); ++i) { | 233 for (size_t i = 0; i < args.size(); ++i) { |
| 234 BalsaHeaders headers; | 234 BalsaHeaders headers; |
| 235 headers.SetRequestFirstlineFromStringPieces("GET", args[i], "HTTP/1.1"); | 235 headers.SetRequestFirstlineFromStringPieces("GET", args[i], "HTTP/1.1"); |
| 236 QuicSpdyClientStream* stream = CreateReliableClientStream(); | 236 QuicSpdyClientStream* stream = CreateReliableClientStream(); |
| 237 DCHECK(stream != nullptr); | 237 DCHECK(stream != nullptr); |
| 238 if (stream == nullptr) { |
| 239 LOG(ERROR) << "stream creation failed!"; |
| 240 break; |
| 241 } |
| 238 stream->SendRequest(headers, "", true); | 242 stream->SendRequest(headers, "", true); |
| 239 stream->set_visitor(this); | 243 stream->set_visitor(this); |
| 240 } | 244 } |
| 241 | 245 |
| 242 while (WaitForEvents()) {} | 246 while (WaitForEvents()) {} |
| 243 } | 247 } |
| 244 | 248 |
| 245 QuicSpdyClientStream* QuicClient::CreateReliableClientStream() { | 249 QuicSpdyClientStream* QuicClient::CreateReliableClientStream() { |
| 246 if (!connected()) { | 250 if (!connected()) { |
| 247 return nullptr; | 251 return nullptr; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 i->second.as_string().c_str()); | 314 i->second.as_string().c_str()); |
| 311 } | 315 } |
| 312 printf("%s\n", client_stream->data().c_str()); | 316 printf("%s\n", client_stream->data().c_str()); |
| 313 } | 317 } |
| 314 | 318 |
| 315 bool QuicClient::connected() const { | 319 bool QuicClient::connected() const { |
| 316 return session_.get() && session_->connection() && | 320 return session_.get() && session_->connection() && |
| 317 session_->connection()->connected(); | 321 session_->connection()->connected(); |
| 318 } | 322 } |
| 319 | 323 |
| 324 bool QuicClient::goaway_received() const { |
| 325 return session_ != nullptr && session_->goaway_received(); |
| 326 } |
| 327 |
| 320 QuicConnectionId QuicClient::GenerateConnectionId() { | 328 QuicConnectionId QuicClient::GenerateConnectionId() { |
| 321 return QuicRandom::GetInstance()->RandUint64(); | 329 return QuicRandom::GetInstance()->RandUint64(); |
| 322 } | 330 } |
| 323 | 331 |
| 324 QuicEpollConnectionHelper* QuicClient::CreateQuicConnectionHelper() { | 332 QuicEpollConnectionHelper* QuicClient::CreateQuicConnectionHelper() { |
| 325 return new QuicEpollConnectionHelper(epoll_server_); | 333 return new QuicEpollConnectionHelper(epoll_server_); |
| 326 } | 334 } |
| 327 | 335 |
| 328 QuicPacketWriter* QuicClient::CreateQuicPacketWriter() { | 336 QuicPacketWriter* QuicClient::CreateQuicPacketWriter() { |
| 329 return new QuicDefaultPacketWriter(fd_); | 337 return new QuicDefaultPacketWriter(fd_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 356 QuicEncryptedPacket packet(buf, bytes_read, false); | 364 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 357 | 365 |
| 358 IPEndPoint client_address(client_ip, client_address_.port()); | 366 IPEndPoint client_address(client_ip, client_address_.port()); |
| 359 session_->connection()->ProcessUdpPacket( | 367 session_->connection()->ProcessUdpPacket( |
| 360 client_address, server_address, packet); | 368 client_address, server_address, packet); |
| 361 return true; | 369 return true; |
| 362 } | 370 } |
| 363 | 371 |
| 364 } // namespace tools | 372 } // namespace tools |
| 365 } // namespace net | 373 } // namespace net |
| OLD | NEW |