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

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

Issue 11415219: Move a number of static variables SPDY to HttpNetworkSession::Params. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar cleanup Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 NetLog::LogLevel /* log_level */) { 170 NetLog::LogLevel /* log_level */) {
171 DictionaryValue* dict = new DictionaryValue(); 171 DictionaryValue* dict = new DictionaryValue();
172 dict->SetInteger("last_accepted_stream_id", 172 dict->SetInteger("last_accepted_stream_id",
173 static_cast<int>(last_stream_id)); 173 static_cast<int>(last_stream_id));
174 dict->SetInteger("active_streams", active_streams); 174 dict->SetInteger("active_streams", active_streams);
175 dict->SetInteger("unclaimed_streams", unclaimed_streams); 175 dict->SetInteger("unclaimed_streams", unclaimed_streams);
176 dict->SetInteger("status", static_cast<int>(status)); 176 dict->SetInteger("status", static_cast<int>(status));
177 return dict; 177 return dict;
178 } 178 }
179 179
180 NextProto g_default_protocol = kProtoUnknown;
181 // Maximum number of concurrent streams we will create, unless the server 180 // Maximum number of concurrent streams we will create, unless the server
182 // sends a SETTINGS frame with a different value. 181 // sends a SETTINGS frame with a different value.
183 size_t g_init_max_concurrent_streams = 100; 182 const size_t kInitialMaxConcurrentStreams = 100;
184 // The maximum number of concurrent streams we will ever create. Even if 183 // The maximum number of concurrent streams we will ever create. Even if
185 // the server permits more, we will never exceed this limit. 184 // the server permits more, we will never exceed this limit.
186 size_t g_max_concurrent_stream_limit = 256; 185 const size_t kMaxConcurrentStreamLimit = 256;
187 size_t g_default_initial_rcv_window_size = 10 * 1024 * 1024; // 10MB 186 const size_t kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB
188 bool g_enable_ping_based_connection_checking = true;
189 bool g_enable_credential_frames = false;
190
191 typedef base::TimeTicks (*ExternalTimeFunc)(void);
192
193 static ExternalTimeFunc g_time_func = base::TimeTicks::Now;
194 187
195 } // namespace 188 } // namespace
196 189
197 // static 190 // static
198 void SpdySession::SpdyIOBufferProducer::ActivateStream( 191 void SpdySession::SpdyIOBufferProducer::ActivateStream(
199 SpdySession* spdy_session, 192 SpdySession* spdy_session,
200 SpdyStream* spdy_stream) { 193 SpdyStream* spdy_stream) {
201 spdy_session->ActivateStream(spdy_stream); 194 spdy_session->ActivateStream(spdy_stream);
202 } 195 }
203 196
204 // static 197 // static
205 SpdyIOBuffer* SpdySession::SpdyIOBufferProducer::CreateIOBuffer( 198 SpdyIOBuffer* SpdySession::SpdyIOBufferProducer::CreateIOBuffer(
206 SpdyFrame* frame, 199 SpdyFrame* frame,
207 RequestPriority priority, 200 RequestPriority priority,
208 SpdyStream* stream) { 201 SpdyStream* stream) {
209 size_t size = frame->length() + SpdyFrame::kHeaderSize; 202 size_t size = frame->length() + SpdyFrame::kHeaderSize;
210 DCHECK_GT(size, 0u); 203 DCHECK_GT(size, 0u);
211 204
212 // TODO(mbelshe): We have too much copying of data here. 205 // TODO(mbelshe): We have too much copying of data here.
213 IOBufferWithSize* buffer = new IOBufferWithSize(size); 206 IOBufferWithSize* buffer = new IOBufferWithSize(size);
214 memcpy(buffer->data(), frame->data(), size); 207 memcpy(buffer->data(), frame->data(), size);
215 208
216 return new SpdyIOBuffer(buffer, size, priority, stream); 209 return new SpdyIOBuffer(buffer, size, priority, stream);
217 } 210 }
218 211
219 // static
220 void SpdySession::set_default_protocol(NextProto default_protocol) {
221 g_default_protocol = default_protocol;
222 }
223
224 // static
225 void SpdySession::set_max_concurrent_streams(size_t value) {
226 g_max_concurrent_stream_limit = value;
227 }
228
229 // static
230 void SpdySession::set_enable_ping_based_connection_checking(bool enable) {
231 g_enable_ping_based_connection_checking = enable;
232 }
233
234 // static
235 void SpdySession::set_enable_credential_frames(bool enable) {
236 g_enable_credential_frames = enable;
237 }
238
239
240 // static
241 void SpdySession::set_init_max_concurrent_streams(size_t value) {
242 g_init_max_concurrent_streams =
243 std::min(value, g_max_concurrent_stream_limit);
244 }
245
246 // static
247 void SpdySession::set_default_initial_recv_window_size(size_t value) {
248 g_default_initial_rcv_window_size = value;
249 }
250
251 // static
252 void SpdySession::ResetStaticSettingsToInit() {
253 // WARNING: These must match the initializers above.
254 g_default_protocol = kProtoUnknown;
255 g_init_max_concurrent_streams = 100;
256 g_max_concurrent_stream_limit = 256;
257 g_default_initial_rcv_window_size = kSpdyStreamInitialWindowSize;
258 g_enable_ping_based_connection_checking = true;
259 g_enable_credential_frames = false;
260 g_time_func = base::TimeTicks::Now;
261 }
262
263 // Outside of tests, g_time_func will always be base::TimeTicks::Now.
264 // When performing linker optimization for the main executable, the compiler
265 // should be able to see that set_time_func() is an uncalled function, that
266 // the static .cc variable never changes, and thus that the extra pointer
267 // indirection can be removed.
268
269
270
271 SpdySession::TimeFunc SpdySession::set_time_func(
272 SpdySession::TimeFunc time_func) {
273 SpdySession::TimeFunc old_time_func =
274 static_cast<SpdySession::TimeFunc>(g_time_func);
275 g_time_func = static_cast<ExternalTimeFunc>(time_func);
276 return old_time_func;
277 }
278
279 SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, 212 SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
280 SpdySessionPool* spdy_session_pool, 213 SpdySessionPool* spdy_session_pool,
281 HttpServerProperties* http_server_properties, 214 HttpServerProperties* http_server_properties,
282 bool verify_domain_authentication, 215 bool verify_domain_authentication,
283 bool enable_sending_initial_settings, 216 bool enable_sending_initial_settings,
217 bool enable_credential_frames,
218 bool enable_compression,
219 bool enable_ping_based_connection_checking,
220 NextProto default_protocol,
221 size_t initial_recv_window_size,
222 size_t initial_max_concurrent_streams,
223 size_t max_concurrent_streams_limit,
224 TimeFunc time_func,
284 const HostPortPair& trusted_spdy_proxy, 225 const HostPortPair& trusted_spdy_proxy,
285 NetLog* net_log) 226 NetLog* net_log)
286 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 227 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
287 host_port_proxy_pair_(host_port_proxy_pair), 228 host_port_proxy_pair_(host_port_proxy_pair),
288 spdy_session_pool_(spdy_session_pool), 229 spdy_session_pool_(spdy_session_pool),
289 http_server_properties_(http_server_properties), 230 http_server_properties_(http_server_properties),
290 connection_(new ClientSocketHandle), 231 connection_(new ClientSocketHandle),
291 read_buffer_(new IOBuffer(kReadBufferSize)), 232 read_buffer_(new IOBuffer(kReadBufferSize)),
292 read_pending_(false), 233 read_pending_(false),
293 stream_hi_water_mark_(1), // Always start at 1 for the first stream id. 234 stream_hi_water_mark_(1), // Always start at 1 for the first stream id.
294 write_pending_(false), 235 write_pending_(false),
295 delayed_write_pending_(false), 236 delayed_write_pending_(false),
296 is_secure_(false), 237 is_secure_(false),
297 certificate_error_code_(OK), 238 certificate_error_code_(OK),
298 error_(OK), 239 error_(OK),
299 state_(IDLE), 240 state_(IDLE),
300 max_concurrent_streams_(g_init_max_concurrent_streams), 241 max_concurrent_streams_(initial_max_concurrent_streams == 0 ?
242 kInitialMaxConcurrentStreams :
243 initial_max_concurrent_streams),
244 max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 ?
245 kMaxConcurrentStreamLimit :
246 max_concurrent_streams_limit),
301 streams_initiated_count_(0), 247 streams_initiated_count_(0),
302 streams_pushed_count_(0), 248 streams_pushed_count_(0),
303 streams_pushed_and_claimed_count_(0), 249 streams_pushed_and_claimed_count_(0),
304 streams_abandoned_count_(0), 250 streams_abandoned_count_(0),
305 bytes_received_(0), 251 bytes_received_(0),
306 sent_settings_(false), 252 sent_settings_(false),
307 received_settings_(false), 253 received_settings_(false),
308 stalled_streams_(0), 254 stalled_streams_(0),
309 pings_in_flight_(0), 255 pings_in_flight_(0),
310 next_ping_id_(1), 256 next_ping_id_(1),
311 last_activity_time_(base::TimeTicks::Now()), 257 last_activity_time_(base::TimeTicks::Now()),
312 check_ping_status_pending_(false), 258 check_ping_status_pending_(false),
313 flow_control_(false), 259 flow_control_(false),
314 initial_send_window_size_(kSpdyStreamInitialWindowSize), 260 initial_send_window_size_(kSpdyStreamInitialWindowSize),
315 initial_recv_window_size_(g_default_initial_rcv_window_size), 261 initial_recv_window_size_(initial_recv_window_size == 0 ?
262 kDefaultInitialRecvWindowSize :
263 initial_recv_window_size),
316 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), 264 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)),
317 verify_domain_authentication_(verify_domain_authentication), 265 verify_domain_authentication_(verify_domain_authentication),
318 enable_sending_initial_settings_(enable_sending_initial_settings), 266 enable_sending_initial_settings_(enable_sending_initial_settings),
267 enable_credential_frames_(enable_credential_frames),
268 enable_compression_(enable_compression),
269 enable_ping_based_connection_checking_(
270 enable_ping_based_connection_checking),
271 default_protocol_(default_protocol),
319 credential_state_(SpdyCredentialState::kDefaultNumSlots), 272 credential_state_(SpdyCredentialState::kDefaultNumSlots),
320 connection_at_risk_of_loss_time_( 273 connection_at_risk_of_loss_time_(
321 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), 274 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)),
322 hung_interval_( 275 hung_interval_(
323 base::TimeDelta::FromSeconds(kHungIntervalSeconds)), 276 base::TimeDelta::FromSeconds(kHungIntervalSeconds)),
324 trusted_spdy_proxy_(trusted_spdy_proxy) { 277 trusted_spdy_proxy_(trusted_spdy_proxy),
278 time_func_(time_func) {
325 DCHECK(HttpStreamFactory::spdy_enabled()); 279 DCHECK(HttpStreamFactory::spdy_enabled());
326 net_log_.BeginEvent( 280 net_log_.BeginEvent(
327 NetLog::TYPE_SPDY_SESSION, 281 NetLog::TYPE_SPDY_SESSION,
328 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair_)); 282 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair_));
329 next_unclaimed_push_stream_sweep_time_ = g_time_func() + 283 next_unclaimed_push_stream_sweep_time_ = time_func_() +
330 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); 284 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
331 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. 285 // TODO(mbelshe): consider randomization of the stream_hi_water_mark.
332 } 286 }
333 287
334 SpdySession::PendingCreateStream::PendingCreateStream( 288 SpdySession::PendingCreateStream::PendingCreateStream(
335 const GURL& url, RequestPriority priority, 289 const GURL& url, RequestPriority priority,
336 scoped_refptr<SpdyStream>* spdy_stream, 290 scoped_refptr<SpdyStream>* spdy_stream,
337 const BoundNetLog& stream_net_log, 291 const BoundNetLog& stream_net_log,
338 const CompletionCallback& callback) 292 const CompletionCallback& callback)
339 : url(&url), 293 : url(&url),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 bool is_secure, 336 bool is_secure,
383 int certificate_error_code) { 337 int certificate_error_code) {
384 base::StatsCounter spdy_sessions("spdy.sessions"); 338 base::StatsCounter spdy_sessions("spdy.sessions");
385 spdy_sessions.Increment(); 339 spdy_sessions.Increment();
386 340
387 state_ = CONNECTED; 341 state_ = CONNECTED;
388 connection_.reset(connection); 342 connection_.reset(connection);
389 is_secure_ = is_secure; 343 is_secure_ = is_secure;
390 certificate_error_code_ = certificate_error_code; 344 certificate_error_code_ = certificate_error_code;
391 345
392 NextProto protocol = g_default_protocol; 346 NextProto protocol = default_protocol_;
393 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol(); 347 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol();
394 if (protocol_negotiated != kProtoUnknown) { 348 if (protocol_negotiated != kProtoUnknown) {
395 protocol = protocol_negotiated; 349 protocol = protocol_negotiated;
396 } 350 }
397 351
398 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 352 SSLClientSocket* ssl_socket = GetSSLClientSocket();
399 if (ssl_socket && ssl_socket->WasChannelIDSent()) { 353 if (ssl_socket && ssl_socket->WasChannelIDSent()) {
400 // According to the SPDY spec, the credential associated with the TLS 354 // According to the SPDY spec, the credential associated with the TLS
401 // connection is stored in slot[1]. 355 // connection is stored in slot[1].
402 credential_state_.SetHasCredential(GURL("https://" + 356 credential_state_.SetHasCredential(GURL("https://" +
403 host_port_pair().ToString())); 357 host_port_pair().ToString()));
404 } 358 }
405 359
406 DCHECK(protocol >= kProtoSPDY2); 360 DCHECK(protocol >= kProtoSPDY2);
407 DCHECK(protocol <= kProtoSPDY3); 361 DCHECK(protocol <= kProtoSPDY3);
408 int version = (protocol == kProtoSPDY3) ? 3 : 2; 362 int version = (protocol == kProtoSPDY3) ? 3 : 2;
409 flow_control_ = (protocol >= kProtoSPDY3); 363 flow_control_ = (protocol >= kProtoSPDY3);
410 364
411 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); 365 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version,
366 enable_compression_));
412 buffered_spdy_framer_->set_visitor(this); 367 buffered_spdy_framer_->set_visitor(this);
413 SendInitialSettings(); 368 SendInitialSettings();
414 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol, kProtoMaximumVersion); 369 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol, kProtoMaximumVersion);
415 370
416 // Write out any data that we might have to send, such as the settings frame. 371 // Write out any data that we might have to send, such as the settings frame.
417 WriteSocketLater(); 372 WriteSocketLater();
418 net::Error error = ReadSocket(); 373 net::Error error = ReadSocket();
419 if (error == ERR_IO_PENDING) 374 if (error == ERR_IO_PENDING)
420 return OK; 375 return OK;
421 return error; 376 return error;
422 } 377 }
423 378
424 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 379 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
425 if (!verify_domain_authentication_) 380 if (!verify_domain_authentication_)
426 return true; 381 return true;
427 382
428 if (state_ != CONNECTED) 383 if (state_ != CONNECTED)
429 return false; 384 return false;
430 385
431 SSLInfo ssl_info; 386 SSLInfo ssl_info;
432 bool was_npn_negotiated; 387 bool was_npn_negotiated;
433 NextProto protocol_negotiated = kProtoUnknown; 388 NextProto protocol_negotiated = kProtoUnknown;
434 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) 389 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated))
435 return true; // This is not a secure session, so all domains are okay. 390 return true; // This is not a secure session, so all domains are okay.
436 391
437 return !ssl_info.client_cert_sent && 392 return !ssl_info.client_cert_sent &&
438 (g_enable_credential_frames || !ssl_info.channel_id_sent || 393 (enable_credential_frames_ || !ssl_info.channel_id_sent ||
439 ServerBoundCertService::GetDomainForHost(domain) == 394 ServerBoundCertService::GetDomainForHost(domain) ==
440 ServerBoundCertService::GetDomainForHost( 395 ServerBoundCertService::GetDomainForHost(
441 host_port_proxy_pair_.first.host())) && 396 host_port_proxy_pair_.first.host())) &&
442 ssl_info.cert->VerifyNameMatch(domain); 397 ssl_info.cert->VerifyNameMatch(domain);
443 } 398 }
444 399
445 void SpdySession::SetStreamHasWriteAvailable(SpdyStream* stream, 400 void SpdySession::SetStreamHasWriteAvailable(SpdyStream* stream,
446 SpdyIOBufferProducer* producer) { 401 SpdyIOBufferProducer* producer) {
447 write_queue_.push(producer); 402 write_queue_.push(producer);
448 stream_producers_[producer] = stream; 403 stream_producers_[producer] = stream;
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 scoped_refptr<SpdyStream> stream(new SpdyStream(this, true, net_log_)); 1419 scoped_refptr<SpdyStream> stream(new SpdyStream(this, true, net_log_));
1465 stream->set_stream_id(stream_id); 1420 stream->set_stream_id(stream_id);
1466 1421
1467 stream->set_path(gurl.PathForRequest()); 1422 stream->set_path(gurl.PathForRequest());
1468 stream->set_send_window_size(initial_send_window_size_); 1423 stream->set_send_window_size(initial_send_window_size_);
1469 stream->set_recv_window_size(initial_recv_window_size_); 1424 stream->set_recv_window_size(initial_recv_window_size_);
1470 1425
1471 DeleteExpiredPushedStreams(); 1426 DeleteExpiredPushedStreams();
1472 unclaimed_pushed_streams_[url] = 1427 unclaimed_pushed_streams_[url] =
1473 std::pair<scoped_refptr<SpdyStream>, base::TimeTicks> ( 1428 std::pair<scoped_refptr<SpdyStream>, base::TimeTicks> (
1474 stream, g_time_func()); 1429 stream, time_func_());
1475 1430
1476 1431
1477 ActivateStream(stream); 1432 ActivateStream(stream);
1478 stream->set_response_received(); 1433 stream->set_response_received();
1479 1434
1480 // Parse the headers. 1435 // Parse the headers.
1481 if (!Respond(headers, stream)) 1436 if (!Respond(headers, stream))
1482 return; 1437 return;
1483 1438
1484 base::StatsCounter push_requests("spdy.pushed_streams"); 1439 base::StatsCounter push_requests("spdy.pushed_streams");
1485 push_requests.Increment(); 1440 push_requests.Increment();
1486 } 1441 }
1487 1442
1488 void SpdySession::DeleteExpiredPushedStreams() { 1443 void SpdySession::DeleteExpiredPushedStreams() {
1489 if (unclaimed_pushed_streams_.empty()) 1444 if (unclaimed_pushed_streams_.empty())
1490 return; 1445 return;
1491 1446
1492 // Check that adequate time has elapsed since the last sweep. 1447 // Check that adequate time has elapsed since the last sweep.
1493 if (g_time_func() < next_unclaimed_push_stream_sweep_time_) 1448 if (time_func_() < next_unclaimed_push_stream_sweep_time_)
1494 return; 1449 return;
1495 1450
1496 // Delete old streams. 1451 // Delete old streams.
1497 base::TimeTicks minimum_freshness = g_time_func() - 1452 base::TimeTicks minimum_freshness = time_func_() -
1498 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); 1453 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
1499 PushedStreamMap::iterator it; 1454 PushedStreamMap::iterator it;
1500 for (it = unclaimed_pushed_streams_.begin(); 1455 for (it = unclaimed_pushed_streams_.begin();
1501 it != unclaimed_pushed_streams_.end(); ) { 1456 it != unclaimed_pushed_streams_.end(); ) {
1502 const scoped_refptr<SpdyStream>& stream = it->second.first; 1457 const scoped_refptr<SpdyStream>& stream = it->second.first;
1503 base::TimeTicks creation_time = it->second.second; 1458 base::TimeTicks creation_time = it->second.second;
1504 // DeleteStream() will invalidate the current iterator, so move to next. 1459 // DeleteStream() will invalidate the current iterator, so move to next.
1505 ++it; 1460 ++it;
1506 if (minimum_freshness > creation_time) { 1461 if (minimum_freshness > creation_time) {
1507 DeleteStream(stream->stream_id(), ERR_INVALID_SPDY_STREAM); 1462 DeleteStream(stream->stream_id(), ERR_INVALID_SPDY_STREAM);
1508 base::StatsCounter abandoned_push_streams( 1463 base::StatsCounter abandoned_push_streams(
1509 "spdy.abandoned_push_streams"); 1464 "spdy.abandoned_push_streams");
1510 base::StatsCounter abandoned_streams("spdy.abandoned_streams"); 1465 base::StatsCounter abandoned_streams("spdy.abandoned_streams");
1511 abandoned_push_streams.Increment(); 1466 abandoned_push_streams.Increment();
1512 abandoned_streams.Increment(); 1467 abandoned_streams.Increment();
1513 streams_abandoned_count_++; 1468 streams_abandoned_count_++;
1514 } 1469 }
1515 } 1470 }
1516 next_unclaimed_push_stream_sweep_time_ = g_time_func() + 1471 next_unclaimed_push_stream_sweep_time_ = time_func_() +
1517 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); 1472 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
1518 } 1473 }
1519 1474
1520 void SpdySession::OnSynReply(SpdyStreamId stream_id, 1475 void SpdySession::OnSynReply(SpdyStreamId stream_id,
1521 bool fin, 1476 bool fin,
1522 const SpdyHeaderBlock& headers) { 1477 const SpdyHeaderBlock& headers) {
1523 if (net_log().IsLoggingAllEvents()) { 1478 if (net_log().IsLoggingAllEvents()) {
1524 net_log().AddEvent( 1479 net_log().AddEvent(
1525 NetLog::TYPE_SPDY_SESSION_SYN_REPLY, 1480 NetLog::TYPE_SPDY_SESSION_SYN_REPLY,
1526 base::Bind(&NetLogSpdySynCallback, 1481 base::Bind(&NetLogSpdySynCallback,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 scoped_ptr<SpdySettingsControlFrame> settings_frame( 1740 scoped_ptr<SpdySettingsControlFrame> settings_frame(
1786 buffered_spdy_framer_->CreateSettings(settings)); 1741 buffered_spdy_framer_->CreateSettings(settings));
1787 sent_settings_ = true; 1742 sent_settings_ = true;
1788 QueueFrame(settings_frame.release(), HIGHEST); 1743 QueueFrame(settings_frame.release(), HIGHEST);
1789 } 1744 }
1790 1745
1791 void SpdySession::HandleSetting(uint32 id, uint32 value) { 1746 void SpdySession::HandleSetting(uint32 id, uint32 value) {
1792 switch (id) { 1747 switch (id) {
1793 case SETTINGS_MAX_CONCURRENT_STREAMS: 1748 case SETTINGS_MAX_CONCURRENT_STREAMS:
1794 max_concurrent_streams_ = std::min(static_cast<size_t>(value), 1749 max_concurrent_streams_ = std::min(static_cast<size_t>(value),
1795 g_max_concurrent_stream_limit); 1750 kMaxConcurrentStreamLimit);
1796 ProcessPendingCreateStreams(); 1751 ProcessPendingCreateStreams();
1797 break; 1752 break;
1798 case SETTINGS_INITIAL_WINDOW_SIZE: 1753 case SETTINGS_INITIAL_WINDOW_SIZE:
1799 if (static_cast<int32>(value) < 0) { 1754 if (static_cast<int32>(value) < 0) {
1800 net_log().AddEvent( 1755 net_log().AddEvent(
1801 NetLog::TYPE_SPDY_SESSION_NEGATIVE_INITIAL_WINDOW_SIZE, 1756 NetLog::TYPE_SPDY_SESSION_NEGATIVE_INITIAL_WINDOW_SIZE,
1802 NetLog::IntegerCallback("initial_window_size", value)); 1757 NetLog::IntegerCallback("initial_window_size", value));
1803 } else { 1758 } else {
1804 // SETTINGS_INITIAL_WINDOW_SIZE updates initial_send_window_size_ only. 1759 // SETTINGS_INITIAL_WINDOW_SIZE updates initial_send_window_size_ only.
1805 int32 delta_window_size = value - initial_send_window_size_; 1760 int32 delta_window_size = value - initial_send_window_size_;
(...skipping 16 matching lines...) Expand all
1822 } 1777 }
1823 1778
1824 CreatedStreamSet::iterator i; 1779 CreatedStreamSet::iterator i;
1825 for (i = created_streams_.begin(); i != created_streams_.end(); i++) { 1780 for (i = created_streams_.begin(); i != created_streams_.end(); i++) {
1826 const scoped_refptr<SpdyStream>& stream = *i; 1781 const scoped_refptr<SpdyStream>& stream = *i;
1827 stream->AdjustSendWindowSize(delta_window_size); 1782 stream->AdjustSendWindowSize(delta_window_size);
1828 } 1783 }
1829 } 1784 }
1830 1785
1831 void SpdySession::SendPrefacePingIfNoneInFlight() { 1786 void SpdySession::SendPrefacePingIfNoneInFlight() {
1832 if (pings_in_flight_ || !g_enable_ping_based_connection_checking) 1787 if (pings_in_flight_ || !enable_ping_based_connection_checking_)
1833 return; 1788 return;
1834 1789
1835 base::TimeTicks now = base::TimeTicks::Now(); 1790 base::TimeTicks now = base::TimeTicks::Now();
1836 // If there is no activity in the session, then send a preface-PING. 1791 // If there is no activity in the session, then send a preface-PING.
1837 if ((now - last_activity_time_) > connection_at_risk_of_loss_time_) 1792 if ((now - last_activity_time_) > connection_at_risk_of_loss_time_)
1838 SendPrefacePing(); 1793 SendPrefacePing();
1839 } 1794 }
1840 1795
1841 void SpdySession::SendPrefacePing() { 1796 void SpdySession::SendPrefacePing() {
1842 WritePingFrame(next_ping_id_); 1797 WritePingFrame(next_ping_id_);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1957 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
2003 if (!is_secure_) 1958 if (!is_secure_)
2004 return NULL; 1959 return NULL;
2005 SSLClientSocket* ssl_socket = 1960 SSLClientSocket* ssl_socket =
2006 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1961 reinterpret_cast<SSLClientSocket*>(connection_->socket());
2007 DCHECK(ssl_socket); 1962 DCHECK(ssl_socket);
2008 return ssl_socket; 1963 return ssl_socket;
2009 } 1964 }
2010 1965
2011 } // namespace net 1966 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698