OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/quic/p2p/quic_p2p_session.h" | 5 #include "net/quic/p2p/quic_p2p_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/ip_address.h" | 11 #include "net/base/ip_address.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/quic/p2p/quic_p2p_crypto_stream.h" | 13 #include "net/quic/p2p/quic_p2p_crypto_stream.h" |
14 #include "net/quic/p2p/quic_p2p_stream.h" | 14 #include "net/quic/p2p/quic_p2p_stream.h" |
15 #include "net/quic/quic_connection.h" | 15 #include "net/quic/quic_connection.h" |
16 #include "net/socket/socket.h" | 16 #include "net/socket/socket.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 QuicP2PSession::QuicP2PSession(const QuicConfig& config, | 20 QuicP2PSession::QuicP2PSession(const QuicConfig& config, |
21 const QuicP2PCryptoConfig& crypto_config, | 21 const QuicP2PCryptoConfig& crypto_config, |
22 std::unique_ptr<QuicConnection> connection, | 22 std::unique_ptr<QuicConnection> connection, |
23 std::unique_ptr<Socket> socket) | 23 std::unique_ptr<Socket> socket) |
24 : QuicSession(connection.release(), config), | 24 : QuicSession(connection.release(), config), |
25 socket_(std::move(socket)), | 25 socket_(std::move(socket)), |
26 crypto_stream_(new QuicP2PCryptoStream(this, crypto_config)), | 26 crypto_stream_(new QuicP2PCryptoStream(this, crypto_config)), |
27 read_buffer_(new IOBuffer(static_cast<size_t>(kMaxPacketSize))) { | 27 read_buffer_(new IOBuffer(static_cast<size_t>(kMaxPacketSize))) { |
28 DCHECK(config.negotiated()); | 28 DCHECK(config.negotiated()); |
29 | |
30 // Non-null IP address needs to be passed here because QuicConnection uses | |
31 // ToString() to format addresses for logging and ToString() is not allowed | |
32 // for empty addresses. | |
33 // TODO(sergeyu): Fix QuicConnection and remove SetSelfAddress() call below. | |
34 this->connection()->SetSelfAddress(IPEndPoint(IPAddress::IPv4AllZeros(), 0)); | |
35 } | 29 } |
36 | 30 |
37 QuicP2PSession::~QuicP2PSession() {} | 31 QuicP2PSession::~QuicP2PSession() {} |
38 | 32 |
39 void QuicP2PSession::Initialize() { | 33 void QuicP2PSession::Initialize() { |
40 QuicSession::Initialize(); | 34 QuicSession::Initialize(); |
41 crypto_stream_->Connect(); | 35 crypto_stream_->Connect(); |
42 DoReadLoop(OK); | 36 DoReadLoop(OK); |
43 } | 37 } |
44 | 38 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return result; | 119 return result; |
126 } | 120 } |
127 | 121 |
128 QuicReceivedPacket packet(read_buffer_->data(), result, clock_.Now()); | 122 QuicReceivedPacket packet(read_buffer_->data(), result, clock_.Now()); |
129 connection()->ProcessUdpPacket(connection()->self_address(), | 123 connection()->ProcessUdpPacket(connection()->self_address(), |
130 connection()->peer_address(), packet); | 124 connection()->peer_address(), packet); |
131 return OK; | 125 return OK; |
132 } | 126 } |
133 | 127 |
134 } // namespace net | 128 } // namespace net |
OLD | NEW |