| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 WaitForEvents(); | 171 WaitForEvents(); |
| 172 } | 172 } |
| 173 return session_->connection()->connected(); | 173 return session_->connection()->connected(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool QuicClient::StartConnect() { | 176 bool QuicClient::StartConnect() { |
| 177 DCHECK(initialized_); | 177 DCHECK(initialized_); |
| 178 DCHECK(!connected()); | 178 DCHECK(!connected()); |
| 179 | 179 |
| 180 QuicPacketWriter* writer = CreateQuicPacketWriter(); | 180 QuicPacketWriter* writer = CreateQuicPacketWriter(); |
| 181 |
| 182 session_.reset(new QuicClientSession( |
| 183 config_, |
| 184 new QuicConnection(GenerateConnectionId(), |
| 185 server_address_, |
| 186 helper_.get(), |
| 187 writer, |
| 188 false /* owns_writer */, |
| 189 false /* is_server */, |
| 190 supported_versions_))); |
| 191 // Reset |writer_| after |session_| so that the old writer outlives the old |
| 192 // session. |
| 181 if (writer_.get() != writer) { | 193 if (writer_.get() != writer) { |
| 182 writer_.reset(writer); | 194 writer_.reset(writer); |
| 183 } | 195 } |
| 184 | |
| 185 session_.reset(new QuicClientSession( | |
| 186 config_, | |
| 187 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(), | |
| 188 writer_.get(), false, supported_versions_))); | |
| 189 session_->InitializeSession(server_id_, &crypto_config_); | 196 session_->InitializeSession(server_id_, &crypto_config_); |
| 190 return session_->CryptoConnect(); | 197 return session_->CryptoConnect(); |
| 191 } | 198 } |
| 192 | 199 |
| 193 bool QuicClient::EncryptionBeingEstablished() { | 200 bool QuicClient::EncryptionBeingEstablished() { |
| 194 return !session_->IsEncryptionEstablished() && | 201 return !session_->IsEncryptionEstablished() && |
| 195 session_->connection()->connected(); | 202 session_->connection()->connected(); |
| 196 } | 203 } |
| 197 | 204 |
| 198 void QuicClient::Disconnect() { | 205 void QuicClient::Disconnect() { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 QuicEncryptedPacket packet(buf, bytes_read, false); | 341 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 335 | 342 |
| 336 IPEndPoint client_address(client_ip, client_address_.port()); | 343 IPEndPoint client_address(client_ip, client_address_.port()); |
| 337 session_->connection()->ProcessUdpPacket( | 344 session_->connection()->ProcessUdpPacket( |
| 338 client_address, server_address, packet); | 345 client_address, server_address, packet); |
| 339 return true; | 346 return true; |
| 340 } | 347 } |
| 341 | 348 |
| 342 } // namespace tools | 349 } // namespace tools |
| 343 } // namespace net | 350 } // namespace net |
| OLD | NEW |