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/quic/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
6 | 6 |
7 #include "net/quic/quic_session.h" | 7 #include "net/quic/quic_session.h" |
8 | 8 |
9 using base::StringPiece; | 9 using base::StringPiece; |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 bool ReliableQuicStream::IsHalfClosed() const { | 85 bool ReliableQuicStream::IsHalfClosed() const { |
86 return sequencer_.IsHalfClosed(); | 86 return sequencer_.IsHalfClosed(); |
87 } | 87 } |
88 | 88 |
89 bool ReliableQuicStream::HasBytesToRead() const { | 89 bool ReliableQuicStream::HasBytesToRead() const { |
90 return sequencer_.HasBytesToRead(); | 90 return sequencer_.HasBytesToRead(); |
91 } | 91 } |
92 | 92 |
| 93 const IPEndPoint& ReliableQuicStream::GetPeerAddress() const { |
| 94 return session_->peer_address(); |
| 95 } |
| 96 |
93 int ReliableQuicStream::WriteData(StringPiece data, bool fin) { | 97 int ReliableQuicStream::WriteData(StringPiece data, bool fin) { |
94 if (write_side_closed_) { | 98 if (write_side_closed_) { |
95 DLOG(ERROR) << "Attempt to write when the write side is closed"; | 99 DLOG(ERROR) << "Attempt to write when the write side is closed"; |
96 return 0; | 100 return 0; |
97 } | 101 } |
98 | 102 |
99 session()->WriteData(id(), data, offset_, fin); | 103 int rv = session()->WriteData(id(), data, offset_, fin); |
100 offset_ += data.length(); | 104 offset_ += data.length(); |
101 if (fin) { | 105 if (fin) { |
102 CloseWriteSide(); | 106 CloseWriteSide(); |
103 } | 107 } |
104 return data.length(); | 108 return rv; |
105 } | 109 } |
106 | 110 |
107 void ReliableQuicStream::CloseReadSide() { | 111 void ReliableQuicStream::CloseReadSide() { |
108 if (read_side_closed_) { | 112 if (read_side_closed_) { |
109 return; | 113 return; |
110 } | 114 } |
111 DLOG(INFO) << "Done reading from stream " << id(); | 115 DLOG(INFO) << "Done reading from stream " << id(); |
112 | 116 |
113 read_side_closed_ = true; | 117 read_side_closed_ = true; |
114 if (write_side_closed_) { | 118 if (write_side_closed_) { |
| 119 DLOG(INFO) << "Closing stream: " << id(); |
115 session_->CloseStream(id()); | 120 session_->CloseStream(id()); |
116 } | 121 } |
117 } | 122 } |
118 | 123 |
119 void ReliableQuicStream::CloseWriteSide() { | 124 void ReliableQuicStream::CloseWriteSide() { |
120 if (write_side_closed_) { | 125 if (write_side_closed_) { |
121 return; | 126 return; |
122 } | 127 } |
123 DLOG(INFO) << "Done writing to stream " << id(); | 128 DLOG(INFO) << "Done writing to stream " << id(); |
124 | 129 |
125 write_side_closed_ = true; | 130 write_side_closed_ = true; |
126 if (read_side_closed_) { | 131 if (read_side_closed_) { |
| 132 DLOG(INFO) << "Closing stream: " << id(); |
127 session_->CloseStream(id()); | 133 session_->CloseStream(id()); |
128 } | 134 } |
129 } | 135 } |
130 | 136 |
131 } // namespace net | 137 } // namespace net |
OLD | NEW |