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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 void QuicP2PStream::OnCanWrite() { | 44 void QuicP2PStream::OnCanWrite() { |
45 ReliableQuicStream::OnCanWrite(); | 45 ReliableQuicStream::OnCanWrite(); |
46 | 46 |
47 if (!HasBufferedData() && !write_callback_.is_null()) { | 47 if (!HasBufferedData() && !write_callback_.is_null()) { |
48 base::ResetAndReturn(&write_callback_).Run(last_write_size_); | 48 base::ResetAndReturn(&write_callback_).Run(last_write_size_); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 QuicPriority QuicP2PStream::EffectivePriority() const { | 52 QuicPriority QuicP2PStream::Priority() const { |
53 return priority_; | 53 return priority_; |
54 } | 54 } |
55 | 55 |
56 void QuicP2PStream::WriteHeader(base::StringPiece data) { | 56 void QuicP2PStream::WriteHeader(base::StringPiece data) { |
57 WriteOrBufferData(data, false, nullptr); | 57 WriteOrBufferData(data, false, nullptr); |
58 } | 58 } |
59 | 59 |
60 int QuicP2PStream::Write(base::StringPiece data, | 60 int QuicP2PStream::Write(base::StringPiece data, |
61 const CompletionCallback& callback) { | 61 const CompletionCallback& callback) { |
62 DCHECK(write_callback_.is_null()); | 62 DCHECK(write_callback_.is_null()); |
63 | 63 |
64 // Writes the data, or buffers it. | 64 // Writes the data, or buffers it. |
65 WriteOrBufferData(data, false, nullptr); | 65 WriteOrBufferData(data, false, nullptr); |
66 if (!HasBufferedData()) { | 66 if (!HasBufferedData()) { |
67 return data.size(); | 67 return data.size(); |
68 } | 68 } |
69 | 69 |
70 write_callback_ = callback; | 70 write_callback_ = callback; |
71 last_write_size_ = data.size(); | 71 last_write_size_ = data.size(); |
72 return ERR_IO_PENDING; | 72 return ERR_IO_PENDING; |
73 } | 73 } |
74 | 74 |
75 void QuicP2PStream::SetDelegate(QuicP2PStream::Delegate* delegate) { | 75 void QuicP2PStream::SetDelegate(QuicP2PStream::Delegate* delegate) { |
76 DCHECK(!(delegate_ && delegate)); | 76 DCHECK(!(delegate_ && delegate)); |
77 delegate_ = delegate; | 77 delegate_ = delegate; |
78 } | 78 } |
79 | 79 |
80 } // namespace net | 80 } // namespace net |
OLD | NEW |