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/quic_chromium_client_stream.h" | 5 #include "net/quic/quic_chromium_client_stream.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 // Writes the data, or buffers it. | 132 // Writes the data, or buffers it. |
133 WriteOrBufferData(data, fin, nullptr); | 133 WriteOrBufferData(data, fin, nullptr); |
134 if (!HasBufferedData()) { | 134 if (!HasBufferedData()) { |
135 return OK; | 135 return OK; |
136 } | 136 } |
137 | 137 |
138 callback_ = callback; | 138 callback_ = callback; |
139 return ERR_IO_PENDING; | 139 return ERR_IO_PENDING; |
140 } | 140 } |
141 | 141 |
142 int QuicChromiumClientStream::WritevStreamData( | |
143 const std::vector<IOBuffer*>& buffers, | |
144 const std::vector<int>& lengths, | |
145 bool fin, | |
146 const CompletionCallback& callback) { | |
147 // We should not have data buffered. | |
Ryan Hamilton
2016/04/26 16:52:16
nit: avoid first person in comments. For example:
xunjieli
2016/04/26 18:11:26
Done.
| |
148 DCHECK(!HasBufferedData()); | |
149 // Writes the data, or buffers it. | |
150 for (size_t i = 0; i < buffers.size(); ++i) { | |
151 bool is_fin = fin && (i == buffers.size() - 1); | |
152 base::StringPiece string_data(buffers[i]->data(), lengths[i]); | |
153 WriteOrBufferData(string_data, is_fin, nullptr); | |
154 } | |
155 if (!HasBufferedData()) { | |
156 return OK; | |
157 } | |
158 | |
159 callback_ = callback; | |
160 return ERR_IO_PENDING; | |
161 } | |
162 | |
142 void QuicChromiumClientStream::SetDelegate( | 163 void QuicChromiumClientStream::SetDelegate( |
143 QuicChromiumClientStream::Delegate* delegate) { | 164 QuicChromiumClientStream::Delegate* delegate) { |
144 DCHECK(!(delegate_ && delegate)); | 165 DCHECK(!(delegate_ && delegate)); |
145 delegate_ = delegate; | 166 delegate_ = delegate; |
146 while (!delegate_tasks_.empty()) { | 167 while (!delegate_tasks_.empty()) { |
147 base::Closure closure = delegate_tasks_.front(); | 168 base::Closure closure = delegate_tasks_.front(); |
148 delegate_tasks_.pop_front(); | 169 delegate_tasks_.pop_front(); |
149 closure.Run(); | 170 closure.Run(); |
150 } | 171 } |
151 if (delegate == nullptr && sequencer()->IsClosed()) { | 172 if (delegate == nullptr && sequencer()->IsClosed()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 } else { | 252 } else { |
232 delegate_tasks_.push_back(closure); | 253 delegate_tasks_.push_back(closure); |
233 } | 254 } |
234 } | 255 } |
235 | 256 |
236 void QuicChromiumClientStream::DisableConnectionMigration() { | 257 void QuicChromiumClientStream::DisableConnectionMigration() { |
237 can_migrate_ = false; | 258 can_migrate_ = false; |
238 } | 259 } |
239 | 260 |
240 } // namespace net | 261 } // namespace net |
OLD | NEW |