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

Unified Diff: net/quic/core/quic_headers_stream.cc

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_headers_stream.h ('k') | net/quic/core/quic_headers_stream_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_headers_stream.cc
diff --git a/net/quic/core/quic_headers_stream.cc b/net/quic/core/quic_headers_stream.cc
index 83f3031f9edd6a59805e2826cec46e0a2eebb7a2..53ca278304e390499e874e2ecf6fabc995e6139e 100644
--- a/net/quic/core/quic_headers_stream.cc
+++ b/net/quic/core/quic_headers_stream.cc
@@ -369,6 +369,25 @@ size_t QuicHeadersStream::WritePushPromise(QuicStreamId original_stream_id,
return frame.size();
}
+void QuicHeadersStream::WriteDataFrame(
+ QuicStreamId id,
+ StringPiece data,
+ bool fin,
+ QuicAckListenerInterface* ack_notifier_delegate) {
+ SpdyDataIR spdy_data(id, data);
+ spdy_data.set_fin(fin);
+ SpdySerializedFrame frame(spdy_framer_.SerializeFrame(spdy_data));
+ scoped_refptr<ForceHolAckListener> ack_listener;
+ if (ack_notifier_delegate != nullptr) {
+ ack_listener = new ForceHolAckListener(ack_notifier_delegate,
+ frame.size() - data.length());
+ }
+ // Use buffered writes so that coherence of framing is preserved
+ // between streams.
+ WriteOrBufferData(StringPiece(frame.data(), frame.size()), false,
+ ack_listener.get());
+}
+
QuicConsumedData QuicHeadersStream::WritevStreamData(
QuicStreamId id,
QuicIOVector iov,
@@ -381,48 +400,92 @@ QuicConsumedData QuicHeadersStream::WritevStreamData(
QuicConsumedData result(0, false);
size_t total_length = iov.total_length;
- // Encapsulate the data into HTTP/2 DATA frames. The outer loop
- // handles each element of the source iov, the inner loop handles
- // the possibility of fragmenting eacho of those into multiple DATA
- // frames, as the DATA frames have a max size of 16KB.
- for (int i = 0; i < iov.iov_count; i++) {
- size_t offset = 0;
- const struct iovec* src_iov = &iov.iov[i];
- do {
- size_t len =
- std::min(std::min(src_iov->iov_len - offset, max_len), total_length);
- char* data = static_cast<char*>(src_iov->iov_base) + offset;
- SpdyDataIR spdy_data(id, StringPiece(data, len));
- offset += len;
- // fin handling, set it only it only very last generated HTTP/2
- // DATA frame.
- bool last_iov = i == iov.iov_count - 1;
- bool last_fragment_within_iov = offset >= src_iov->iov_len;
- bool frame_fin = (last_iov && last_fragment_within_iov) ? fin : false;
- spdy_data.set_fin(frame_fin);
- if (frame_fin) {
- result.fin_consumed = true;
- }
- SpdySerializedFrame frame(spdy_framer_.SerializeFrame(spdy_data));
- DVLOG(1) << "Encapsulating in DATA frame for stream " << id << " len "
- << len << " fin " << spdy_data.fin() << " remaining "
- << src_iov->iov_len - offset;
-
- scoped_refptr<ForceHolAckListener> ack_listener;
- if (ack_notifier_delegate != nullptr) {
- ack_listener =
- new ForceHolAckListener(ack_notifier_delegate, frame.size() - len);
- }
+ if (!FLAGS_quic_bugfix_fhol_writev_fin_only_v2) {
+ // Encapsulate the data into HTTP/2 DATA frames. The outer loop
+ // handles each element of the source iov, the inner loop handles
+ // the possibility of fragmenting eacho of those into multiple DATA
+ // frames, as the DATA frames have a max size of 16KB.
+ for (int i = 0; i < iov.iov_count; i++) {
+ size_t offset = 0;
+ const struct iovec* src_iov = &iov.iov[i];
+ do {
+ size_t len = std::min(std::min(src_iov->iov_len - offset, max_len),
+ total_length);
+ char* data = static_cast<char*>(src_iov->iov_base) + offset;
+ SpdyDataIR spdy_data(id, StringPiece(data, len));
+ offset += len;
+ // fin handling, only set it for the final HTTP/2 DATA frame.
+ bool last_iov = i == iov.iov_count - 1;
+ bool last_fragment_within_iov = offset >= src_iov->iov_len;
+ bool frame_fin = (last_iov && last_fragment_within_iov) ? fin : false;
+ spdy_data.set_fin(frame_fin);
+ if (frame_fin) {
+ result.fin_consumed = true;
+ }
+ SpdySerializedFrame frame(spdy_framer_.SerializeFrame(spdy_data));
+ DVLOG(1) << "Encapsulating in DATA frame for stream " << id << " len "
+ << len << " fin " << spdy_data.fin() << " remaining "
+ << src_iov->iov_len - offset;
+
+ scoped_refptr<ForceHolAckListener> ack_listener;
+ if (ack_notifier_delegate != nullptr) {
+ ack_listener = new ForceHolAckListener(ack_notifier_delegate,
+ frame.size() - len);
+ }
- WriteOrBufferData(StringPiece(frame.data(), frame.size()), false,
- ack_listener.get());
- result.bytes_consumed += len;
- total_length -= len;
- if (total_length <= 0) {
- return result;
- }
- } while (offset < src_iov->iov_len);
+ WriteOrBufferData(StringPiece(frame.data(), frame.size()), false,
+ ack_listener.get());
+ result.bytes_consumed += len;
+ total_length -= len;
+ if (total_length <= 0) {
+ return result;
+ }
+ } while (offset < src_iov->iov_len);
+ }
+ } else {
+ if (total_length == 0 && fin) {
+ WriteDataFrame(id, StringPiece(), true, ack_notifier_delegate);
+ result.fin_consumed = true;
+ return result;
+ }
+
+ // Encapsulate the data into HTTP/2 DATA frames. The outer loop
+ // handles each element of the source iov, the inner loop handles
+ // the possibility of fragmenting each of those into multiple DATA
+ // frames, as the DATA frames have a max size of 16KB.
+ for (int i = 0; i < iov.iov_count; i++) {
+ size_t src_iov_offset = 0;
+ const struct iovec* src_iov = &iov.iov[i];
+ do {
+ if (queued_data_bytes() > 0) {
+ // Limit the amount of buffering to the minimum needed to
+ // preserve framing.
+ return result;
+ }
+ size_t len = std::min(
+ std::min(src_iov->iov_len - src_iov_offset, max_len), total_length);
+ char* data = static_cast<char*>(src_iov->iov_base) + src_iov_offset;
+ src_iov_offset += len;
+ offset += len;
+ // fin handling, only set it for the final HTTP/2 DATA frame.
+ bool last_iov = i == iov.iov_count - 1;
+ bool last_fragment_within_iov = src_iov_offset >= src_iov->iov_len;
+ bool frame_fin = (last_iov && last_fragment_within_iov) ? fin : false;
+ WriteDataFrame(id, StringPiece(data, len), frame_fin,
+ ack_notifier_delegate);
+ result.bytes_consumed += len;
+ if (frame_fin) {
+ result.fin_consumed = true;
+ }
+ DCHECK_GE(total_length, len);
+ total_length -= len;
+ if (total_length <= 0) {
+ return result;
+ }
+ } while (src_iov_offset < src_iov->iov_len);
+ }
}
+
return result;
}
« no previous file with comments | « net/quic/core/quic_headers_stream.h ('k') | net/quic/core/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698