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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 2096713002: Reduce SpdyHeaderBlock copies with move semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clear() does not work after all. Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 DCHECK(frame_type == HEADERS || 1078 DCHECK(frame_type == HEADERS ||
1079 frame_type == DATA || 1079 frame_type == DATA ||
1080 frame_type == SYN_STREAM); 1080 frame_type == SYN_STREAM);
1081 EnqueueWrite(stream->priority(), frame_type, std::move(producer), stream); 1081 EnqueueWrite(stream->priority(), frame_type, std::move(producer), stream);
1082 } 1082 }
1083 1083
1084 std::unique_ptr<SpdySerializedFrame> SpdySession::CreateSynStream( 1084 std::unique_ptr<SpdySerializedFrame> SpdySession::CreateSynStream(
1085 SpdyStreamId stream_id, 1085 SpdyStreamId stream_id,
1086 RequestPriority priority, 1086 RequestPriority priority,
1087 SpdyControlFlags flags, 1087 SpdyControlFlags flags,
1088 const SpdyHeaderBlock& block) { 1088 SpdyHeaderBlock block) {
1089 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); 1089 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id);
1090 CHECK(it != active_streams_.end()); 1090 CHECK(it != active_streams_.end());
1091 CHECK_EQ(it->second.stream->stream_id(), stream_id); 1091 CHECK_EQ(it->second.stream->stream_id(), stream_id);
1092 1092
1093 SendPrefacePingIfNoneInFlight(); 1093 SendPrefacePingIfNoneInFlight();
1094 1094
1095 DCHECK(buffered_spdy_framer_.get()); 1095 DCHECK(buffered_spdy_framer_.get());
1096 SpdyPriority spdy_priority = 1096 SpdyPriority spdy_priority =
1097 ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion()); 1097 ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion());
1098 1098
1099 std::unique_ptr<SpdySerializedFrame> syn_frame; 1099 std::unique_ptr<SpdySerializedFrame> syn_frame;
1100 // TODO(hkhalil): Avoid copy of |block|.
1101 if (GetProtocolVersion() <= SPDY3) { 1100 if (GetProtocolVersion() <= SPDY3) {
1102 SpdySynStreamIR syn_stream(stream_id);
1103 syn_stream.set_associated_to_stream_id(0);
1104 syn_stream.set_priority(spdy_priority);
1105 syn_stream.set_fin((flags & CONTROL_FLAG_FIN) != 0);
1106 syn_stream.set_unidirectional((flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0);
1107 syn_stream.set_header_block(block);
1108 syn_frame.reset(new SpdySerializedFrame(
1109 buffered_spdy_framer_->SerializeFrame(syn_stream)));
1110
1111 if (net_log().IsCapturing()) { 1101 if (net_log().IsCapturing()) {
1112 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SYN_STREAM, 1102 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SYN_STREAM,
1113 base::Bind(&NetLogSpdySynStreamSentCallback, &block, 1103 base::Bind(&NetLogSpdySynStreamSentCallback, &block,
1114 (flags & CONTROL_FLAG_FIN) != 0, 1104 (flags & CONTROL_FLAG_FIN) != 0,
1115 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, 1105 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0,
1116 spdy_priority, stream_id)); 1106 spdy_priority, stream_id));
1117 } 1107 }
1108
1109 SpdySynStreamIR syn_stream(stream_id, std::move(block));
1110 syn_stream.set_associated_to_stream_id(0);
1111 syn_stream.set_priority(spdy_priority);
1112 syn_stream.set_fin((flags & CONTROL_FLAG_FIN) != 0);
1113 syn_stream.set_unidirectional((flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0);
1114 syn_frame.reset(new SpdySerializedFrame(
1115 buffered_spdy_framer_->SerializeFrame(syn_stream)));
1116
1118 } else { 1117 } else {
1119 SpdyHeadersIR headers(stream_id); 1118 bool has_priority = true;
1120 headers.set_weight(Spdy3PriorityToHttp2Weight(spdy_priority)); 1119 int weight = Spdy3PriorityToHttp2Weight(spdy_priority);
1121 headers.set_has_priority(true); 1120 SpdyStreamId dependent_stream_id = 0;
1121 bool exclusive = false;
1122 1122
1123 if (priority_dependencies_enabled_) { 1123 if (priority_dependencies_enabled_) {
1124 SpdyStreamId dependent_stream_id = 0;
1125 bool exclusive = false;
1126 priority_dependency_state_.OnStreamSynSent( 1124 priority_dependency_state_.OnStreamSynSent(
1127 stream_id, spdy_priority, &dependent_stream_id, &exclusive); 1125 stream_id, spdy_priority, &dependent_stream_id, &exclusive);
1128 headers.set_parent_stream_id(dependent_stream_id);
1129 headers.set_exclusive(exclusive);
1130 } 1126 }
1131 1127
1132 headers.set_fin((flags & CONTROL_FLAG_FIN) != 0);
1133 headers.set_header_block(block);
1134 syn_frame.reset(new SpdySerializedFrame(
1135 buffered_spdy_framer_->SerializeFrame(headers)));
1136
1137 if (net_log().IsCapturing()) { 1128 if (net_log().IsCapturing()) {
1138 net_log().AddEvent( 1129 net_log().AddEvent(
1139 NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS, 1130 NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS,
1140 base::Bind(&NetLogSpdyHeadersSentCallback, &block, 1131 base::Bind(&NetLogSpdyHeadersSentCallback, &block,
1141 (flags & CONTROL_FLAG_FIN) != 0, stream_id, 1132 (flags & CONTROL_FLAG_FIN) != 0, stream_id, has_priority,
1142 headers.has_priority(), headers.weight(), 1133 weight, dependent_stream_id, exclusive));
1143 headers.parent_stream_id(), headers.exclusive()));
1144 } 1134 }
1135
1136 SpdyHeadersIR headers(stream_id, std::move(block));
1137 headers.set_has_priority(has_priority);
1138 headers.set_weight(weight);
1139 headers.set_parent_stream_id(dependent_stream_id);
1140 headers.set_exclusive(exclusive);
1141 headers.set_fin((flags & CONTROL_FLAG_FIN) != 0);
1142 syn_frame.reset(new SpdySerializedFrame(
1143 buffered_spdy_framer_->SerializeFrame(headers)));
1145 } 1144 }
1146 1145
1147 streams_initiated_count_++; 1146 streams_initiated_count_++;
1148 1147
1149 return syn_frame; 1148 return syn_frame;
1150 } 1149 }
1151 1150
1152 std::unique_ptr<SpdyBuffer> SpdySession::CreateDataBuffer( 1151 std::unique_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(
1153 SpdyStreamId stream_id, 1152 SpdyStreamId stream_id,
1154 IOBuffer* data, 1153 IOBuffer* data,
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3389 if (!queue->empty()) { 3388 if (!queue->empty()) {
3390 SpdyStreamId stream_id = queue->front(); 3389 SpdyStreamId stream_id = queue->front();
3391 queue->pop_front(); 3390 queue->pop_front();
3392 return stream_id; 3391 return stream_id;
3393 } 3392 }
3394 } 3393 }
3395 return 0; 3394 return 0;
3396 } 3395 }
3397 3396
3398 } // namespace net 3397 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698