| 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/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); | 63 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); |
| 64 for (SpdyHeaderBlock::const_iterator it = headers.begin(); | 64 for (SpdyHeaderBlock::const_iterator it = headers.begin(); |
| 65 it != headers.end(); ++it) { | 65 it != headers.end(); ++it) { |
| 66 headers_list->AppendString( | 66 headers_list->AppendString( |
| 67 it->first + ": " + | 67 it->first + ": " + |
| 68 ElideHeaderValueForNetLog(capture_mode, it->first, it->second)); | 68 ElideHeaderValueForNetLog(capture_mode, it->first, it->second)); |
| 69 } | 69 } |
| 70 return headers_list.Pass(); | 70 return headers_list.Pass(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 base::Value* NetLogSpdySynStreamSentCallback(const SpdyHeaderBlock* headers, | 73 scoped_ptr<base::Value> NetLogSpdySynStreamSentCallback( |
| 74 bool fin, | 74 const SpdyHeaderBlock* headers, |
| 75 bool unidirectional, | 75 bool fin, |
| 76 SpdyPriority spdy_priority, | 76 bool unidirectional, |
| 77 SpdyStreamId stream_id, | 77 SpdyPriority spdy_priority, |
| 78 NetLogCaptureMode capture_mode) { | 78 SpdyStreamId stream_id, |
| 79 base::DictionaryValue* dict = new base::DictionaryValue(); | 79 NetLogCaptureMode capture_mode) { |
| 80 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 80 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); | 81 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); |
| 81 dict->SetBoolean("fin", fin); | 82 dict->SetBoolean("fin", fin); |
| 82 dict->SetBoolean("unidirectional", unidirectional); | 83 dict->SetBoolean("unidirectional", unidirectional); |
| 83 dict->SetInteger("priority", static_cast<int>(spdy_priority)); | 84 dict->SetInteger("priority", static_cast<int>(spdy_priority)); |
| 84 dict->SetInteger("stream_id", stream_id); | 85 dict->SetInteger("stream_id", stream_id); |
| 85 return dict; | 86 return dict.Pass(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 base::Value* NetLogSpdySynStreamReceivedCallback( | 89 scoped_ptr<base::Value> NetLogSpdySynStreamReceivedCallback( |
| 89 const SpdyHeaderBlock* headers, | 90 const SpdyHeaderBlock* headers, |
| 90 bool fin, | 91 bool fin, |
| 91 bool unidirectional, | 92 bool unidirectional, |
| 92 SpdyPriority spdy_priority, | 93 SpdyPriority spdy_priority, |
| 93 SpdyStreamId stream_id, | 94 SpdyStreamId stream_id, |
| 94 SpdyStreamId associated_stream, | 95 SpdyStreamId associated_stream, |
| 95 NetLogCaptureMode capture_mode) { | 96 NetLogCaptureMode capture_mode) { |
| 96 base::DictionaryValue* dict = new base::DictionaryValue(); | 97 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 97 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); | 98 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); |
| 98 dict->SetBoolean("fin", fin); | 99 dict->SetBoolean("fin", fin); |
| 99 dict->SetBoolean("unidirectional", unidirectional); | 100 dict->SetBoolean("unidirectional", unidirectional); |
| 100 dict->SetInteger("priority", static_cast<int>(spdy_priority)); | 101 dict->SetInteger("priority", static_cast<int>(spdy_priority)); |
| 101 dict->SetInteger("stream_id", stream_id); | 102 dict->SetInteger("stream_id", stream_id); |
| 102 dict->SetInteger("associated_stream", associated_stream); | 103 dict->SetInteger("associated_stream", associated_stream); |
| 103 return dict; | 104 return dict.Pass(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 base::Value* NetLogSpdySynReplyOrHeadersReceivedCallback( | 107 scoped_ptr<base::Value> NetLogSpdySynReplyOrHeadersReceivedCallback( |
| 107 const SpdyHeaderBlock* headers, | 108 const SpdyHeaderBlock* headers, |
| 108 bool fin, | 109 bool fin, |
| 109 SpdyStreamId stream_id, | 110 SpdyStreamId stream_id, |
| 110 NetLogCaptureMode capture_mode) { | 111 NetLogCaptureMode capture_mode) { |
| 111 base::DictionaryValue* dict = new base::DictionaryValue(); | 112 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 112 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); | 113 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); |
| 113 dict->SetBoolean("fin", fin); | 114 dict->SetBoolean("fin", fin); |
| 114 dict->SetInteger("stream_id", stream_id); | 115 dict->SetInteger("stream_id", stream_id); |
| 115 return dict; | 116 return dict.Pass(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 base::Value* NetLogSpdySessionCloseCallback( | 119 scoped_ptr<base::Value> NetLogSpdySessionCloseCallback( |
| 119 int net_error, | 120 int net_error, |
| 120 const std::string* description, | 121 const std::string* description, |
| 121 NetLogCaptureMode /* capture_mode */) { | 122 NetLogCaptureMode /* capture_mode */) { |
| 122 base::DictionaryValue* dict = new base::DictionaryValue(); | 123 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 123 dict->SetInteger("net_error", net_error); | 124 dict->SetInteger("net_error", net_error); |
| 124 dict->SetString("description", *description); | 125 dict->SetString("description", *description); |
| 125 return dict; | 126 return dict.Pass(); |
| 126 } | 127 } |
| 127 | 128 |
| 128 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair, | 129 scoped_ptr<base::Value> NetLogSpdySessionCallback( |
| 129 NetLogCaptureMode /* capture_mode */) { | 130 const HostPortProxyPair* host_pair, |
| 130 base::DictionaryValue* dict = new base::DictionaryValue(); | 131 NetLogCaptureMode /* capture_mode */) { |
| 132 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 131 dict->SetString("host", host_pair->first.ToString()); | 133 dict->SetString("host", host_pair->first.ToString()); |
| 132 dict->SetString("proxy", host_pair->second.ToPacString()); | 134 dict->SetString("proxy", host_pair->second.ToPacString()); |
| 133 return dict; | 135 return dict.Pass(); |
| 134 } | 136 } |
| 135 | 137 |
| 136 base::Value* NetLogSpdyInitializedCallback( | 138 scoped_ptr<base::Value> NetLogSpdyInitializedCallback( |
| 137 NetLog::Source source, | 139 NetLog::Source source, |
| 138 const NextProto protocol_version, | 140 const NextProto protocol_version, |
| 139 NetLogCaptureMode /* capture_mode */) { | 141 NetLogCaptureMode /* capture_mode */) { |
| 140 base::DictionaryValue* dict = new base::DictionaryValue(); | 142 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 141 if (source.IsValid()) { | 143 if (source.IsValid()) { |
| 142 source.AddToEventParameters(dict); | 144 source.AddToEventParameters(dict.get()); |
| 143 } | 145 } |
| 144 dict->SetString("protocol", | 146 dict->SetString("protocol", |
| 145 SSLClientSocket::NextProtoToString(protocol_version)); | 147 SSLClientSocket::NextProtoToString(protocol_version)); |
| 146 return dict; | 148 return dict.Pass(); |
| 147 } | 149 } |
| 148 | 150 |
| 149 base::Value* NetLogSpdySettingsCallback(const HostPortPair& host_port_pair, | 151 scoped_ptr<base::Value> NetLogSpdySettingsCallback( |
| 150 bool clear_persisted, | 152 const HostPortPair& host_port_pair, |
| 151 NetLogCaptureMode /* capture_mode */) { | 153 bool clear_persisted, |
| 152 base::DictionaryValue* dict = new base::DictionaryValue(); | 154 NetLogCaptureMode /* capture_mode */) { |
| 155 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 153 dict->SetString("host", host_port_pair.ToString()); | 156 dict->SetString("host", host_port_pair.ToString()); |
| 154 dict->SetBoolean("clear_persisted", clear_persisted); | 157 dict->SetBoolean("clear_persisted", clear_persisted); |
| 155 return dict; | 158 return dict.Pass(); |
| 156 } | 159 } |
| 157 | 160 |
| 158 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id, | 161 scoped_ptr<base::Value> NetLogSpdySettingCallback( |
| 159 const SpdyMajorVersion protocol_version, | 162 SpdySettingsIds id, |
| 160 SpdySettingsFlags flags, | 163 const SpdyMajorVersion protocol_version, |
| 161 uint32 value, | 164 SpdySettingsFlags flags, |
| 162 NetLogCaptureMode /* capture_mode */) { | 165 uint32 value, |
| 163 base::DictionaryValue* dict = new base::DictionaryValue(); | 166 NetLogCaptureMode /* capture_mode */) { |
| 167 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 164 dict->SetInteger("id", | 168 dict->SetInteger("id", |
| 165 SpdyConstants::SerializeSettingId(protocol_version, id)); | 169 SpdyConstants::SerializeSettingId(protocol_version, id)); |
| 166 dict->SetInteger("flags", flags); | 170 dict->SetInteger("flags", flags); |
| 167 dict->SetInteger("value", value); | 171 dict->SetInteger("value", value); |
| 168 return dict; | 172 return dict.Pass(); |
| 169 } | 173 } |
| 170 | 174 |
| 171 base::Value* NetLogSpdySendSettingsCallback( | 175 scoped_ptr<base::Value> NetLogSpdySendSettingsCallback( |
| 172 const SettingsMap* settings, | 176 const SettingsMap* settings, |
| 173 const SpdyMajorVersion protocol_version, | 177 const SpdyMajorVersion protocol_version, |
| 174 NetLogCaptureMode /* capture_mode */) { | 178 NetLogCaptureMode /* capture_mode */) { |
| 175 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 179 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 176 scoped_ptr<base::ListValue> settings_list(new base::ListValue()); | 180 scoped_ptr<base::ListValue> settings_list(new base::ListValue()); |
| 177 for (SettingsMap::const_iterator it = settings->begin(); | 181 for (SettingsMap::const_iterator it = settings->begin(); |
| 178 it != settings->end(); ++it) { | 182 it != settings->end(); ++it) { |
| 179 const SpdySettingsIds id = it->first; | 183 const SpdySettingsIds id = it->first; |
| 180 const SpdySettingsFlags flags = it->second.first; | 184 const SpdySettingsFlags flags = it->second.first; |
| 181 const uint32 value = it->second.second; | 185 const uint32 value = it->second.second; |
| 182 settings_list->Append(new base::StringValue(base::StringPrintf( | 186 settings_list->Append(new base::StringValue(base::StringPrintf( |
| 183 "[id:%u flags:%u value:%u]", | 187 "[id:%u flags:%u value:%u]", |
| 184 SpdyConstants::SerializeSettingId(protocol_version, id), | 188 SpdyConstants::SerializeSettingId(protocol_version, id), |
| 185 flags, | 189 flags, |
| 186 value))); | 190 value))); |
| 187 } | 191 } |
| 188 dict->Set("settings", settings_list.Pass()); | 192 dict->Set("settings", settings_list.Pass()); |
| 189 return dict.release(); | 193 return dict.Pass(); |
| 190 } | 194 } |
| 191 | 195 |
| 192 base::Value* NetLogSpdyWindowUpdateFrameCallback( | 196 scoped_ptr<base::Value> NetLogSpdyWindowUpdateFrameCallback( |
| 193 SpdyStreamId stream_id, | 197 SpdyStreamId stream_id, |
| 194 uint32 delta, | 198 uint32 delta, |
| 195 NetLogCaptureMode /* capture_mode */) { | 199 NetLogCaptureMode /* capture_mode */) { |
| 196 base::DictionaryValue* dict = new base::DictionaryValue(); | 200 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 197 dict->SetInteger("stream_id", static_cast<int>(stream_id)); | 201 dict->SetInteger("stream_id", static_cast<int>(stream_id)); |
| 198 dict->SetInteger("delta", delta); | 202 dict->SetInteger("delta", delta); |
| 199 return dict; | 203 return dict.Pass(); |
| 200 } | 204 } |
| 201 | 205 |
| 202 base::Value* NetLogSpdySessionWindowUpdateCallback( | 206 scoped_ptr<base::Value> NetLogSpdySessionWindowUpdateCallback( |
| 203 int32 delta, | 207 int32 delta, |
| 204 int32 window_size, | 208 int32 window_size, |
| 205 NetLogCaptureMode /* capture_mode */) { | 209 NetLogCaptureMode /* capture_mode */) { |
| 206 base::DictionaryValue* dict = new base::DictionaryValue(); | 210 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 207 dict->SetInteger("delta", delta); | 211 dict->SetInteger("delta", delta); |
| 208 dict->SetInteger("window_size", window_size); | 212 dict->SetInteger("window_size", window_size); |
| 209 return dict; | 213 return dict.Pass(); |
| 210 } | 214 } |
| 211 | 215 |
| 212 base::Value* NetLogSpdyDataCallback(SpdyStreamId stream_id, | 216 scoped_ptr<base::Value> NetLogSpdyDataCallback( |
| 213 int size, | 217 SpdyStreamId stream_id, |
| 214 bool fin, | 218 int size, |
| 215 NetLogCaptureMode /* capture_mode */) { | 219 bool fin, |
| 216 base::DictionaryValue* dict = new base::DictionaryValue(); | 220 NetLogCaptureMode /* capture_mode */) { |
| 221 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 217 dict->SetInteger("stream_id", static_cast<int>(stream_id)); | 222 dict->SetInteger("stream_id", static_cast<int>(stream_id)); |
| 218 dict->SetInteger("size", size); | 223 dict->SetInteger("size", size); |
| 219 dict->SetBoolean("fin", fin); | 224 dict->SetBoolean("fin", fin); |
| 220 return dict; | 225 return dict.Pass(); |
| 221 } | 226 } |
| 222 | 227 |
| 223 base::Value* NetLogSpdyRstCallback(SpdyStreamId stream_id, | 228 scoped_ptr<base::Value> NetLogSpdyRstCallback( |
| 224 int status, | 229 SpdyStreamId stream_id, |
| 225 const std::string* description, | 230 int status, |
| 226 NetLogCaptureMode /* capture_mode */) { | 231 const std::string* description, |
| 227 base::DictionaryValue* dict = new base::DictionaryValue(); | 232 NetLogCaptureMode /* capture_mode */) { |
| 233 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 228 dict->SetInteger("stream_id", static_cast<int>(stream_id)); | 234 dict->SetInteger("stream_id", static_cast<int>(stream_id)); |
| 229 dict->SetInteger("status", status); | 235 dict->SetInteger("status", status); |
| 230 dict->SetString("description", *description); | 236 dict->SetString("description", *description); |
| 231 return dict; | 237 return dict.Pass(); |
| 232 } | 238 } |
| 233 | 239 |
| 234 base::Value* NetLogSpdyPingCallback(SpdyPingId unique_id, | 240 scoped_ptr<base::Value> NetLogSpdyPingCallback( |
| 235 bool is_ack, | 241 SpdyPingId unique_id, |
| 236 const char* type, | 242 bool is_ack, |
| 237 NetLogCaptureMode /* capture_mode */) { | 243 const char* type, |
| 238 base::DictionaryValue* dict = new base::DictionaryValue(); | 244 NetLogCaptureMode /* capture_mode */) { |
| 245 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 239 dict->SetInteger("unique_id", static_cast<int>(unique_id)); | 246 dict->SetInteger("unique_id", static_cast<int>(unique_id)); |
| 240 dict->SetString("type", type); | 247 dict->SetString("type", type); |
| 241 dict->SetBoolean("is_ack", is_ack); | 248 dict->SetBoolean("is_ack", is_ack); |
| 242 return dict; | 249 return dict.Pass(); |
| 243 } | 250 } |
| 244 | 251 |
| 245 base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id, | 252 scoped_ptr<base::Value> NetLogSpdyGoAwayCallback( |
| 246 int active_streams, | 253 SpdyStreamId last_stream_id, |
| 247 int unclaimed_streams, | 254 int active_streams, |
| 248 SpdyGoAwayStatus status, | 255 int unclaimed_streams, |
| 249 NetLogCaptureMode /* capture_mode */) { | 256 SpdyGoAwayStatus status, |
| 250 base::DictionaryValue* dict = new base::DictionaryValue(); | 257 NetLogCaptureMode /* capture_mode */) { |
| 258 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 251 dict->SetInteger("last_accepted_stream_id", | 259 dict->SetInteger("last_accepted_stream_id", |
| 252 static_cast<int>(last_stream_id)); | 260 static_cast<int>(last_stream_id)); |
| 253 dict->SetInteger("active_streams", active_streams); | 261 dict->SetInteger("active_streams", active_streams); |
| 254 dict->SetInteger("unclaimed_streams", unclaimed_streams); | 262 dict->SetInteger("unclaimed_streams", unclaimed_streams); |
| 255 dict->SetInteger("status", static_cast<int>(status)); | 263 dict->SetInteger("status", static_cast<int>(status)); |
| 256 return dict; | 264 return dict.Pass(); |
| 257 } | 265 } |
| 258 | 266 |
| 259 base::Value* NetLogSpdyPushPromiseReceivedCallback( | 267 scoped_ptr<base::Value> NetLogSpdyPushPromiseReceivedCallback( |
| 260 const SpdyHeaderBlock* headers, | 268 const SpdyHeaderBlock* headers, |
| 261 SpdyStreamId stream_id, | 269 SpdyStreamId stream_id, |
| 262 SpdyStreamId promised_stream_id, | 270 SpdyStreamId promised_stream_id, |
| 263 NetLogCaptureMode capture_mode) { | 271 NetLogCaptureMode capture_mode) { |
| 264 base::DictionaryValue* dict = new base::DictionaryValue(); | 272 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 265 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); | 273 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); |
| 266 dict->SetInteger("id", stream_id); | 274 dict->SetInteger("id", stream_id); |
| 267 dict->SetInteger("promised_stream_id", promised_stream_id); | 275 dict->SetInteger("promised_stream_id", promised_stream_id); |
| 268 return dict; | 276 return dict.Pass(); |
| 269 } | 277 } |
| 270 | 278 |
| 271 base::Value* NetLogSpdyAdoptedPushStreamCallback( | 279 scoped_ptr<base::Value> NetLogSpdyAdoptedPushStreamCallback( |
| 272 SpdyStreamId stream_id, | 280 SpdyStreamId stream_id, |
| 273 const GURL* url, | 281 const GURL* url, |
| 274 NetLogCaptureMode capture_mode) { | 282 NetLogCaptureMode capture_mode) { |
| 275 base::DictionaryValue* dict = new base::DictionaryValue(); | 283 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 276 dict->SetInteger("stream_id", stream_id); | 284 dict->SetInteger("stream_id", stream_id); |
| 277 dict->SetString("url", url->spec()); | 285 dict->SetString("url", url->spec()); |
| 278 return dict; | 286 return dict.Pass(); |
| 279 } | 287 } |
| 280 | 288 |
| 281 // Helper function to return the total size of an array of objects | 289 // Helper function to return the total size of an array of objects |
| 282 // with .size() member functions. | 290 // with .size() member functions. |
| 283 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) { | 291 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) { |
| 284 size_t total_size = 0; | 292 size_t total_size = 0; |
| 285 for (size_t i = 0; i < N; ++i) { | 293 for (size_t i = 0; i < N; ++i) { |
| 286 total_size += arr[i].size(); | 294 total_size += arr[i].size(); |
| 287 } | 295 } |
| 288 return total_size; | 296 return total_size; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), | 677 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), |
| 670 hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), | 678 hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), |
| 671 trusted_spdy_proxy_(trusted_spdy_proxy), | 679 trusted_spdy_proxy_(trusted_spdy_proxy), |
| 672 time_func_(time_func), | 680 time_func_(time_func), |
| 673 weak_factory_(this) { | 681 weak_factory_(this) { |
| 674 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); | 682 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); |
| 675 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); | 683 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); |
| 676 DCHECK(HttpStreamFactory::spdy_enabled()); | 684 DCHECK(HttpStreamFactory::spdy_enabled()); |
| 677 net_log_.BeginEvent( | 685 net_log_.BeginEvent( |
| 678 NetLog::TYPE_HTTP2_SESSION, | 686 NetLog::TYPE_HTTP2_SESSION, |
| 679 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair())); | 687 base::Bind(NetLogSpdySessionCallback, &host_port_proxy_pair())); |
| 680 next_unclaimed_push_stream_sweep_time_ = time_func_() + | 688 next_unclaimed_push_stream_sweep_time_ = time_func_() + |
| 681 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); | 689 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); |
| 682 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. | 690 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. |
| 683 } | 691 } |
| 684 | 692 |
| 685 SpdySession::~SpdySession() { | 693 SpdySession::~SpdySession() { |
| 686 CHECK(!in_io_loop_); | 694 CHECK(!in_io_loop_); |
| 687 DcheckDraining(); | 695 DcheckDraining(); |
| 688 | 696 |
| 689 // TODO(akalin): Check connection->is_initialized() instead. This | 697 // TODO(akalin): Check connection->is_initialized() instead. This |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 enable_compression_)); | 754 enable_compression_)); |
| 747 buffered_spdy_framer_->set_visitor(this); | 755 buffered_spdy_framer_->set_visitor(this); |
| 748 buffered_spdy_framer_->set_debug_visitor(this); | 756 buffered_spdy_framer_->set_debug_visitor(this); |
| 749 UMA_HISTOGRAM_ENUMERATION( | 757 UMA_HISTOGRAM_ENUMERATION( |
| 750 "Net.SpdyVersion2", | 758 "Net.SpdyVersion2", |
| 751 protocol_ - kProtoSPDYHistogramOffset, | 759 protocol_ - kProtoSPDYHistogramOffset, |
| 752 kProtoSPDYMaximumVersion - kProtoSPDYMinimumVersion + 1); | 760 kProtoSPDYMaximumVersion - kProtoSPDYMinimumVersion + 1); |
| 753 | 761 |
| 754 net_log_.AddEvent( | 762 net_log_.AddEvent( |
| 755 NetLog::TYPE_HTTP2_SESSION_INITIALIZED, | 763 NetLog::TYPE_HTTP2_SESSION_INITIALIZED, |
| 756 base::Bind(&NetLogSpdyInitializedCallback, | 764 base::Bind(NetLogSpdyInitializedCallback, |
| 757 connection_->socket()->NetLog().source(), protocol_)); | 765 connection_->socket()->NetLog().source(), protocol_)); |
| 758 | 766 |
| 759 DCHECK_EQ(availability_state_, STATE_AVAILABLE); | 767 DCHECK_EQ(availability_state_, STATE_AVAILABLE); |
| 760 connection_->AddHigherLayeredPool(this); | 768 connection_->AddHigherLayeredPool(this); |
| 761 if (enable_sending_initial_data_) | 769 if (enable_sending_initial_data_) |
| 762 SendInitialData(); | 770 SendInitialData(); |
| 763 pool_ = pool; | 771 pool_ = pool; |
| 764 | 772 |
| 765 // Bootstrap the read loop. | 773 // Bootstrap the read loop. |
| 766 base::MessageLoop::current()->PostTask( | 774 base::MessageLoop::current()->PostTask( |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 } | 1081 } |
| 1074 | 1082 |
| 1075 streams_initiated_count_++; | 1083 streams_initiated_count_++; |
| 1076 | 1084 |
| 1077 if (net_log().IsCapturing()) { | 1085 if (net_log().IsCapturing()) { |
| 1078 const NetLog::EventType type = | 1086 const NetLog::EventType type = |
| 1079 (GetProtocolVersion() <= SPDY3) | 1087 (GetProtocolVersion() <= SPDY3) |
| 1080 ? NetLog::TYPE_HTTP2_SESSION_SYN_STREAM | 1088 ? NetLog::TYPE_HTTP2_SESSION_SYN_STREAM |
| 1081 : NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS; | 1089 : NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS; |
| 1082 net_log().AddEvent(type, | 1090 net_log().AddEvent(type, |
| 1083 base::Bind(&NetLogSpdySynStreamSentCallback, &block, | 1091 base::Bind(NetLogSpdySynStreamSentCallback, &block, |
| 1084 (flags & CONTROL_FLAG_FIN) != 0, | 1092 (flags & CONTROL_FLAG_FIN) != 0, |
| 1085 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, | 1093 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, |
| 1086 spdy_priority, stream_id)); | 1094 spdy_priority, stream_id)); |
| 1087 } | 1095 } |
| 1088 | 1096 |
| 1089 return syn_frame.Pass(); | 1097 return syn_frame.Pass(); |
| 1090 } | 1098 } |
| 1091 | 1099 |
| 1092 scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, | 1100 scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, |
| 1093 IOBuffer* data, | 1101 IOBuffer* data, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 | 1187 |
| 1180 DCHECK_GE(effective_len, 0); | 1188 DCHECK_GE(effective_len, 0); |
| 1181 | 1189 |
| 1182 // Clear FIN flag if only some of the data will be in the data | 1190 // Clear FIN flag if only some of the data will be in the data |
| 1183 // frame. | 1191 // frame. |
| 1184 if (effective_len < len) | 1192 if (effective_len < len) |
| 1185 flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_FIN); | 1193 flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_FIN); |
| 1186 | 1194 |
| 1187 if (net_log().IsCapturing()) { | 1195 if (net_log().IsCapturing()) { |
| 1188 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SEND_DATA, | 1196 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SEND_DATA, |
| 1189 base::Bind(&NetLogSpdyDataCallback, stream_id, | 1197 base::Bind(NetLogSpdyDataCallback, stream_id, |
| 1190 effective_len, (flags & DATA_FLAG_FIN) != 0)); | 1198 effective_len, (flags & DATA_FLAG_FIN) != 0)); |
| 1191 } | 1199 } |
| 1192 | 1200 |
| 1193 // Send PrefacePing for DATA_FRAMEs with nonzero payload size. | 1201 // Send PrefacePing for DATA_FRAMEs with nonzero payload size. |
| 1194 if (effective_len > 0) | 1202 if (effective_len > 0) |
| 1195 SendPrefacePingIfNoneInFlight(); | 1203 SendPrefacePingIfNoneInFlight(); |
| 1196 | 1204 |
| 1197 // TODO(mbelshe): reduce memory copies here. | 1205 // TODO(mbelshe): reduce memory copies here. |
| 1198 DCHECK(buffered_spdy_framer_.get()); | 1206 DCHECK(buffered_spdy_framer_.get()); |
| 1199 scoped_ptr<SpdyFrame> frame( | 1207 scoped_ptr<SpdyFrame> frame( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 } | 1328 } |
| 1321 | 1329 |
| 1322 void SpdySession::EnqueueResetStreamFrame(SpdyStreamId stream_id, | 1330 void SpdySession::EnqueueResetStreamFrame(SpdyStreamId stream_id, |
| 1323 RequestPriority priority, | 1331 RequestPriority priority, |
| 1324 SpdyRstStreamStatus status, | 1332 SpdyRstStreamStatus status, |
| 1325 const std::string& description) { | 1333 const std::string& description) { |
| 1326 DCHECK_NE(stream_id, 0u); | 1334 DCHECK_NE(stream_id, 0u); |
| 1327 | 1335 |
| 1328 net_log().AddEvent( | 1336 net_log().AddEvent( |
| 1329 NetLog::TYPE_HTTP2_SESSION_SEND_RST_STREAM, | 1337 NetLog::TYPE_HTTP2_SESSION_SEND_RST_STREAM, |
| 1330 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description)); | 1338 base::Bind(NetLogSpdyRstCallback, stream_id, status, &description)); |
| 1331 | 1339 |
| 1332 DCHECK(buffered_spdy_framer_.get()); | 1340 DCHECK(buffered_spdy_framer_.get()); |
| 1333 scoped_ptr<SpdyFrame> rst_frame( | 1341 scoped_ptr<SpdyFrame> rst_frame( |
| 1334 buffered_spdy_framer_->CreateRstStream(stream_id, status)); | 1342 buffered_spdy_framer_->CreateRstStream(stream_id, status)); |
| 1335 | 1343 |
| 1336 EnqueueSessionWrite(priority, RST_STREAM, rst_frame.Pass()); | 1344 EnqueueSessionWrite(priority, RST_STREAM, rst_frame.Pass()); |
| 1337 RecordProtocolErrorHistogram(MapRstStreamStatusToProtocolError(status)); | 1345 RecordProtocolErrorHistogram(MapRstStreamStatusToProtocolError(status)); |
| 1338 } | 1346 } |
| 1339 | 1347 |
| 1340 void SpdySession::PumpReadLoop(ReadState expected_read_state, int result) { | 1348 void SpdySession::PumpReadLoop(ReadState expected_read_state, int result) { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 GOAWAY, | 1729 GOAWAY, |
| 1722 scoped_ptr<SpdyFrame>( | 1730 scoped_ptr<SpdyFrame>( |
| 1723 buffered_spdy_framer_->SerializeFrame(goaway_ir))); | 1731 buffered_spdy_framer_->SerializeFrame(goaway_ir))); |
| 1724 } | 1732 } |
| 1725 | 1733 |
| 1726 availability_state_ = STATE_DRAINING; | 1734 availability_state_ = STATE_DRAINING; |
| 1727 error_on_close_ = err; | 1735 error_on_close_ = err; |
| 1728 | 1736 |
| 1729 net_log_.AddEvent( | 1737 net_log_.AddEvent( |
| 1730 NetLog::TYPE_HTTP2_SESSION_CLOSE, | 1738 NetLog::TYPE_HTTP2_SESSION_CLOSE, |
| 1731 base::Bind(&NetLogSpdySessionCloseCallback, err, &description)); | 1739 base::Bind(NetLogSpdySessionCloseCallback, err, &description)); |
| 1732 | 1740 |
| 1733 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SpdySession.ClosedOnError", -err); | 1741 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SpdySession.ClosedOnError", -err); |
| 1734 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySession.BytesRead.OtherErrors", | 1742 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySession.BytesRead.OtherErrors", |
| 1735 total_bytes_received_, 1, 100000000, 50); | 1743 total_bytes_received_, 1, 100000000, 50); |
| 1736 | 1744 |
| 1737 if (err == OK) { | 1745 if (err == OK) { |
| 1738 // We ought to be going away already, as this is a graceful close. | 1746 // We ought to be going away already, as this is a graceful close. |
| 1739 DcheckGoingAway(); | 1747 DcheckGoingAway(); |
| 1740 } else { | 1748 } else { |
| 1741 StartGoingAway(0, err); | 1749 StartGoingAway(0, err); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 SpdyStreamId stream_id = unclaimed_it->second.stream_id; | 1963 SpdyStreamId stream_id = unclaimed_it->second.stream_id; |
| 1956 unclaimed_pushed_streams_.erase(unclaimed_it); | 1964 unclaimed_pushed_streams_.erase(unclaimed_it); |
| 1957 | 1965 |
| 1958 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); | 1966 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); |
| 1959 if (active_it == active_streams_.end()) { | 1967 if (active_it == active_streams_.end()) { |
| 1960 NOTREACHED(); | 1968 NOTREACHED(); |
| 1961 return base::WeakPtr<SpdyStream>(); | 1969 return base::WeakPtr<SpdyStream>(); |
| 1962 } | 1970 } |
| 1963 | 1971 |
| 1964 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ADOPTED_PUSH_STREAM, | 1972 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ADOPTED_PUSH_STREAM, |
| 1965 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, | 1973 base::Bind(NetLogSpdyAdoptedPushStreamCallback, |
| 1966 active_it->second.stream->stream_id(), &url)); | 1974 active_it->second.stream->stream_id(), &url)); |
| 1967 return active_it->second.stream->GetWeakPtr(); | 1975 return active_it->second.stream->GetWeakPtr(); |
| 1968 } | 1976 } |
| 1969 | 1977 |
| 1970 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, | 1978 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, |
| 1971 bool* was_npn_negotiated, | 1979 bool* was_npn_negotiated, |
| 1972 NextProto* protocol_negotiated) { | 1980 NextProto* protocol_negotiated) { |
| 1973 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); | 1981 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); |
| 1974 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); | 1982 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); |
| 1975 return connection_->socket()->GetSSLInfo(ssl_info); | 1983 return connection_->socket()->GetSSLInfo(ssl_info); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 stream->IncrementRawReceivedBytes(header_len); | 2029 stream->IncrementRawReceivedBytes(header_len); |
| 2022 } | 2030 } |
| 2023 | 2031 |
| 2024 void SpdySession::OnStreamFrameData(SpdyStreamId stream_id, | 2032 void SpdySession::OnStreamFrameData(SpdyStreamId stream_id, |
| 2025 const char* data, | 2033 const char* data, |
| 2026 size_t len, | 2034 size_t len, |
| 2027 bool fin) { | 2035 bool fin) { |
| 2028 CHECK(in_io_loop_); | 2036 CHECK(in_io_loop_); |
| 2029 DCHECK_LT(len, 1u << 24); | 2037 DCHECK_LT(len, 1u << 24); |
| 2030 if (net_log().IsCapturing()) { | 2038 if (net_log().IsCapturing()) { |
| 2031 net_log().AddEvent( | 2039 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_DATA, |
| 2032 NetLog::TYPE_HTTP2_SESSION_RECV_DATA, | 2040 base::Bind(NetLogSpdyDataCallback, stream_id, len, fin)); |
| 2033 base::Bind(&NetLogSpdyDataCallback, stream_id, len, fin)); | |
| 2034 } | 2041 } |
| 2035 | 2042 |
| 2036 // Build the buffer as early as possible so that we go through the | 2043 // Build the buffer as early as possible so that we go through the |
| 2037 // session flow control checks and update | 2044 // session flow control checks and update |
| 2038 // |unacked_recv_window_bytes_| properly even when the stream is | 2045 // |unacked_recv_window_bytes_| properly even when the stream is |
| 2039 // inactive (since the other side has still reduced its session send | 2046 // inactive (since the other side has still reduced its session send |
| 2040 // window). | 2047 // window). |
| 2041 scoped_ptr<SpdyBuffer> buffer; | 2048 scoped_ptr<SpdyBuffer> buffer; |
| 2042 if (data) { | 2049 if (data) { |
| 2043 DCHECK_GT(len, 0u); | 2050 DCHECK_GT(len, 0u); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 } | 2102 } |
| 2096 | 2103 |
| 2097 void SpdySession::OnSettings(bool clear_persisted) { | 2104 void SpdySession::OnSettings(bool clear_persisted) { |
| 2098 CHECK(in_io_loop_); | 2105 CHECK(in_io_loop_); |
| 2099 | 2106 |
| 2100 if (clear_persisted) | 2107 if (clear_persisted) |
| 2101 http_server_properties_->ClearSpdySettings(host_port_pair()); | 2108 http_server_properties_->ClearSpdySettings(host_port_pair()); |
| 2102 | 2109 |
| 2103 if (net_log_.IsCapturing()) { | 2110 if (net_log_.IsCapturing()) { |
| 2104 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, | 2111 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, |
| 2105 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), | 2112 base::Bind(NetLogSpdySettingsCallback, host_port_pair(), |
| 2106 clear_persisted)); | 2113 clear_persisted)); |
| 2107 } | 2114 } |
| 2108 | 2115 |
| 2109 if (GetProtocolVersion() >= SPDY4) { | 2116 if (GetProtocolVersion() >= SPDY4) { |
| 2110 // Send an acknowledgment of the setting. | 2117 // Send an acknowledgment of the setting. |
| 2111 SpdySettingsIR settings_ir; | 2118 SpdySettingsIR settings_ir; |
| 2112 settings_ir.set_is_ack(true); | 2119 settings_ir.set_is_ack(true); |
| 2113 EnqueueSessionWrite( | 2120 EnqueueSessionWrite( |
| 2114 HIGHEST, | 2121 HIGHEST, |
| 2115 SETTINGS, | 2122 SETTINGS, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2127 http_server_properties_->SetSpdySetting( | 2134 http_server_properties_->SetSpdySetting( |
| 2128 host_port_pair(), | 2135 host_port_pair(), |
| 2129 id, | 2136 id, |
| 2130 static_cast<SpdySettingsFlags>(flags), | 2137 static_cast<SpdySettingsFlags>(flags), |
| 2131 value); | 2138 value); |
| 2132 received_settings_ = true; | 2139 received_settings_ = true; |
| 2133 | 2140 |
| 2134 // Log the setting. | 2141 // Log the setting. |
| 2135 const SpdyMajorVersion protocol_version = GetProtocolVersion(); | 2142 const SpdyMajorVersion protocol_version = GetProtocolVersion(); |
| 2136 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTING, | 2143 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTING, |
| 2137 base::Bind(&NetLogSpdySettingCallback, id, protocol_version, | 2144 base::Bind(NetLogSpdySettingCallback, id, protocol_version, |
| 2138 static_cast<SpdySettingsFlags>(flags), value)); | 2145 static_cast<SpdySettingsFlags>(flags), value)); |
| 2139 } | 2146 } |
| 2140 | 2147 |
| 2141 void SpdySession::OnSendCompressedFrame( | 2148 void SpdySession::OnSendCompressedFrame( |
| 2142 SpdyStreamId stream_id, | 2149 SpdyStreamId stream_id, |
| 2143 SpdyFrameType type, | 2150 SpdyFrameType type, |
| 2144 size_t payload_len, | 2151 size_t payload_len, |
| 2145 size_t frame_len) { | 2152 size_t frame_len) { |
| 2146 if (type != SYN_STREAM && type != HEADERS) | 2153 if (type != SYN_STREAM && type != HEADERS) |
| 2147 return; | 2154 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 CHECK(in_io_loop_); | 2216 CHECK(in_io_loop_); |
| 2210 | 2217 |
| 2211 DCHECK_LE(GetProtocolVersion(), SPDY3); | 2218 DCHECK_LE(GetProtocolVersion(), SPDY3); |
| 2212 | 2219 |
| 2213 base::Time response_time = base::Time::Now(); | 2220 base::Time response_time = base::Time::Now(); |
| 2214 base::TimeTicks recv_first_byte_time = time_func_(); | 2221 base::TimeTicks recv_first_byte_time = time_func_(); |
| 2215 | 2222 |
| 2216 if (net_log_.IsCapturing()) { | 2223 if (net_log_.IsCapturing()) { |
| 2217 net_log_.AddEvent( | 2224 net_log_.AddEvent( |
| 2218 NetLog::TYPE_HTTP2_SESSION_PUSHED_SYN_STREAM, | 2225 NetLog::TYPE_HTTP2_SESSION_PUSHED_SYN_STREAM, |
| 2219 base::Bind(&NetLogSpdySynStreamReceivedCallback, &headers, fin, | 2226 base::Bind(NetLogSpdySynStreamReceivedCallback, &headers, fin, |
| 2220 unidirectional, priority, stream_id, associated_stream_id)); | 2227 unidirectional, priority, stream_id, associated_stream_id)); |
| 2221 } | 2228 } |
| 2222 | 2229 |
| 2223 // Split headers to simulate push promise and response. | 2230 // Split headers to simulate push promise and response. |
| 2224 SpdyHeaderBlock request_headers; | 2231 SpdyHeaderBlock request_headers; |
| 2225 SpdyHeaderBlock response_headers; | 2232 SpdyHeaderBlock response_headers; |
| 2226 SplitPushedHeadersToRequestAndResponse( | 2233 SplitPushedHeadersToRequestAndResponse( |
| 2227 headers, GetProtocolVersion(), &request_headers, &response_headers); | 2234 headers, GetProtocolVersion(), &request_headers, &response_headers); |
| 2228 | 2235 |
| 2229 if (!TryCreatePushStream( | 2236 if (!TryCreatePushStream( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2280 void SpdySession::OnSynReply(SpdyStreamId stream_id, | 2287 void SpdySession::OnSynReply(SpdyStreamId stream_id, |
| 2281 bool fin, | 2288 bool fin, |
| 2282 const SpdyHeaderBlock& headers) { | 2289 const SpdyHeaderBlock& headers) { |
| 2283 CHECK(in_io_loop_); | 2290 CHECK(in_io_loop_); |
| 2284 | 2291 |
| 2285 base::Time response_time = base::Time::Now(); | 2292 base::Time response_time = base::Time::Now(); |
| 2286 base::TimeTicks recv_first_byte_time = time_func_(); | 2293 base::TimeTicks recv_first_byte_time = time_func_(); |
| 2287 | 2294 |
| 2288 if (net_log().IsCapturing()) { | 2295 if (net_log().IsCapturing()) { |
| 2289 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SYN_REPLY, | 2296 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SYN_REPLY, |
| 2290 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, | 2297 base::Bind(NetLogSpdySynReplyOrHeadersReceivedCallback, |
| 2291 &headers, fin, stream_id)); | 2298 &headers, fin, stream_id)); |
| 2292 } | 2299 } |
| 2293 | 2300 |
| 2294 ActiveStreamMap::iterator it = active_streams_.find(stream_id); | 2301 ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
| 2295 if (it == active_streams_.end()) { | 2302 if (it == active_streams_.end()) { |
| 2296 // NOTE: it may just be that the stream was cancelled. | 2303 // NOTE: it may just be that the stream was cancelled. |
| 2297 return; | 2304 return; |
| 2298 } | 2305 } |
| 2299 | 2306 |
| 2300 SpdyStream* stream = it->second.stream; | 2307 SpdyStream* stream = it->second.stream; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2325 | 2332 |
| 2326 void SpdySession::OnHeaders(SpdyStreamId stream_id, | 2333 void SpdySession::OnHeaders(SpdyStreamId stream_id, |
| 2327 bool has_priority, | 2334 bool has_priority, |
| 2328 SpdyPriority priority, | 2335 SpdyPriority priority, |
| 2329 bool fin, | 2336 bool fin, |
| 2330 const SpdyHeaderBlock& headers) { | 2337 const SpdyHeaderBlock& headers) { |
| 2331 CHECK(in_io_loop_); | 2338 CHECK(in_io_loop_); |
| 2332 | 2339 |
| 2333 if (net_log().IsCapturing()) { | 2340 if (net_log().IsCapturing()) { |
| 2334 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_HEADERS, | 2341 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_HEADERS, |
| 2335 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, | 2342 base::Bind(NetLogSpdySynReplyOrHeadersReceivedCallback, |
| 2336 &headers, fin, stream_id)); | 2343 &headers, fin, stream_id)); |
| 2337 } | 2344 } |
| 2338 | 2345 |
| 2339 ActiveStreamMap::iterator it = active_streams_.find(stream_id); | 2346 ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
| 2340 if (it == active_streams_.end()) { | 2347 if (it == active_streams_.end()) { |
| 2341 // NOTE: it may just be that the stream was cancelled. | 2348 // NOTE: it may just be that the stream was cancelled. |
| 2342 LOG(WARNING) << "Received HEADERS for invalid stream " << stream_id; | 2349 LOG(WARNING) << "Received HEADERS for invalid stream " << stream_id; |
| 2343 return; | 2350 return; |
| 2344 } | 2351 } |
| 2345 | 2352 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 return true; | 2395 return true; |
| 2389 } | 2396 } |
| 2390 | 2397 |
| 2391 void SpdySession::OnRstStream(SpdyStreamId stream_id, | 2398 void SpdySession::OnRstStream(SpdyStreamId stream_id, |
| 2392 SpdyRstStreamStatus status) { | 2399 SpdyRstStreamStatus status) { |
| 2393 CHECK(in_io_loop_); | 2400 CHECK(in_io_loop_); |
| 2394 | 2401 |
| 2395 std::string description; | 2402 std::string description; |
| 2396 net_log().AddEvent( | 2403 net_log().AddEvent( |
| 2397 NetLog::TYPE_HTTP2_SESSION_RST_STREAM, | 2404 NetLog::TYPE_HTTP2_SESSION_RST_STREAM, |
| 2398 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description)); | 2405 base::Bind(NetLogSpdyRstCallback, stream_id, status, &description)); |
| 2399 | 2406 |
| 2400 ActiveStreamMap::iterator it = active_streams_.find(stream_id); | 2407 ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
| 2401 if (it == active_streams_.end()) { | 2408 if (it == active_streams_.end()) { |
| 2402 // NOTE: it may just be that the stream was cancelled. | 2409 // NOTE: it may just be that the stream was cancelled. |
| 2403 LOG(WARNING) << "Received RST for invalid stream" << stream_id; | 2410 LOG(WARNING) << "Received RST for invalid stream" << stream_id; |
| 2404 return; | 2411 return; |
| 2405 } | 2412 } |
| 2406 | 2413 |
| 2407 CHECK_EQ(it->second.stream->stream_id(), stream_id); | 2414 CHECK_EQ(it->second.stream->stream_id(), stream_id); |
| 2408 | 2415 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2429 } | 2436 } |
| 2430 } | 2437 } |
| 2431 | 2438 |
| 2432 void SpdySession::OnGoAway(SpdyStreamId last_accepted_stream_id, | 2439 void SpdySession::OnGoAway(SpdyStreamId last_accepted_stream_id, |
| 2433 SpdyGoAwayStatus status) { | 2440 SpdyGoAwayStatus status) { |
| 2434 CHECK(in_io_loop_); | 2441 CHECK(in_io_loop_); |
| 2435 | 2442 |
| 2436 // TODO(jgraettinger): UMA histogram on |status|. | 2443 // TODO(jgraettinger): UMA histogram on |status|. |
| 2437 | 2444 |
| 2438 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_GOAWAY, | 2445 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_GOAWAY, |
| 2439 base::Bind(&NetLogSpdyGoAwayCallback, | 2446 base::Bind(NetLogSpdyGoAwayCallback, |
| 2440 last_accepted_stream_id, active_streams_.size(), | 2447 last_accepted_stream_id, active_streams_.size(), |
| 2441 unclaimed_pushed_streams_.size(), status)); | 2448 unclaimed_pushed_streams_.size(), status)); |
| 2442 MakeUnavailable(); | 2449 MakeUnavailable(); |
| 2443 if (status == GOAWAY_HTTP_1_1_REQUIRED) { | 2450 if (status == GOAWAY_HTTP_1_1_REQUIRED) { |
| 2444 // TODO(bnc): Record histogram with number of open streams capped at 50. | 2451 // TODO(bnc): Record histogram with number of open streams capped at 50. |
| 2445 DoDrainSession(ERR_HTTP_1_1_REQUIRED, "HTTP_1_1_REQUIRED for stream."); | 2452 DoDrainSession(ERR_HTTP_1_1_REQUIRED, "HTTP_1_1_REQUIRED for stream."); |
| 2446 } else { | 2453 } else { |
| 2447 StartGoingAway(last_accepted_stream_id, ERR_ABORTED); | 2454 StartGoingAway(last_accepted_stream_id, ERR_ABORTED); |
| 2448 } | 2455 } |
| 2449 // This is to handle the case when we already don't have any active | 2456 // This is to handle the case when we already don't have any active |
| 2450 // streams (i.e., StartGoingAway() did nothing). Otherwise, we have | 2457 // streams (i.e., StartGoingAway() did nothing). Otherwise, we have |
| 2451 // active streams and so the last one being closed will finish the | 2458 // active streams and so the last one being closed will finish the |
| 2452 // going away process (see DeleteStream()). | 2459 // going away process (see DeleteStream()). |
| 2453 MaybeFinishGoingAway(); | 2460 MaybeFinishGoingAway(); |
| 2454 } | 2461 } |
| 2455 | 2462 |
| 2456 void SpdySession::OnPing(SpdyPingId unique_id, bool is_ack) { | 2463 void SpdySession::OnPing(SpdyPingId unique_id, bool is_ack) { |
| 2457 CHECK(in_io_loop_); | 2464 CHECK(in_io_loop_); |
| 2458 | 2465 |
| 2459 net_log_.AddEvent( | 2466 net_log_.AddEvent( |
| 2460 NetLog::TYPE_HTTP2_SESSION_PING, | 2467 NetLog::TYPE_HTTP2_SESSION_PING, |
| 2461 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "received")); | 2468 base::Bind(NetLogSpdyPingCallback, unique_id, is_ack, "received")); |
| 2462 | 2469 |
| 2463 // Send response to a PING from server. | 2470 // Send response to a PING from server. |
| 2464 if ((protocol_ >= kProtoSPDY4MinimumVersion && !is_ack) || | 2471 if ((protocol_ >= kProtoSPDY4MinimumVersion && !is_ack) || |
| 2465 (protocol_ < kProtoSPDY4MinimumVersion && unique_id % 2 == 0)) { | 2472 (protocol_ < kProtoSPDY4MinimumVersion && unique_id % 2 == 0)) { |
| 2466 WritePingFrame(unique_id, true); | 2473 WritePingFrame(unique_id, true); |
| 2467 return; | 2474 return; |
| 2468 } | 2475 } |
| 2469 | 2476 |
| 2470 --pings_in_flight_; | 2477 --pings_in_flight_; |
| 2471 if (pings_in_flight_ < 0) { | 2478 if (pings_in_flight_ < 0) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2482 // pings_in_flight_. | 2489 // pings_in_flight_. |
| 2483 RecordPingRTTHistogram(time_func_() - last_ping_sent_time_); | 2490 RecordPingRTTHistogram(time_func_() - last_ping_sent_time_); |
| 2484 } | 2491 } |
| 2485 | 2492 |
| 2486 void SpdySession::OnWindowUpdate(SpdyStreamId stream_id, | 2493 void SpdySession::OnWindowUpdate(SpdyStreamId stream_id, |
| 2487 uint32 delta_window_size) { | 2494 uint32 delta_window_size) { |
| 2488 CHECK(in_io_loop_); | 2495 CHECK(in_io_loop_); |
| 2489 | 2496 |
| 2490 DCHECK_LE(delta_window_size, static_cast<uint32>(kint32max)); | 2497 DCHECK_LE(delta_window_size, static_cast<uint32>(kint32max)); |
| 2491 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECEIVED_WINDOW_UPDATE_FRAME, | 2498 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECEIVED_WINDOW_UPDATE_FRAME, |
| 2492 base::Bind(&NetLogSpdyWindowUpdateFrameCallback, stream_id, | 2499 base::Bind(NetLogSpdyWindowUpdateFrameCallback, stream_id, |
| 2493 delta_window_size)); | 2500 delta_window_size)); |
| 2494 | 2501 |
| 2495 if (stream_id == kSessionFlowControlStreamId) { | 2502 if (stream_id == kSessionFlowControlStreamId) { |
| 2496 // WINDOW_UPDATE for the session. | 2503 // WINDOW_UPDATE for the session. |
| 2497 if (flow_control_state_ < FLOW_CONTROL_STREAM_AND_SESSION) { | 2504 if (flow_control_state_ < FLOW_CONTROL_STREAM_AND_SESSION) { |
| 2498 LOG(WARNING) << "Received WINDOW_UPDATE for session when " | 2505 LOG(WARNING) << "Received WINDOW_UPDATE for session when " |
| 2499 << "session flow control is not turned on"; | 2506 << "session flow control is not turned on"; |
| 2500 // TODO(akalin): Record an error and close the session. | 2507 // TODO(akalin): Record an error and close the session. |
| 2501 return; | 2508 return; |
| 2502 } | 2509 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2708 return true; | 2715 return true; |
| 2709 } | 2716 } |
| 2710 | 2717 |
| 2711 void SpdySession::OnPushPromise(SpdyStreamId stream_id, | 2718 void SpdySession::OnPushPromise(SpdyStreamId stream_id, |
| 2712 SpdyStreamId promised_stream_id, | 2719 SpdyStreamId promised_stream_id, |
| 2713 const SpdyHeaderBlock& headers) { | 2720 const SpdyHeaderBlock& headers) { |
| 2714 CHECK(in_io_loop_); | 2721 CHECK(in_io_loop_); |
| 2715 | 2722 |
| 2716 if (net_log_.IsCapturing()) { | 2723 if (net_log_.IsCapturing()) { |
| 2717 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_PUSH_PROMISE, | 2724 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_PUSH_PROMISE, |
| 2718 base::Bind(&NetLogSpdyPushPromiseReceivedCallback, | 2725 base::Bind(NetLogSpdyPushPromiseReceivedCallback, |
| 2719 &headers, stream_id, promised_stream_id)); | 2726 &headers, stream_id, promised_stream_id)); |
| 2720 } | 2727 } |
| 2721 | 2728 |
| 2722 // Any priority will do. | 2729 // Any priority will do. |
| 2723 // TODO(baranovich): pass parent stream id priority? | 2730 // TODO(baranovich): pass parent stream id priority? |
| 2724 if (!TryCreatePushStream(promised_stream_id, stream_id, 0, headers)) | 2731 if (!TryCreatePushStream(promised_stream_id, stream_id, 0, headers)) |
| 2725 return; | 2732 return; |
| 2726 } | 2733 } |
| 2727 | 2734 |
| 2728 void SpdySession::SendStreamWindowUpdate(SpdyStreamId stream_id, | 2735 void SpdySession::SendStreamWindowUpdate(SpdyStreamId stream_id, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2802 | 2809 |
| 2803 SendSettings(server_settings_map); | 2810 SendSettings(server_settings_map); |
| 2804 } | 2811 } |
| 2805 } | 2812 } |
| 2806 | 2813 |
| 2807 | 2814 |
| 2808 void SpdySession::SendSettings(const SettingsMap& settings) { | 2815 void SpdySession::SendSettings(const SettingsMap& settings) { |
| 2809 const SpdyMajorVersion protocol_version = GetProtocolVersion(); | 2816 const SpdyMajorVersion protocol_version = GetProtocolVersion(); |
| 2810 net_log_.AddEvent( | 2817 net_log_.AddEvent( |
| 2811 NetLog::TYPE_HTTP2_SESSION_SEND_SETTINGS, | 2818 NetLog::TYPE_HTTP2_SESSION_SEND_SETTINGS, |
| 2812 base::Bind(&NetLogSpdySendSettingsCallback, &settings, protocol_version)); | 2819 base::Bind(NetLogSpdySendSettingsCallback, &settings, protocol_version)); |
| 2813 // Create the SETTINGS frame and send it. | 2820 // Create the SETTINGS frame and send it. |
| 2814 DCHECK(buffered_spdy_framer_.get()); | 2821 DCHECK(buffered_spdy_framer_.get()); |
| 2815 scoped_ptr<SpdyFrame> settings_frame( | 2822 scoped_ptr<SpdyFrame> settings_frame( |
| 2816 buffered_spdy_framer_->CreateSettings(settings)); | 2823 buffered_spdy_framer_->CreateSettings(settings)); |
| 2817 sent_settings_ = true; | 2824 sent_settings_ = true; |
| 2818 EnqueueSessionWrite(HIGHEST, SETTINGS, settings_frame.Pass()); | 2825 EnqueueSessionWrite(HIGHEST, SETTINGS, settings_frame.Pass()); |
| 2819 } | 2826 } |
| 2820 | 2827 |
| 2821 void SpdySession::HandleSetting(uint32 id, uint32 value) { | 2828 void SpdySession::HandleSetting(uint32 id, uint32 value) { |
| 2822 switch (id) { | 2829 switch (id) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2885 CHECK_GE(flow_control_state_, FLOW_CONTROL_STREAM); | 2892 CHECK_GE(flow_control_state_, FLOW_CONTROL_STREAM); |
| 2886 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); | 2893 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); |
| 2887 if (it != active_streams_.end()) { | 2894 if (it != active_streams_.end()) { |
| 2888 CHECK_EQ(it->second.stream->stream_id(), stream_id); | 2895 CHECK_EQ(it->second.stream->stream_id(), stream_id); |
| 2889 } else { | 2896 } else { |
| 2890 CHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 2897 CHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
| 2891 CHECK_EQ(stream_id, kSessionFlowControlStreamId); | 2898 CHECK_EQ(stream_id, kSessionFlowControlStreamId); |
| 2892 } | 2899 } |
| 2893 | 2900 |
| 2894 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_SENT_WINDOW_UPDATE_FRAME, | 2901 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_SENT_WINDOW_UPDATE_FRAME, |
| 2895 base::Bind(&NetLogSpdyWindowUpdateFrameCallback, stream_id, | 2902 base::Bind(NetLogSpdyWindowUpdateFrameCallback, stream_id, |
| 2896 delta_window_size)); | 2903 delta_window_size)); |
| 2897 | 2904 |
| 2898 DCHECK(buffered_spdy_framer_.get()); | 2905 DCHECK(buffered_spdy_framer_.get()); |
| 2899 scoped_ptr<SpdyFrame> window_update_frame( | 2906 scoped_ptr<SpdyFrame> window_update_frame( |
| 2900 buffered_spdy_framer_->CreateWindowUpdate(stream_id, delta_window_size)); | 2907 buffered_spdy_framer_->CreateWindowUpdate(stream_id, delta_window_size)); |
| 2901 EnqueueSessionWrite(priority, WINDOW_UPDATE, window_update_frame.Pass()); | 2908 EnqueueSessionWrite(priority, WINDOW_UPDATE, window_update_frame.Pass()); |
| 2902 } | 2909 } |
| 2903 | 2910 |
| 2904 void SpdySession::WritePingFrame(SpdyPingId unique_id, bool is_ack) { | 2911 void SpdySession::WritePingFrame(SpdyPingId unique_id, bool is_ack) { |
| 2905 DCHECK(buffered_spdy_framer_.get()); | 2912 DCHECK(buffered_spdy_framer_.get()); |
| 2906 scoped_ptr<SpdyFrame> ping_frame( | 2913 scoped_ptr<SpdyFrame> ping_frame( |
| 2907 buffered_spdy_framer_->CreatePingFrame(unique_id, is_ack)); | 2914 buffered_spdy_framer_->CreatePingFrame(unique_id, is_ack)); |
| 2908 EnqueueSessionWrite(HIGHEST, PING, ping_frame.Pass()); | 2915 EnqueueSessionWrite(HIGHEST, PING, ping_frame.Pass()); |
| 2909 | 2916 |
| 2910 if (net_log().IsCapturing()) { | 2917 if (net_log().IsCapturing()) { |
| 2911 net_log().AddEvent( | 2918 net_log().AddEvent( |
| 2912 NetLog::TYPE_HTTP2_SESSION_PING, | 2919 NetLog::TYPE_HTTP2_SESSION_PING, |
| 2913 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "sent")); | 2920 base::Bind(NetLogSpdyPingCallback, unique_id, is_ack, "sent")); |
| 2914 } | 2921 } |
| 2915 if (!is_ack) { | 2922 if (!is_ack) { |
| 2916 next_ping_id_ += 2; | 2923 next_ping_id_ += 2; |
| 2917 ++pings_in_flight_; | 2924 ++pings_in_flight_; |
| 2918 PlanToCheckPingStatus(); | 2925 PlanToCheckPingStatus(); |
| 2919 last_ping_sent_time_ = time_func_(); | 2926 last_ping_sent_time_ = time_func_(); |
| 2920 } | 2927 } |
| 2921 } | 2928 } |
| 2922 | 2929 |
| 2923 void SpdySession::PlanToCheckPingStatus() { | 2930 void SpdySession::PlanToCheckPingStatus() { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3112 "Received WINDOW_UPDATE [delta: " + | 3119 "Received WINDOW_UPDATE [delta: " + |
| 3113 base::IntToString(delta_window_size) + | 3120 base::IntToString(delta_window_size) + |
| 3114 "] for session overflows session_send_window_size_ [current: " + | 3121 "] for session overflows session_send_window_size_ [current: " + |
| 3115 base::IntToString(session_send_window_size_) + "]"); | 3122 base::IntToString(session_send_window_size_) + "]"); |
| 3116 return; | 3123 return; |
| 3117 } | 3124 } |
| 3118 | 3125 |
| 3119 session_send_window_size_ += delta_window_size; | 3126 session_send_window_size_ += delta_window_size; |
| 3120 | 3127 |
| 3121 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_UPDATE_SEND_WINDOW, | 3128 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_UPDATE_SEND_WINDOW, |
| 3122 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3129 base::Bind(NetLogSpdySessionWindowUpdateCallback, |
| 3123 delta_window_size, session_send_window_size_)); | 3130 delta_window_size, session_send_window_size_)); |
| 3124 | 3131 |
| 3125 DCHECK(!IsSendStalled()); | 3132 DCHECK(!IsSendStalled()); |
| 3126 ResumeSendStalledStreams(); | 3133 ResumeSendStalledStreams(); |
| 3127 } | 3134 } |
| 3128 | 3135 |
| 3129 void SpdySession::DecreaseSendWindowSize(int32 delta_window_size) { | 3136 void SpdySession::DecreaseSendWindowSize(int32 delta_window_size) { |
| 3130 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3137 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
| 3131 | 3138 |
| 3132 // We only call this method when sending a frame. Therefore, | 3139 // We only call this method when sending a frame. Therefore, |
| 3133 // |delta_window_size| should be within the valid frame size range. | 3140 // |delta_window_size| should be within the valid frame size range. |
| 3134 DCHECK_GE(delta_window_size, 1); | 3141 DCHECK_GE(delta_window_size, 1); |
| 3135 DCHECK_LE(delta_window_size, kMaxSpdyFrameChunkSize); | 3142 DCHECK_LE(delta_window_size, kMaxSpdyFrameChunkSize); |
| 3136 | 3143 |
| 3137 // |send_window_size_| should have been at least |delta_window_size| for | 3144 // |send_window_size_| should have been at least |delta_window_size| for |
| 3138 // this call to happen. | 3145 // this call to happen. |
| 3139 DCHECK_GE(session_send_window_size_, delta_window_size); | 3146 DCHECK_GE(session_send_window_size_, delta_window_size); |
| 3140 | 3147 |
| 3141 session_send_window_size_ -= delta_window_size; | 3148 session_send_window_size_ -= delta_window_size; |
| 3142 | 3149 |
| 3143 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_UPDATE_SEND_WINDOW, | 3150 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_UPDATE_SEND_WINDOW, |
| 3144 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3151 base::Bind(NetLogSpdySessionWindowUpdateCallback, |
| 3145 -delta_window_size, session_send_window_size_)); | 3152 -delta_window_size, session_send_window_size_)); |
| 3146 } | 3153 } |
| 3147 | 3154 |
| 3148 void SpdySession::OnReadBufferConsumed( | 3155 void SpdySession::OnReadBufferConsumed( |
| 3149 size_t consume_size, | 3156 size_t consume_size, |
| 3150 SpdyBuffer::ConsumeSource consume_source) { | 3157 SpdyBuffer::ConsumeSource consume_source) { |
| 3151 // We can be called with |in_io_loop_| set if a read SpdyBuffer is | 3158 // We can be called with |in_io_loop_| set if a read SpdyBuffer is |
| 3152 // deleted (e.g., discarded by a SpdyReadQueue). | 3159 // deleted (e.g., discarded by a SpdyReadQueue). |
| 3153 | 3160 |
| 3154 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3161 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
| 3155 DCHECK_GE(consume_size, 1u); | 3162 DCHECK_GE(consume_size, 1u); |
| 3156 DCHECK_LE(consume_size, static_cast<size_t>(kint32max)); | 3163 DCHECK_LE(consume_size, static_cast<size_t>(kint32max)); |
| 3157 | 3164 |
| 3158 IncreaseRecvWindowSize(static_cast<int32>(consume_size)); | 3165 IncreaseRecvWindowSize(static_cast<int32>(consume_size)); |
| 3159 } | 3166 } |
| 3160 | 3167 |
| 3161 void SpdySession::IncreaseRecvWindowSize(int32 delta_window_size) { | 3168 void SpdySession::IncreaseRecvWindowSize(int32 delta_window_size) { |
| 3162 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3169 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
| 3163 DCHECK_GE(session_unacked_recv_window_bytes_, 0); | 3170 DCHECK_GE(session_unacked_recv_window_bytes_, 0); |
| 3164 DCHECK_GE(session_recv_window_size_, session_unacked_recv_window_bytes_); | 3171 DCHECK_GE(session_recv_window_size_, session_unacked_recv_window_bytes_); |
| 3165 DCHECK_GE(delta_window_size, 1); | 3172 DCHECK_GE(delta_window_size, 1); |
| 3166 // Check for overflow. | 3173 // Check for overflow. |
| 3167 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); | 3174 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); |
| 3168 | 3175 |
| 3169 session_recv_window_size_ += delta_window_size; | 3176 session_recv_window_size_ += delta_window_size; |
| 3170 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, | 3177 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, |
| 3171 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3178 base::Bind(NetLogSpdySessionWindowUpdateCallback, |
| 3172 delta_window_size, session_recv_window_size_)); | 3179 delta_window_size, session_recv_window_size_)); |
| 3173 | 3180 |
| 3174 session_unacked_recv_window_bytes_ += delta_window_size; | 3181 session_unacked_recv_window_bytes_ += delta_window_size; |
| 3175 if (session_unacked_recv_window_bytes_ > session_max_recv_window_size_ / 2) { | 3182 if (session_unacked_recv_window_bytes_ > session_max_recv_window_size_ / 2) { |
| 3176 SendWindowUpdateFrame(kSessionFlowControlStreamId, | 3183 SendWindowUpdateFrame(kSessionFlowControlStreamId, |
| 3177 session_unacked_recv_window_bytes_, | 3184 session_unacked_recv_window_bytes_, |
| 3178 HIGHEST); | 3185 HIGHEST); |
| 3179 session_unacked_recv_window_bytes_ = 0; | 3186 session_unacked_recv_window_bytes_ = 0; |
| 3180 } | 3187 } |
| 3181 } | 3188 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3195 DoDrainSession( | 3202 DoDrainSession( |
| 3196 ERR_SPDY_FLOW_CONTROL_ERROR, | 3203 ERR_SPDY_FLOW_CONTROL_ERROR, |
| 3197 "delta_window_size is " + base::IntToString(delta_window_size) + | 3204 "delta_window_size is " + base::IntToString(delta_window_size) + |
| 3198 " in DecreaseRecvWindowSize, which is larger than the receive " + | 3205 " in DecreaseRecvWindowSize, which is larger than the receive " + |
| 3199 "window size of " + base::IntToString(session_recv_window_size_)); | 3206 "window size of " + base::IntToString(session_recv_window_size_)); |
| 3200 return; | 3207 return; |
| 3201 } | 3208 } |
| 3202 | 3209 |
| 3203 session_recv_window_size_ -= delta_window_size; | 3210 session_recv_window_size_ -= delta_window_size; |
| 3204 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_UPDATE_RECV_WINDOW, | 3211 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_UPDATE_RECV_WINDOW, |
| 3205 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3212 base::Bind(NetLogSpdySessionWindowUpdateCallback, |
| 3206 -delta_window_size, session_recv_window_size_)); | 3213 -delta_window_size, session_recv_window_size_)); |
| 3207 } | 3214 } |
| 3208 | 3215 |
| 3209 void SpdySession::QueueSendStalledStream(const SpdyStream& stream) { | 3216 void SpdySession::QueueSendStalledStream(const SpdyStream& stream) { |
| 3210 DCHECK(stream.send_stalled_by_flow_control()); | 3217 DCHECK(stream.send_stalled_by_flow_control()); |
| 3211 RequestPriority priority = stream.priority(); | 3218 RequestPriority priority = stream.priority(); |
| 3212 CHECK_GE(priority, MINIMUM_PRIORITY); | 3219 CHECK_GE(priority, MINIMUM_PRIORITY); |
| 3213 CHECK_LE(priority, MAXIMUM_PRIORITY); | 3220 CHECK_LE(priority, MAXIMUM_PRIORITY); |
| 3214 stream_send_unstall_queue_[priority].push_back(stream.stream_id()); | 3221 stream_send_unstall_queue_[priority].push_back(stream.stream_id()); |
| 3215 } | 3222 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3250 if (!queue->empty()) { | 3257 if (!queue->empty()) { |
| 3251 SpdyStreamId stream_id = queue->front(); | 3258 SpdyStreamId stream_id = queue->front(); |
| 3252 queue->pop_front(); | 3259 queue->pop_front(); |
| 3253 return stream_id; | 3260 return stream_id; |
| 3254 } | 3261 } |
| 3255 } | 3262 } |
| 3256 return 0; | 3263 return 0; |
| 3257 } | 3264 } |
| 3258 | 3265 |
| 3259 } // namespace net | 3266 } // namespace net |
| OLD | NEW |