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

Side by Side Diff: net/quic/p2p/quic_p2p_session.cc

Issue 1273233002: Implement QuicChannel and QuicChannelFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | net/quic/p2p/quic_p2p_stream.cc » ('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 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 "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/quic/p2p/quic_p2p_crypto_stream.h" 10 #include "net/quic/p2p/quic_p2p_crypto_stream.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 QuicP2PStream* stream = new QuicP2PStream(GetNextStreamId(), this); 60 QuicP2PStream* stream = new QuicP2PStream(GetNextStreamId(), this);
61 if (stream) { 61 if (stream) {
62 ActivateStream(stream); 62 ActivateStream(stream);
63 } 63 }
64 return stream; 64 return stream;
65 } 65 }
66 66
67 void QuicP2PSession::OnConnectionClosed(QuicErrorCode error, bool from_peer) { 67 void QuicP2PSession::OnConnectionClosed(QuicErrorCode error, bool from_peer) {
68 QuicSession::OnConnectionClosed(error, from_peer); 68 QuicSession::OnConnectionClosed(error, from_peer);
69 69
70 socket_.reset();
71
70 if (delegate_) { 72 if (delegate_) {
71 Delegate* delegate = delegate_; 73 Delegate* delegate = delegate_;
72 delegate_ = nullptr; 74 delegate_ = nullptr;
73 delegate->OnConnectionClosed(error); 75 delegate->OnConnectionClosed(error);
74 } 76 }
75 } 77 }
76 78
77 void QuicP2PSession::DoReadLoop(int result) { 79 void QuicP2PSession::DoReadLoop(int result) {
78 while (error() == net::QUIC_NO_ERROR) { 80 while (error() == net::QUIC_NO_ERROR) {
79 switch (read_state_) { 81 switch (read_state_) {
(...skipping 11 matching lines...) Expand all
91 93
92 if (result < 0) 94 if (result < 0)
93 break; 95 break;
94 } 96 }
95 } 97 }
96 98
97 int QuicP2PSession::DoRead() { 99 int QuicP2PSession::DoRead() {
98 DCHECK_EQ(read_state_, READ_STATE_DO_READ); 100 DCHECK_EQ(read_state_, READ_STATE_DO_READ);
99 read_state_ = READ_STATE_DO_READ_COMPLETE; 101 read_state_ = READ_STATE_DO_READ_COMPLETE;
100 102
103 if (!socket_) {
104 return net::ERR_SOCKET_NOT_CONNECTED;
105 }
Ryan Hamilton 2015/08/12 02:59:16 Looks like there are behavior changes in this file
Sergey Ulanov 2015/08/12 17:09:31 Yes. Added a test now.
106
101 return socket_->Read( 107 return socket_->Read(
102 read_buffer_.get(), kMaxPacketSize, 108 read_buffer_.get(), kMaxPacketSize,
103 base::Bind(&QuicP2PSession::DoReadLoop, base::Unretained(this))); 109 base::Bind(&QuicP2PSession::DoReadLoop, base::Unretained(this)));
104 } 110 }
105 111
106 int QuicP2PSession::DoReadComplete(int result) { 112 int QuicP2PSession::DoReadComplete(int result) {
107 DCHECK_EQ(read_state_, READ_STATE_DO_READ_COMPLETE); 113 DCHECK_EQ(read_state_, READ_STATE_DO_READ_COMPLETE);
108 read_state_ = READ_STATE_DO_READ; 114 read_state_ = READ_STATE_DO_READ;
109 115
110 if (result <= 0) { 116 if (result <= 0) {
111 connection()->CloseConnection(net::QUIC_PACKET_READ_ERROR, false); 117 connection()->CloseConnection(net::QUIC_PACKET_READ_ERROR, false);
112 return result; 118 return result;
113 } 119 }
114 120
115 QuicEncryptedPacket packet(read_buffer_->data(), result); 121 QuicEncryptedPacket packet(read_buffer_->data(), result);
116 connection()->ProcessUdpPacket(connection()->self_address(), 122 connection()->ProcessUdpPacket(connection()->self_address(),
117 connection()->peer_address(), packet); 123 connection()->peer_address(), packet);
118 return OK; 124 return OK;
119 } 125 }
120 126
121 } // namespace net 127 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/p2p/quic_p2p_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698