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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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_proxy_client_socket.cc ('k') | net/spdy/spdy_session_pool.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 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/location.h" 14 #include "base/location.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
17 #include "base/metrics/sparse_histogram.h" 18 #include "base/metrics/sparse_histogram.h"
18 #include "base/profiler/scoped_tracker.h" 19 #include "base/profiler/scoped_tracker.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const SpdyHeaderBlock& headers, 72 const SpdyHeaderBlock& headers,
72 NetLogCaptureMode capture_mode) { 73 NetLogCaptureMode capture_mode) {
73 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); 74 scoped_ptr<base::ListValue> headers_list(new base::ListValue());
74 for (SpdyHeaderBlock::const_iterator it = headers.begin(); 75 for (SpdyHeaderBlock::const_iterator it = headers.begin();
75 it != headers.end(); ++it) { 76 it != headers.end(); ++it) {
76 headers_list->AppendString( 77 headers_list->AppendString(
77 it->first.as_string() + ": " + 78 it->first.as_string() + ": " +
78 ElideHeaderValueForNetLog(capture_mode, it->first.as_string(), 79 ElideHeaderValueForNetLog(capture_mode, it->first.as_string(),
79 it->second.as_string())); 80 it->second.as_string()));
80 } 81 }
81 return headers_list.Pass(); 82 return headers_list;
82 } 83 }
83 84
84 scoped_ptr<base::Value> NetLogSpdySynStreamSentCallback( 85 scoped_ptr<base::Value> NetLogSpdySynStreamSentCallback(
85 const SpdyHeaderBlock* headers, 86 const SpdyHeaderBlock* headers,
86 bool fin, 87 bool fin,
87 bool unidirectional, 88 bool unidirectional,
88 SpdyPriority spdy_priority, 89 SpdyPriority spdy_priority,
89 SpdyStreamId stream_id, 90 SpdyStreamId stream_id,
90 NetLogCaptureMode capture_mode) { 91 NetLogCaptureMode capture_mode) {
91 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 92 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
92 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 93 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
93 dict->SetBoolean("fin", fin); 94 dict->SetBoolean("fin", fin);
94 dict->SetBoolean("unidirectional", unidirectional); 95 dict->SetBoolean("unidirectional", unidirectional);
95 dict->SetInteger("priority", static_cast<int>(spdy_priority)); 96 dict->SetInteger("priority", static_cast<int>(spdy_priority));
96 dict->SetInteger("stream_id", stream_id); 97 dict->SetInteger("stream_id", stream_id);
97 return dict.Pass(); 98 return std::move(dict);
98 } 99 }
99 100
100 scoped_ptr<base::Value> NetLogSpdySynStreamReceivedCallback( 101 scoped_ptr<base::Value> NetLogSpdySynStreamReceivedCallback(
101 const SpdyHeaderBlock* headers, 102 const SpdyHeaderBlock* headers,
102 bool fin, 103 bool fin,
103 bool unidirectional, 104 bool unidirectional,
104 SpdyPriority spdy_priority, 105 SpdyPriority spdy_priority,
105 SpdyStreamId stream_id, 106 SpdyStreamId stream_id,
106 SpdyStreamId associated_stream, 107 SpdyStreamId associated_stream,
107 NetLogCaptureMode capture_mode) { 108 NetLogCaptureMode capture_mode) {
108 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 109 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
109 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 110 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
110 dict->SetBoolean("fin", fin); 111 dict->SetBoolean("fin", fin);
111 dict->SetBoolean("unidirectional", unidirectional); 112 dict->SetBoolean("unidirectional", unidirectional);
112 dict->SetInteger("priority", static_cast<int>(spdy_priority)); 113 dict->SetInteger("priority", static_cast<int>(spdy_priority));
113 dict->SetInteger("stream_id", stream_id); 114 dict->SetInteger("stream_id", stream_id);
114 dict->SetInteger("associated_stream", associated_stream); 115 dict->SetInteger("associated_stream", associated_stream);
115 return dict.Pass(); 116 return std::move(dict);
116 } 117 }
117 118
118 scoped_ptr<base::Value> NetLogSpdySynReplyOrHeadersReceivedCallback( 119 scoped_ptr<base::Value> NetLogSpdySynReplyOrHeadersReceivedCallback(
119 const SpdyHeaderBlock* headers, 120 const SpdyHeaderBlock* headers,
120 bool fin, 121 bool fin,
121 SpdyStreamId stream_id, 122 SpdyStreamId stream_id,
122 NetLogCaptureMode capture_mode) { 123 NetLogCaptureMode capture_mode) {
123 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 124 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
124 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 125 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
125 dict->SetBoolean("fin", fin); 126 dict->SetBoolean("fin", fin);
126 dict->SetInteger("stream_id", stream_id); 127 dict->SetInteger("stream_id", stream_id);
127 return dict.Pass(); 128 return std::move(dict);
128 } 129 }
129 130
130 scoped_ptr<base::Value> NetLogSpdySessionCloseCallback( 131 scoped_ptr<base::Value> NetLogSpdySessionCloseCallback(
131 int net_error, 132 int net_error,
132 const std::string* description, 133 const std::string* description,
133 NetLogCaptureMode /* capture_mode */) { 134 NetLogCaptureMode /* capture_mode */) {
134 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 135 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
135 dict->SetInteger("net_error", net_error); 136 dict->SetInteger("net_error", net_error);
136 dict->SetString("description", *description); 137 dict->SetString("description", *description);
137 return dict.Pass(); 138 return std::move(dict);
138 } 139 }
139 140
140 scoped_ptr<base::Value> NetLogSpdySessionCallback( 141 scoped_ptr<base::Value> NetLogSpdySessionCallback(
141 const HostPortProxyPair* host_pair, 142 const HostPortProxyPair* host_pair,
142 NetLogCaptureMode /* capture_mode */) { 143 NetLogCaptureMode /* capture_mode */) {
143 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 144 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
144 dict->SetString("host", host_pair->first.ToString()); 145 dict->SetString("host", host_pair->first.ToString());
145 dict->SetString("proxy", host_pair->second.ToPacString()); 146 dict->SetString("proxy", host_pair->second.ToPacString());
146 return dict.Pass(); 147 return std::move(dict);
147 } 148 }
148 149
149 scoped_ptr<base::Value> NetLogSpdyInitializedCallback( 150 scoped_ptr<base::Value> NetLogSpdyInitializedCallback(
150 NetLog::Source source, 151 NetLog::Source source,
151 const NextProto protocol_version, 152 const NextProto protocol_version,
152 NetLogCaptureMode /* capture_mode */) { 153 NetLogCaptureMode /* capture_mode */) {
153 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 154 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
154 if (source.IsValid()) { 155 if (source.IsValid()) {
155 source.AddToEventParameters(dict.get()); 156 source.AddToEventParameters(dict.get());
156 } 157 }
157 dict->SetString("protocol", 158 dict->SetString("protocol",
158 SSLClientSocket::NextProtoToString(protocol_version)); 159 SSLClientSocket::NextProtoToString(protocol_version));
159 return dict.Pass(); 160 return std::move(dict);
160 } 161 }
161 162
162 scoped_ptr<base::Value> NetLogSpdySettingsCallback( 163 scoped_ptr<base::Value> NetLogSpdySettingsCallback(
163 const HostPortPair& host_port_pair, 164 const HostPortPair& host_port_pair,
164 bool clear_persisted, 165 bool clear_persisted,
165 NetLogCaptureMode /* capture_mode */) { 166 NetLogCaptureMode /* capture_mode */) {
166 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 167 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
167 dict->SetString("host", host_port_pair.ToString()); 168 dict->SetString("host", host_port_pair.ToString());
168 dict->SetBoolean("clear_persisted", clear_persisted); 169 dict->SetBoolean("clear_persisted", clear_persisted);
169 return dict.Pass(); 170 return std::move(dict);
170 } 171 }
171 172
172 scoped_ptr<base::Value> NetLogSpdySettingCallback( 173 scoped_ptr<base::Value> NetLogSpdySettingCallback(
173 SpdySettingsIds id, 174 SpdySettingsIds id,
174 const SpdyMajorVersion protocol_version, 175 const SpdyMajorVersion protocol_version,
175 SpdySettingsFlags flags, 176 SpdySettingsFlags flags,
176 uint32_t value, 177 uint32_t value,
177 NetLogCaptureMode /* capture_mode */) { 178 NetLogCaptureMode /* capture_mode */) {
178 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 179 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
179 dict->SetInteger("id", 180 dict->SetInteger("id",
180 SpdyConstants::SerializeSettingId(protocol_version, id)); 181 SpdyConstants::SerializeSettingId(protocol_version, id));
181 dict->SetInteger("flags", flags); 182 dict->SetInteger("flags", flags);
182 dict->SetInteger("value", value); 183 dict->SetInteger("value", value);
183 return dict.Pass(); 184 return std::move(dict);
184 } 185 }
185 186
186 scoped_ptr<base::Value> NetLogSpdySendSettingsCallback( 187 scoped_ptr<base::Value> NetLogSpdySendSettingsCallback(
187 const SettingsMap* settings, 188 const SettingsMap* settings,
188 const SpdyMajorVersion protocol_version, 189 const SpdyMajorVersion protocol_version,
189 NetLogCaptureMode /* capture_mode */) { 190 NetLogCaptureMode /* capture_mode */) {
190 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 191 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
191 scoped_ptr<base::ListValue> settings_list(new base::ListValue()); 192 scoped_ptr<base::ListValue> settings_list(new base::ListValue());
192 for (SettingsMap::const_iterator it = settings->begin(); 193 for (SettingsMap::const_iterator it = settings->begin();
193 it != settings->end(); ++it) { 194 it != settings->end(); ++it) {
194 const SpdySettingsIds id = it->first; 195 const SpdySettingsIds id = it->first;
195 const SpdySettingsFlags flags = it->second.first; 196 const SpdySettingsFlags flags = it->second.first;
196 const uint32_t value = it->second.second; 197 const uint32_t value = it->second.second;
197 settings_list->Append(new base::StringValue(base::StringPrintf( 198 settings_list->Append(new base::StringValue(base::StringPrintf(
198 "[id:%u flags:%u value:%u]", 199 "[id:%u flags:%u value:%u]",
199 SpdyConstants::SerializeSettingId(protocol_version, id), 200 SpdyConstants::SerializeSettingId(protocol_version, id),
200 flags, 201 flags,
201 value))); 202 value)));
202 } 203 }
203 dict->Set("settings", settings_list.Pass()); 204 dict->Set("settings", std::move(settings_list));
204 return dict.Pass(); 205 return std::move(dict);
205 } 206 }
206 207
207 scoped_ptr<base::Value> NetLogSpdyWindowUpdateFrameCallback( 208 scoped_ptr<base::Value> NetLogSpdyWindowUpdateFrameCallback(
208 SpdyStreamId stream_id, 209 SpdyStreamId stream_id,
209 uint32_t delta, 210 uint32_t delta,
210 NetLogCaptureMode /* capture_mode */) { 211 NetLogCaptureMode /* capture_mode */) {
211 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 212 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
212 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 213 dict->SetInteger("stream_id", static_cast<int>(stream_id));
213 dict->SetInteger("delta", delta); 214 dict->SetInteger("delta", delta);
214 return dict.Pass(); 215 return std::move(dict);
215 } 216 }
216 217
217 scoped_ptr<base::Value> NetLogSpdySessionWindowUpdateCallback( 218 scoped_ptr<base::Value> NetLogSpdySessionWindowUpdateCallback(
218 int32_t delta, 219 int32_t delta,
219 int32_t window_size, 220 int32_t window_size,
220 NetLogCaptureMode /* capture_mode */) { 221 NetLogCaptureMode /* capture_mode */) {
221 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 222 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
222 dict->SetInteger("delta", delta); 223 dict->SetInteger("delta", delta);
223 dict->SetInteger("window_size", window_size); 224 dict->SetInteger("window_size", window_size);
224 return dict.Pass(); 225 return std::move(dict);
225 } 226 }
226 227
227 scoped_ptr<base::Value> NetLogSpdyDataCallback( 228 scoped_ptr<base::Value> NetLogSpdyDataCallback(
228 SpdyStreamId stream_id, 229 SpdyStreamId stream_id,
229 int size, 230 int size,
230 bool fin, 231 bool fin,
231 NetLogCaptureMode /* capture_mode */) { 232 NetLogCaptureMode /* capture_mode */) {
232 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 233 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
233 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 234 dict->SetInteger("stream_id", static_cast<int>(stream_id));
234 dict->SetInteger("size", size); 235 dict->SetInteger("size", size);
235 dict->SetBoolean("fin", fin); 236 dict->SetBoolean("fin", fin);
236 return dict.Pass(); 237 return std::move(dict);
237 } 238 }
238 239
239 scoped_ptr<base::Value> NetLogSpdyRstCallback( 240 scoped_ptr<base::Value> NetLogSpdyRstCallback(
240 SpdyStreamId stream_id, 241 SpdyStreamId stream_id,
241 int status, 242 int status,
242 const std::string* description, 243 const std::string* description,
243 NetLogCaptureMode /* capture_mode */) { 244 NetLogCaptureMode /* capture_mode */) {
244 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 245 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
245 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 246 dict->SetInteger("stream_id", static_cast<int>(stream_id));
246 dict->SetInteger("status", status); 247 dict->SetInteger("status", status);
247 dict->SetString("description", *description); 248 dict->SetString("description", *description);
248 return dict.Pass(); 249 return std::move(dict);
249 } 250 }
250 251
251 scoped_ptr<base::Value> NetLogSpdyPingCallback( 252 scoped_ptr<base::Value> NetLogSpdyPingCallback(
252 SpdyPingId unique_id, 253 SpdyPingId unique_id,
253 bool is_ack, 254 bool is_ack,
254 const char* type, 255 const char* type,
255 NetLogCaptureMode /* capture_mode */) { 256 NetLogCaptureMode /* capture_mode */) {
256 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 257 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
257 dict->SetInteger("unique_id", static_cast<int>(unique_id)); 258 dict->SetInteger("unique_id", static_cast<int>(unique_id));
258 dict->SetString("type", type); 259 dict->SetString("type", type);
259 dict->SetBoolean("is_ack", is_ack); 260 dict->SetBoolean("is_ack", is_ack);
260 return dict.Pass(); 261 return std::move(dict);
261 } 262 }
262 263
263 scoped_ptr<base::Value> NetLogSpdyGoAwayCallback( 264 scoped_ptr<base::Value> NetLogSpdyGoAwayCallback(
264 SpdyStreamId last_stream_id, 265 SpdyStreamId last_stream_id,
265 int active_streams, 266 int active_streams,
266 int unclaimed_streams, 267 int unclaimed_streams,
267 SpdyGoAwayStatus status, 268 SpdyGoAwayStatus status,
268 StringPiece debug_data, 269 StringPiece debug_data,
269 NetLogCaptureMode capture_mode) { 270 NetLogCaptureMode capture_mode) {
270 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 271 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
271 dict->SetInteger("last_accepted_stream_id", 272 dict->SetInteger("last_accepted_stream_id",
272 static_cast<int>(last_stream_id)); 273 static_cast<int>(last_stream_id));
273 dict->SetInteger("active_streams", active_streams); 274 dict->SetInteger("active_streams", active_streams);
274 dict->SetInteger("unclaimed_streams", unclaimed_streams); 275 dict->SetInteger("unclaimed_streams", unclaimed_streams);
275 dict->SetInteger("status", static_cast<int>(status)); 276 dict->SetInteger("status", static_cast<int>(status));
276 dict->SetString("debug_data", 277 dict->SetString("debug_data",
277 ElideGoAwayDebugDataForNetLog(capture_mode, debug_data)); 278 ElideGoAwayDebugDataForNetLog(capture_mode, debug_data));
278 return dict.Pass(); 279 return std::move(dict);
279 } 280 }
280 281
281 scoped_ptr<base::Value> NetLogSpdyPushPromiseReceivedCallback( 282 scoped_ptr<base::Value> NetLogSpdyPushPromiseReceivedCallback(
282 const SpdyHeaderBlock* headers, 283 const SpdyHeaderBlock* headers,
283 SpdyStreamId stream_id, 284 SpdyStreamId stream_id,
284 SpdyStreamId promised_stream_id, 285 SpdyStreamId promised_stream_id,
285 NetLogCaptureMode capture_mode) { 286 NetLogCaptureMode capture_mode) {
286 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 287 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
287 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 288 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
288 dict->SetInteger("id", stream_id); 289 dict->SetInteger("id", stream_id);
289 dict->SetInteger("promised_stream_id", promised_stream_id); 290 dict->SetInteger("promised_stream_id", promised_stream_id);
290 return dict.Pass(); 291 return std::move(dict);
291 } 292 }
292 293
293 scoped_ptr<base::Value> NetLogSpdyAdoptedPushStreamCallback( 294 scoped_ptr<base::Value> NetLogSpdyAdoptedPushStreamCallback(
294 SpdyStreamId stream_id, 295 SpdyStreamId stream_id,
295 const GURL* url, 296 const GURL* url,
296 NetLogCaptureMode capture_mode) { 297 NetLogCaptureMode capture_mode) {
297 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 298 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
298 dict->SetInteger("stream_id", stream_id); 299 dict->SetInteger("stream_id", stream_id);
299 dict->SetString("url", url->spec()); 300 dict->SetString("url", url->spec());
300 return dict.Pass(); 301 return std::move(dict);
301 } 302 }
302 303
303 // Helper function to return the total size of an array of objects 304 // Helper function to return the total size of an array of objects
304 // with .size() member functions. 305 // with .size() member functions.
305 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) { 306 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) {
306 size_t total_size = 0; 307 size_t total_size = 0;
307 for (size_t i = 0; i < N; ++i) { 308 for (size_t i = 0; i < N; ++i) {
308 total_size += arr[i].size(); 309 total_size += arr[i].size();
309 } 310 }
310 return total_size; 311 return total_size;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 DCHECK_EQ(read_state_, READ_STATE_DO_READ); 740 DCHECK_EQ(read_state_, READ_STATE_DO_READ);
740 DCHECK_EQ(write_state_, WRITE_STATE_IDLE); 741 DCHECK_EQ(write_state_, WRITE_STATE_IDLE);
741 DCHECK(!connection_); 742 DCHECK(!connection_);
742 743
743 DCHECK(certificate_error_code == OK || 744 DCHECK(certificate_error_code == OK ||
744 certificate_error_code < ERR_IO_PENDING); 745 certificate_error_code < ERR_IO_PENDING);
745 // TODO(akalin): Check connection->is_initialized() instead. This 746 // TODO(akalin): Check connection->is_initialized() instead. This
746 // requires re-working CreateFakeSpdySession(), though. 747 // requires re-working CreateFakeSpdySession(), though.
747 DCHECK(connection->socket()); 748 DCHECK(connection->socket());
748 749
749 connection_ = connection.Pass(); 750 connection_ = std::move(connection);
750 is_secure_ = is_secure; 751 is_secure_ = is_secure;
751 certificate_error_code_ = certificate_error_code; 752 certificate_error_code_ = certificate_error_code;
752 753
753 NextProto protocol_negotiated = 754 NextProto protocol_negotiated =
754 connection_->socket()->GetNegotiatedProtocol(); 755 connection_->socket()->GetNegotiatedProtocol();
755 if (protocol_negotiated != kProtoUnknown) { 756 if (protocol_negotiated != kProtoUnknown) {
756 protocol_ = protocol_negotiated; 757 protocol_ = protocol_negotiated;
757 stream_initial_send_window_size_ = GetDefaultInitialWindowSize(protocol_); 758 stream_initial_send_window_size_ = GetDefaultInitialWindowSize(protocol_);
758 } 759 }
759 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); 760 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 ERR_CONNECTION_CLOSED, 915 ERR_CONNECTION_CLOSED,
915 "Tried to create SPDY stream for a closed socket connection."); 916 "Tried to create SPDY stream for a closed socket connection.");
916 return ERR_CONNECTION_CLOSED; 917 return ERR_CONNECTION_CLOSED;
917 } 918 }
918 919
919 scoped_ptr<SpdyStream> new_stream( 920 scoped_ptr<SpdyStream> new_stream(
920 new SpdyStream(request.type(), GetWeakPtr(), request.url(), 921 new SpdyStream(request.type(), GetWeakPtr(), request.url(),
921 request.priority(), stream_initial_send_window_size_, 922 request.priority(), stream_initial_send_window_size_,
922 stream_max_recv_window_size_, request.net_log())); 923 stream_max_recv_window_size_, request.net_log()));
923 *stream = new_stream->GetWeakPtr(); 924 *stream = new_stream->GetWeakPtr();
924 InsertCreatedStream(new_stream.Pass()); 925 InsertCreatedStream(std::move(new_stream));
925 926
926 UMA_HISTOGRAM_CUSTOM_COUNTS( 927 UMA_HISTOGRAM_CUSTOM_COUNTS(
927 "Net.SpdyPriorityCount", 928 "Net.SpdyPriorityCount",
928 static_cast<int>(request.priority()), 0, 10, 11); 929 static_cast<int>(request.priority()), 0, 10, 11);
929 930
930 return OK; 931 return OK;
931 } 932 }
932 933
933 void SpdySession::CancelStreamRequest( 934 void SpdySession::CancelStreamRequest(
934 const base::WeakPtr<SpdyStreamRequest>& request) { 935 const base::WeakPtr<SpdyStreamRequest>& request) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 priority_dependency_enabled_default = enable; 1062 priority_dependency_enabled_default = enable;
1062 } 1063 }
1063 1064
1064 void SpdySession::EnqueueStreamWrite( 1065 void SpdySession::EnqueueStreamWrite(
1065 const base::WeakPtr<SpdyStream>& stream, 1066 const base::WeakPtr<SpdyStream>& stream,
1066 SpdyFrameType frame_type, 1067 SpdyFrameType frame_type,
1067 scoped_ptr<SpdyBufferProducer> producer) { 1068 scoped_ptr<SpdyBufferProducer> producer) {
1068 DCHECK(frame_type == HEADERS || 1069 DCHECK(frame_type == HEADERS ||
1069 frame_type == DATA || 1070 frame_type == DATA ||
1070 frame_type == SYN_STREAM); 1071 frame_type == SYN_STREAM);
1071 EnqueueWrite(stream->priority(), frame_type, producer.Pass(), stream); 1072 EnqueueWrite(stream->priority(), frame_type, std::move(producer), stream);
1072 } 1073 }
1073 1074
1074 scoped_ptr<SpdyFrame> SpdySession::CreateSynStream( 1075 scoped_ptr<SpdyFrame> SpdySession::CreateSynStream(
1075 SpdyStreamId stream_id, 1076 SpdyStreamId stream_id,
1076 RequestPriority priority, 1077 RequestPriority priority,
1077 SpdyControlFlags flags, 1078 SpdyControlFlags flags,
1078 const SpdyHeaderBlock& block) { 1079 const SpdyHeaderBlock& block) {
1079 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); 1080 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id);
1080 CHECK(it != active_streams_.end()); 1081 CHECK(it != active_streams_.end());
1081 CHECK_EQ(it->second.stream->stream_id(), stream_id); 1082 CHECK_EQ(it->second.stream->stream_id(), stream_id);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 (GetProtocolVersion() <= SPDY3) 1148 (GetProtocolVersion() <= SPDY3)
1148 ? NetLog::TYPE_HTTP2_SESSION_SYN_STREAM 1149 ? NetLog::TYPE_HTTP2_SESSION_SYN_STREAM
1149 : NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS; 1150 : NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS;
1150 net_log().AddEvent(type, 1151 net_log().AddEvent(type,
1151 base::Bind(&NetLogSpdySynStreamSentCallback, &block, 1152 base::Bind(&NetLogSpdySynStreamSentCallback, &block,
1152 (flags & CONTROL_FLAG_FIN) != 0, 1153 (flags & CONTROL_FLAG_FIN) != 0,
1153 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, 1154 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0,
1154 spdy_priority, stream_id)); 1155 spdy_priority, stream_id));
1155 } 1156 }
1156 1157
1157 return syn_frame.Pass(); 1158 return syn_frame;
1158 } 1159 }
1159 1160
1160 scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, 1161 scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id,
1161 IOBuffer* data, 1162 IOBuffer* data,
1162 int len, 1163 int len,
1163 SpdyDataFlags flags) { 1164 SpdyDataFlags flags) {
1164 if (availability_state_ == STATE_DRAINING) { 1165 if (availability_state_ == STATE_DRAINING) {
1165 return scoped_ptr<SpdyBuffer>(); 1166 return scoped_ptr<SpdyBuffer>();
1166 } 1167 }
1167 1168
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1261
1261 // Send PrefacePing for DATA_FRAMEs with nonzero payload size. 1262 // Send PrefacePing for DATA_FRAMEs with nonzero payload size.
1262 if (effective_len > 0) 1263 if (effective_len > 0)
1263 SendPrefacePingIfNoneInFlight(); 1264 SendPrefacePingIfNoneInFlight();
1264 1265
1265 // TODO(mbelshe): reduce memory copies here. 1266 // TODO(mbelshe): reduce memory copies here.
1266 DCHECK(buffered_spdy_framer_.get()); 1267 DCHECK(buffered_spdy_framer_.get());
1267 scoped_ptr<SpdyFrame> frame(buffered_spdy_framer_->CreateDataFrame( 1268 scoped_ptr<SpdyFrame> frame(buffered_spdy_framer_->CreateDataFrame(
1268 stream_id, data->data(), static_cast<uint32_t>(effective_len), flags)); 1269 stream_id, data->data(), static_cast<uint32_t>(effective_len), flags));
1269 1270
1270 scoped_ptr<SpdyBuffer> data_buffer(new SpdyBuffer(frame.Pass())); 1271 scoped_ptr<SpdyBuffer> data_buffer(new SpdyBuffer(std::move(frame)));
1271 1272
1272 // Send window size is based on payload size, so nothing to do if this is 1273 // Send window size is based on payload size, so nothing to do if this is
1273 // just a FIN with no payload. 1274 // just a FIN with no payload.
1274 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION && 1275 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION &&
1275 effective_len != 0) { 1276 effective_len != 0) {
1276 DecreaseSendWindowSize(static_cast<int32_t>(effective_len)); 1277 DecreaseSendWindowSize(static_cast<int32_t>(effective_len));
1277 data_buffer->AddConsumeCallback( 1278 data_buffer->AddConsumeCallback(
1278 base::Bind(&SpdySession::OnWriteBufferConsumed, 1279 base::Bind(&SpdySession::OnWriteBufferConsumed,
1279 weak_factory_.GetWeakPtr(), 1280 weak_factory_.GetWeakPtr(),
1280 static_cast<size_t>(effective_len))); 1281 static_cast<size_t>(effective_len)));
1281 } 1282 }
1282 1283
1283 return data_buffer.Pass(); 1284 return data_buffer;
1284 } 1285 }
1285 1286
1286 void SpdySession::CloseActiveStream(SpdyStreamId stream_id, int status) { 1287 void SpdySession::CloseActiveStream(SpdyStreamId stream_id, int status) {
1287 DCHECK_NE(stream_id, 0u); 1288 DCHECK_NE(stream_id, 0u);
1288 1289
1289 ActiveStreamMap::iterator it = active_streams_.find(stream_id); 1290 ActiveStreamMap::iterator it = active_streams_.find(stream_id);
1290 if (it == active_streams_.end()) { 1291 if (it == active_streams_.end()) {
1291 NOTREACHED(); 1292 NOTREACHED();
1292 return; 1293 return;
1293 } 1294 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 // probably something that we still want to support, although server 1350 // probably something that we still want to support, although server
1350 // push is hardly used. Write tests for this and fix this. (See 1351 // push is hardly used. Write tests for this and fix this. (See
1351 // http://crbug.com/261712 .) 1352 // http://crbug.com/261712 .)
1352 if (owned_stream->type() == SPDY_PUSH_STREAM) { 1353 if (owned_stream->type() == SPDY_PUSH_STREAM) {
1353 unclaimed_pushed_streams_.erase(owned_stream->url()); 1354 unclaimed_pushed_streams_.erase(owned_stream->url());
1354 num_pushed_streams_--; 1355 num_pushed_streams_--;
1355 if (!owned_stream->IsReservedRemote()) 1356 if (!owned_stream->IsReservedRemote())
1356 num_active_pushed_streams_--; 1357 num_active_pushed_streams_--;
1357 } 1358 }
1358 1359
1359 DeleteStream(owned_stream.Pass(), status); 1360 DeleteStream(std::move(owned_stream), status);
1360 1361
1361 // If there are no active streams and the socket pool is stalled, close the 1362 // If there are no active streams and the socket pool is stalled, close the
1362 // session to free up a socket slot. 1363 // session to free up a socket slot.
1363 if (active_streams_.empty() && created_streams_.empty() && 1364 if (active_streams_.empty() && created_streams_.empty() &&
1364 connection_->IsPoolStalled()) { 1365 connection_->IsPoolStalled()) {
1365 DoDrainSession(ERR_CONNECTION_CLOSED, "Closing idle connection."); 1366 DoDrainSession(ERR_CONNECTION_CLOSED, "Closing idle connection.");
1366 } 1367 }
1367 } 1368 }
1368 1369
1369 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it, 1370 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it,
1370 int status) { 1371 int status) {
1371 scoped_ptr<SpdyStream> owned_stream(*it); 1372 scoped_ptr<SpdyStream> owned_stream(*it);
1372 created_streams_.erase(it); 1373 created_streams_.erase(it);
1373 DeleteStream(owned_stream.Pass(), status); 1374 DeleteStream(std::move(owned_stream), status);
1374 } 1375 }
1375 1376
1376 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it, 1377 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it,
1377 SpdyRstStreamStatus status, 1378 SpdyRstStreamStatus status,
1378 const std::string& description) { 1379 const std::string& description) {
1379 // Send the RST_STREAM frame first as CloseActiveStreamIterator() 1380 // Send the RST_STREAM frame first as CloseActiveStreamIterator()
1380 // may close us. 1381 // may close us.
1381 SpdyStreamId stream_id = it->first; 1382 SpdyStreamId stream_id = it->first;
1382 RequestPriority priority = it->second.stream->priority(); 1383 RequestPriority priority = it->second.stream->priority();
1383 EnqueueResetStreamFrame(stream_id, priority, status, description); 1384 EnqueueResetStreamFrame(stream_id, priority, status, description);
(...skipping 10 matching lines...) Expand all
1394 DCHECK_NE(stream_id, 0u); 1395 DCHECK_NE(stream_id, 0u);
1395 1396
1396 net_log().AddEvent( 1397 net_log().AddEvent(
1397 NetLog::TYPE_HTTP2_SESSION_SEND_RST_STREAM, 1398 NetLog::TYPE_HTTP2_SESSION_SEND_RST_STREAM,
1398 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description)); 1399 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description));
1399 1400
1400 DCHECK(buffered_spdy_framer_.get()); 1401 DCHECK(buffered_spdy_framer_.get());
1401 scoped_ptr<SpdyFrame> rst_frame( 1402 scoped_ptr<SpdyFrame> rst_frame(
1402 buffered_spdy_framer_->CreateRstStream(stream_id, status)); 1403 buffered_spdy_framer_->CreateRstStream(stream_id, status));
1403 1404
1404 EnqueueSessionWrite(priority, RST_STREAM, rst_frame.Pass()); 1405 EnqueueSessionWrite(priority, RST_STREAM, std::move(rst_frame));
1405 RecordProtocolErrorHistogram(MapRstStreamStatusToProtocolError(status)); 1406 RecordProtocolErrorHistogram(MapRstStreamStatusToProtocolError(status));
1406 } 1407 }
1407 1408
1408 void SpdySession::PumpReadLoop(ReadState expected_read_state, int result) { 1409 void SpdySession::PumpReadLoop(ReadState expected_read_state, int result) {
1409 // TODO(bnc): Remove ScopedTracker below once crbug.com/462774 is fixed. 1410 // TODO(bnc): Remove ScopedTracker below once crbug.com/462774 is fixed.
1410 tracked_objects::ScopedTracker tracking_profile( 1411 tracked_objects::ScopedTracker tracking_profile(
1411 FROM_HERE_WITH_EXPLICIT_FUNCTION("462774 SpdySession::PumpReadLoop")); 1412 FROM_HERE_WITH_EXPLICIT_FUNCTION("462774 SpdySession::PumpReadLoop"));
1412 1413
1413 CHECK(!in_io_loop_); 1414 CHECK(!in_io_loop_);
1414 if (availability_state_ == STATE_DRAINING) { 1415 if (availability_state_ == STATE_DRAINING) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 if (stream.get()) 1597 if (stream.get())
1597 CHECK(!stream->IsClosed()); 1598 CHECK(!stream->IsClosed());
1598 1599
1599 // Activate the stream only when sending the SYN_STREAM frame to 1600 // Activate the stream only when sending the SYN_STREAM frame to
1600 // guarantee monotonically-increasing stream IDs. 1601 // guarantee monotonically-increasing stream IDs.
1601 if (frame_type == SYN_STREAM) { 1602 if (frame_type == SYN_STREAM) {
1602 CHECK(stream.get()); 1603 CHECK(stream.get());
1603 CHECK_EQ(stream->stream_id(), 0u); 1604 CHECK_EQ(stream->stream_id(), 0u);
1604 scoped_ptr<SpdyStream> owned_stream = 1605 scoped_ptr<SpdyStream> owned_stream =
1605 ActivateCreatedStream(stream.get()); 1606 ActivateCreatedStream(stream.get());
1606 InsertActivatedStream(owned_stream.Pass()); 1607 InsertActivatedStream(std::move(owned_stream));
1607 1608
1608 if (stream_hi_water_mark_ > kLastStreamId) { 1609 if (stream_hi_water_mark_ > kLastStreamId) {
1609 CHECK_EQ(stream->stream_id(), kLastStreamId); 1610 CHECK_EQ(stream->stream_id(), kLastStreamId);
1610 // We've exhausted the stream ID space, and no new streams may be 1611 // We've exhausted the stream ID space, and no new streams may be
1611 // created after this one. 1612 // created after this one.
1612 MakeUnavailable(); 1613 MakeUnavailable();
1613 StartGoingAway(kLastStreamId, ERR_ABORTED); 1614 StartGoingAway(kLastStreamId, ERR_ABORTED);
1614 } 1615 }
1615 } 1616 }
1616 1617
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 1869 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
1869 1870
1870 dict->SetInteger("source_id", net_log_.source().id); 1871 dict->SetInteger("source_id", net_log_.source().id);
1871 1872
1872 dict->SetString("host_port_pair", host_port_pair().ToString()); 1873 dict->SetString("host_port_pair", host_port_pair().ToString());
1873 if (!pooled_aliases_.empty()) { 1874 if (!pooled_aliases_.empty()) {
1874 scoped_ptr<base::ListValue> alias_list(new base::ListValue()); 1875 scoped_ptr<base::ListValue> alias_list(new base::ListValue());
1875 for (const auto& alias : pooled_aliases_) { 1876 for (const auto& alias : pooled_aliases_) {
1876 alias_list->AppendString(alias.host_port_pair().ToString()); 1877 alias_list->AppendString(alias.host_port_pair().ToString());
1877 } 1878 }
1878 dict->Set("aliases", alias_list.Pass()); 1879 dict->Set("aliases", std::move(alias_list));
1879 } 1880 }
1880 dict->SetString("proxy", host_port_proxy_pair().second.ToURI()); 1881 dict->SetString("proxy", host_port_proxy_pair().second.ToURI());
1881 1882
1882 dict->SetInteger("active_streams", active_streams_.size()); 1883 dict->SetInteger("active_streams", active_streams_.size());
1883 1884
1884 dict->SetInteger("unclaimed_pushed_streams", 1885 dict->SetInteger("unclaimed_pushed_streams",
1885 unclaimed_pushed_streams_.size()); 1886 unclaimed_pushed_streams_.size());
1886 1887
1887 dict->SetBoolean("is_secure", is_secure_); 1888 dict->SetBoolean("is_secure", is_secure_);
1888 1889
(...skipping 12 matching lines...) Expand all
1901 DCHECK(buffered_spdy_framer_.get()); 1902 DCHECK(buffered_spdy_framer_.get());
1902 dict->SetInteger("frames_received", buffered_spdy_framer_->frames_received()); 1903 dict->SetInteger("frames_received", buffered_spdy_framer_->frames_received());
1903 1904
1904 dict->SetBoolean("sent_settings", sent_settings_); 1905 dict->SetBoolean("sent_settings", sent_settings_);
1905 dict->SetBoolean("received_settings", received_settings_); 1906 dict->SetBoolean("received_settings", received_settings_);
1906 1907
1907 dict->SetInteger("send_window_size", session_send_window_size_); 1908 dict->SetInteger("send_window_size", session_send_window_size_);
1908 dict->SetInteger("recv_window_size", session_recv_window_size_); 1909 dict->SetInteger("recv_window_size", session_recv_window_size_);
1909 dict->SetInteger("unacked_recv_window_bytes", 1910 dict->SetInteger("unacked_recv_window_bytes",
1910 session_unacked_recv_window_bytes_); 1911 session_unacked_recv_window_bytes_);
1911 return dict.Pass(); 1912 return std::move(dict);
1912 } 1913 }
1913 1914
1914 bool SpdySession::IsReused() const { 1915 bool SpdySession::IsReused() const {
1915 return buffered_spdy_framer_->frames_received() > 0 || 1916 return buffered_spdy_framer_->frames_received() > 0 ||
1916 connection_->reuse_type() == ClientSocketHandle::UNUSED_IDLE; 1917 connection_->reuse_type() == ClientSocketHandle::UNUSED_IDLE;
1917 } 1918 }
1918 1919
1919 bool SpdySession::GetLoadTimingInfo(SpdyStreamId stream_id, 1920 bool SpdySession::GetLoadTimingInfo(SpdyStreamId stream_id,
1920 LoadTimingInfo* load_timing_info) const { 1921 LoadTimingInfo* load_timing_info) const {
1921 return connection_->GetLoadTimingInfo(stream_id != kFirstStreamId, 1922 return connection_->GetLoadTimingInfo(stream_id != kFirstStreamId,
(...skipping 23 matching lines...) Expand all
1945 1946
1946 return rv; 1947 return rv;
1947 } 1948 }
1948 1949
1949 void SpdySession::EnqueueSessionWrite(RequestPriority priority, 1950 void SpdySession::EnqueueSessionWrite(RequestPriority priority,
1950 SpdyFrameType frame_type, 1951 SpdyFrameType frame_type,
1951 scoped_ptr<SpdyFrame> frame) { 1952 scoped_ptr<SpdyFrame> frame) {
1952 DCHECK(frame_type == RST_STREAM || frame_type == SETTINGS || 1953 DCHECK(frame_type == RST_STREAM || frame_type == SETTINGS ||
1953 frame_type == WINDOW_UPDATE || frame_type == PING || 1954 frame_type == WINDOW_UPDATE || frame_type == PING ||
1954 frame_type == GOAWAY); 1955 frame_type == GOAWAY);
1955 EnqueueWrite( 1956 EnqueueWrite(priority, frame_type,
1956 priority, frame_type, 1957 scoped_ptr<SpdyBufferProducer>(new SimpleBufferProducer(
1957 scoped_ptr<SpdyBufferProducer>( 1958 scoped_ptr<SpdyBuffer>(new SpdyBuffer(std::move(frame))))),
1958 new SimpleBufferProducer( 1959 base::WeakPtr<SpdyStream>());
1959 scoped_ptr<SpdyBuffer>(new SpdyBuffer(frame.Pass())))),
1960 base::WeakPtr<SpdyStream>());
1961 } 1960 }
1962 1961
1963 void SpdySession::EnqueueWrite(RequestPriority priority, 1962 void SpdySession::EnqueueWrite(RequestPriority priority,
1964 SpdyFrameType frame_type, 1963 SpdyFrameType frame_type,
1965 scoped_ptr<SpdyBufferProducer> producer, 1964 scoped_ptr<SpdyBufferProducer> producer,
1966 const base::WeakPtr<SpdyStream>& stream) { 1965 const base::WeakPtr<SpdyStream>& stream) {
1967 if (availability_state_ == STATE_DRAINING) 1966 if (availability_state_ == STATE_DRAINING)
1968 return; 1967 return;
1969 1968
1970 write_queue_.Enqueue(priority, frame_type, producer.Pass(), stream); 1969 write_queue_.Enqueue(priority, frame_type, std::move(producer), stream);
1971 MaybePostWriteLoop(); 1970 MaybePostWriteLoop();
1972 } 1971 }
1973 1972
1974 void SpdySession::MaybePostWriteLoop() { 1973 void SpdySession::MaybePostWriteLoop() {
1975 if (write_state_ == WRITE_STATE_IDLE) { 1974 if (write_state_ == WRITE_STATE_IDLE) {
1976 CHECK(!in_flight_write_); 1975 CHECK(!in_flight_write_);
1977 write_state_ = WRITE_STATE_DO_WRITE; 1976 write_state_ = WRITE_STATE_DO_WRITE;
1978 base::ThreadTaskRunnerHandle::Get()->PostTask( 1977 base::ThreadTaskRunnerHandle::Get()->PostTask(
1979 FROM_HERE, 1978 FROM_HERE,
1980 base::Bind(&SpdySession::PumpWriteLoop, weak_factory_.GetWeakPtr(), 1979 base::Bind(&SpdySession::PumpWriteLoop, weak_factory_.GetWeakPtr(),
1981 WRITE_STATE_DO_WRITE, OK)); 1980 WRITE_STATE_DO_WRITE, OK));
1982 } 1981 }
1983 } 1982 }
1984 1983
1985 void SpdySession::InsertCreatedStream(scoped_ptr<SpdyStream> stream) { 1984 void SpdySession::InsertCreatedStream(scoped_ptr<SpdyStream> stream) {
1986 CHECK_EQ(stream->stream_id(), 0u); 1985 CHECK_EQ(stream->stream_id(), 0u);
1987 CHECK(created_streams_.find(stream.get()) == created_streams_.end()); 1986 CHECK(created_streams_.find(stream.get()) == created_streams_.end());
1988 created_streams_.insert(stream.release()); 1987 created_streams_.insert(stream.release());
1989 } 1988 }
1990 1989
1991 scoped_ptr<SpdyStream> SpdySession::ActivateCreatedStream(SpdyStream* stream) { 1990 scoped_ptr<SpdyStream> SpdySession::ActivateCreatedStream(SpdyStream* stream) {
1992 CHECK_EQ(stream->stream_id(), 0u); 1991 CHECK_EQ(stream->stream_id(), 0u);
1993 CHECK(created_streams_.find(stream) != created_streams_.end()); 1992 CHECK(created_streams_.find(stream) != created_streams_.end());
1994 stream->set_stream_id(GetNewStreamId()); 1993 stream->set_stream_id(GetNewStreamId());
1995 scoped_ptr<SpdyStream> owned_stream(stream); 1994 scoped_ptr<SpdyStream> owned_stream(stream);
1996 created_streams_.erase(stream); 1995 created_streams_.erase(stream);
1997 return owned_stream.Pass(); 1996 return owned_stream;
1998 } 1997 }
1999 1998
2000 void SpdySession::InsertActivatedStream(scoped_ptr<SpdyStream> stream) { 1999 void SpdySession::InsertActivatedStream(scoped_ptr<SpdyStream> stream) {
2001 SpdyStreamId stream_id = stream->stream_id(); 2000 SpdyStreamId stream_id = stream->stream_id();
2002 CHECK_NE(stream_id, 0u); 2001 CHECK_NE(stream_id, 0u);
2003 std::pair<ActiveStreamMap::iterator, bool> result = 2002 std::pair<ActiveStreamMap::iterator, bool> result =
2004 active_streams_.insert( 2003 active_streams_.insert(
2005 std::make_pair(stream_id, ActiveStreamInfo(stream.get()))); 2004 std::make_pair(stream_id, ActiveStreamInfo(stream.get())));
2006 active_streams_by_priority_[stream->priority()].insert( 2005 active_streams_by_priority_[stream->priority()].insert(
2007 std::make_pair(stream_id, stream.get())); 2006 std::make_pair(stream_id, stream.get()));
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 2143
2145 stream->AddRawReceivedBytes(len); 2144 stream->AddRawReceivedBytes(len);
2146 2145
2147 if (it->second.waiting_for_syn_reply) { 2146 if (it->second.waiting_for_syn_reply) {
2148 const std::string& error = "Data received before SYN_REPLY."; 2147 const std::string& error = "Data received before SYN_REPLY.";
2149 stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); 2148 stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error);
2150 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); 2149 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error);
2151 return; 2150 return;
2152 } 2151 }
2153 2152
2154 stream->OnDataReceived(buffer.Pass()); 2153 stream->OnDataReceived(std::move(buffer));
2155 } 2154 }
2156 2155
2157 void SpdySession::OnStreamPadding(SpdyStreamId stream_id, size_t len) { 2156 void SpdySession::OnStreamPadding(SpdyStreamId stream_id, size_t len) {
2158 CHECK(in_io_loop_); 2157 CHECK(in_io_loop_);
2159 2158
2160 if (flow_control_state_ != FLOW_CONTROL_STREAM_AND_SESSION) 2159 if (flow_control_state_ != FLOW_CONTROL_STREAM_AND_SESSION)
2161 return; 2160 return;
2162 2161
2163 // Decrease window size because padding bytes are received. 2162 // Decrease window size because padding bytes are received.
2164 // Increase window size because padding bytes are consumed (by discarding). 2163 // Increase window size because padding bytes are consumed (by discarding).
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 2774
2776 last_compressed_frame_len_ = 0; 2775 last_compressed_frame_len_ = 0;
2777 2776
2778 PushedStreamMap::iterator inserted_pushed_it = 2777 PushedStreamMap::iterator inserted_pushed_it =
2779 unclaimed_pushed_streams_.insert( 2778 unclaimed_pushed_streams_.insert(
2780 pushed_it, 2779 pushed_it,
2781 std::make_pair(gurl, PushedStreamInfo(stream_id, time_func_()))); 2780 std::make_pair(gurl, PushedStreamInfo(stream_id, time_func_())));
2782 DCHECK(inserted_pushed_it != pushed_it); 2781 DCHECK(inserted_pushed_it != pushed_it);
2783 DeleteExpiredPushedStreams(); 2782 DeleteExpiredPushedStreams();
2784 2783
2785 InsertActivatedStream(stream.Pass()); 2784 InsertActivatedStream(std::move(stream));
2786 2785
2787 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); 2786 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id);
2788 if (active_it == active_streams_.end()) { 2787 if (active_it == active_streams_.end()) {
2789 NOTREACHED(); 2788 NOTREACHED();
2790 return false; 2789 return false;
2791 } 2790 }
2792 2791
2793 active_it->second.stream->OnPushPromiseHeadersReceived(headers); 2792 active_it->second.stream->OnPushPromiseHeadersReceived(headers);
2794 DCHECK(active_it->second.stream->IsReservedRemote()); 2793 DCHECK(active_it->second.stream->IsReservedRemote());
2795 num_pushed_streams_++; 2794 num_pushed_streams_++;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 DCHECK(enable_sending_initial_data_); 2826 DCHECK(enable_sending_initial_data_);
2828 2827
2829 if (send_connection_header_prefix_) { 2828 if (send_connection_header_prefix_) {
2830 DCHECK_EQ(protocol_, kProtoHTTP2); 2829 DCHECK_EQ(protocol_, kProtoHTTP2);
2831 scoped_ptr<SpdyFrame> connection_header_prefix_frame( 2830 scoped_ptr<SpdyFrame> connection_header_prefix_frame(
2832 new SpdyFrame(const_cast<char*>(kHttp2ConnectionHeaderPrefix), 2831 new SpdyFrame(const_cast<char*>(kHttp2ConnectionHeaderPrefix),
2833 kHttp2ConnectionHeaderPrefixSize, 2832 kHttp2ConnectionHeaderPrefixSize,
2834 false /* take_ownership */)); 2833 false /* take_ownership */));
2835 // Count the prefix as part of the subsequent SETTINGS frame. 2834 // Count the prefix as part of the subsequent SETTINGS frame.
2836 EnqueueSessionWrite(HIGHEST, SETTINGS, 2835 EnqueueSessionWrite(HIGHEST, SETTINGS,
2837 connection_header_prefix_frame.Pass()); 2836 std::move(connection_header_prefix_frame));
2838 } 2837 }
2839 2838
2840 // First, notify the server about the settings they should use when 2839 // First, notify the server about the settings they should use when
2841 // communicating with us. 2840 // communicating with us.
2842 SettingsMap settings_map; 2841 SettingsMap settings_map;
2843 // Create a new settings frame notifying the server of our 2842 // Create a new settings frame notifying the server of our
2844 // max concurrent streams and initial window size. 2843 // max concurrent streams and initial window size.
2845 settings_map[SETTINGS_MAX_CONCURRENT_STREAMS] = 2844 settings_map[SETTINGS_MAX_CONCURRENT_STREAMS] =
2846 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); 2845 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams);
2847 if (flow_control_state_ >= FLOW_CONTROL_STREAM && 2846 if (flow_control_state_ >= FLOW_CONTROL_STREAM &&
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 void SpdySession::SendSettings(const SettingsMap& settings) { 2894 void SpdySession::SendSettings(const SettingsMap& settings) {
2896 const SpdyMajorVersion protocol_version = GetProtocolVersion(); 2895 const SpdyMajorVersion protocol_version = GetProtocolVersion();
2897 net_log_.AddEvent( 2896 net_log_.AddEvent(
2898 NetLog::TYPE_HTTP2_SESSION_SEND_SETTINGS, 2897 NetLog::TYPE_HTTP2_SESSION_SEND_SETTINGS,
2899 base::Bind(&NetLogSpdySendSettingsCallback, &settings, protocol_version)); 2898 base::Bind(&NetLogSpdySendSettingsCallback, &settings, protocol_version));
2900 // Create the SETTINGS frame and send it. 2899 // Create the SETTINGS frame and send it.
2901 DCHECK(buffered_spdy_framer_.get()); 2900 DCHECK(buffered_spdy_framer_.get());
2902 scoped_ptr<SpdyFrame> settings_frame( 2901 scoped_ptr<SpdyFrame> settings_frame(
2903 buffered_spdy_framer_->CreateSettings(settings)); 2902 buffered_spdy_framer_->CreateSettings(settings));
2904 sent_settings_ = true; 2903 sent_settings_ = true;
2905 EnqueueSessionWrite(HIGHEST, SETTINGS, settings_frame.Pass()); 2904 EnqueueSessionWrite(HIGHEST, SETTINGS, std::move(settings_frame));
2906 } 2905 }
2907 2906
2908 void SpdySession::HandleSetting(uint32_t id, uint32_t value) { 2907 void SpdySession::HandleSetting(uint32_t id, uint32_t value) {
2909 switch (id) { 2908 switch (id) {
2910 case SETTINGS_MAX_CONCURRENT_STREAMS: 2909 case SETTINGS_MAX_CONCURRENT_STREAMS:
2911 max_concurrent_streams_ = std::min(static_cast<size_t>(value), 2910 max_concurrent_streams_ = std::min(static_cast<size_t>(value),
2912 kMaxConcurrentStreamLimit); 2911 kMaxConcurrentStreamLimit);
2913 ProcessPendingStreamRequests(); 2912 ProcessPendingStreamRequests();
2914 break; 2913 break;
2915 case SETTINGS_INITIAL_WINDOW_SIZE: { 2914 case SETTINGS_INITIAL_WINDOW_SIZE: {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 CHECK_EQ(stream_id, kSessionFlowControlStreamId); 2977 CHECK_EQ(stream_id, kSessionFlowControlStreamId);
2979 } 2978 }
2980 2979
2981 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_SENT_WINDOW_UPDATE_FRAME, 2980 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_SENT_WINDOW_UPDATE_FRAME,
2982 base::Bind(&NetLogSpdyWindowUpdateFrameCallback, stream_id, 2981 base::Bind(&NetLogSpdyWindowUpdateFrameCallback, stream_id,
2983 delta_window_size)); 2982 delta_window_size));
2984 2983
2985 DCHECK(buffered_spdy_framer_.get()); 2984 DCHECK(buffered_spdy_framer_.get());
2986 scoped_ptr<SpdyFrame> window_update_frame( 2985 scoped_ptr<SpdyFrame> window_update_frame(
2987 buffered_spdy_framer_->CreateWindowUpdate(stream_id, delta_window_size)); 2986 buffered_spdy_framer_->CreateWindowUpdate(stream_id, delta_window_size));
2988 EnqueueSessionWrite(priority, WINDOW_UPDATE, window_update_frame.Pass()); 2987 EnqueueSessionWrite(priority, WINDOW_UPDATE, std::move(window_update_frame));
2989 } 2988 }
2990 2989
2991 void SpdySession::WritePingFrame(SpdyPingId unique_id, bool is_ack) { 2990 void SpdySession::WritePingFrame(SpdyPingId unique_id, bool is_ack) {
2992 DCHECK(buffered_spdy_framer_.get()); 2991 DCHECK(buffered_spdy_framer_.get());
2993 scoped_ptr<SpdyFrame> ping_frame( 2992 scoped_ptr<SpdyFrame> ping_frame(
2994 buffered_spdy_framer_->CreatePingFrame(unique_id, is_ack)); 2993 buffered_spdy_framer_->CreatePingFrame(unique_id, is_ack));
2995 EnqueueSessionWrite(HIGHEST, PING, ping_frame.Pass()); 2994 EnqueueSessionWrite(HIGHEST, PING, std::move(ping_frame));
2996 2995
2997 if (net_log().IsCapturing()) { 2996 if (net_log().IsCapturing()) {
2998 net_log().AddEvent( 2997 net_log().AddEvent(
2999 NetLog::TYPE_HTTP2_SESSION_PING, 2998 NetLog::TYPE_HTTP2_SESSION_PING,
3000 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "sent")); 2999 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "sent"));
3001 } 3000 }
3002 if (!is_ack) { 3001 if (!is_ack) {
3003 next_ping_id_ += 2; 3002 next_ping_id_ += 2;
3004 ++pings_in_flight_; 3003 ++pings_in_flight_;
3005 PlanToCheckPingStatus(); 3004 PlanToCheckPingStatus();
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
3331 if (!queue->empty()) { 3330 if (!queue->empty()) {
3332 SpdyStreamId stream_id = queue->front(); 3331 SpdyStreamId stream_id = queue->front();
3333 queue->pop_front(); 3332 queue->pop_front();
3334 return stream_id; 3333 return stream_id;
3335 } 3334 }
3336 } 3335 }
3337 return 0; 3336 return 0;
3338 } 3337 }
3339 3338
3340 } // namespace net 3339 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket.cc ('k') | net/spdy/spdy_session_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698