| 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_stream.h" | 5 #include "net/quic/p2p/quic_p2p_stream.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/quic/quic_session.h" | 9 #include "net/quic/quic_session.h" |
| 10 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 QuicP2PStream::QuicP2PStream(QuicStreamId id, QuicSession* session) | 14 QuicP2PStream::QuicP2PStream(QuicStreamId id, QuicSession* session) |
| 15 : ReliableQuicStream(id, session) {} | 15 : ReliableQuicStream(id, session) {} |
| 16 | 16 |
| 17 QuicP2PStream::~QuicP2PStream() {} | 17 QuicP2PStream::~QuicP2PStream() {} |
| 18 | 18 |
| 19 void QuicP2PStream::OnDataAvailable() { | 19 void QuicP2PStream::OnDataAvailable() { |
| 20 DCHECK(delegate_); | 20 DCHECK(delegate_); |
| 21 | 21 |
| 22 char buffer[1024]; | |
| 23 struct iovec iov; | 22 struct iovec iov; |
| 24 while (true) { | 23 while (true) { |
| 25 iov.iov_base = buffer; | |
| 26 iov.iov_len = arraysize(buffer); | |
| 27 if (sequencer()->GetReadableRegions(&iov, 1) != 1) { | 24 if (sequencer()->GetReadableRegions(&iov, 1) != 1) { |
| 28 // No more data to read. | 25 // No more data to read. |
| 29 break; | 26 break; |
| 30 } | 27 } |
| 31 delegate_->OnDataReceived(reinterpret_cast<const char*>(iov.iov_base), | 28 delegate_->OnDataReceived(reinterpret_cast<const char*>(iov.iov_base), |
| 32 iov.iov_len); | 29 iov.iov_len); |
| 33 sequencer()->MarkConsumed(iov.iov_len); | 30 sequencer()->MarkConsumed(iov.iov_len); |
| 34 } | 31 } |
| 35 } | 32 } |
| 36 | 33 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 last_write_size_ = data.size(); | 71 last_write_size_ = data.size(); |
| 75 return ERR_IO_PENDING; | 72 return ERR_IO_PENDING; |
| 76 } | 73 } |
| 77 | 74 |
| 78 void QuicP2PStream::SetDelegate(QuicP2PStream::Delegate* delegate) { | 75 void QuicP2PStream::SetDelegate(QuicP2PStream::Delegate* delegate) { |
| 79 DCHECK(!(delegate_ && delegate)); | 76 DCHECK(!(delegate_ && delegate)); |
| 80 delegate_ = delegate; | 77 delegate_ = delegate; |
| 81 } | 78 } |
| 82 | 79 |
| 83 } // namespace net | 80 } // namespace net |
| OLD | NEW |