| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 bytes_received_(0), | 275 bytes_received_(0), |
| 276 sent_settings_(false), | 276 sent_settings_(false), |
| 277 received_settings_(false), | 277 received_settings_(false), |
| 278 stalled_streams_(0), | 278 stalled_streams_(0), |
| 279 pings_in_flight_(0), | 279 pings_in_flight_(0), |
| 280 next_ping_id_(1), | 280 next_ping_id_(1), |
| 281 received_data_time_(base::TimeTicks::Now()), | 281 received_data_time_(base::TimeTicks::Now()), |
| 282 trailing_ping_pending_(false), | 282 trailing_ping_pending_(false), |
| 283 check_ping_status_pending_(false), | 283 check_ping_status_pending_(false), |
| 284 need_to_send_ping_(false), | 284 need_to_send_ping_(false), |
| 285 flow_control_(use_flow_control_), |
| 285 initial_send_window_size_(spdy::kSpdyStreamInitialWindowSize), | 286 initial_send_window_size_(spdy::kSpdyStreamInitialWindowSize), |
| 286 initial_recv_window_size_(spdy::kSpdyStreamInitialWindowSize), | 287 initial_recv_window_size_(spdy::kSpdyStreamInitialWindowSize), |
| 287 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), | 288 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), |
| 288 verify_domain_authentication_(verify_domain_authentication) { | 289 verify_domain_authentication_(verify_domain_authentication) { |
| 289 DCHECK(HttpStreamFactory::spdy_enabled()); | 290 DCHECK(HttpStreamFactory::spdy_enabled()); |
| 290 net_log_.BeginEvent( | 291 net_log_.BeginEvent( |
| 291 NetLog::TYPE_SPDY_SESSION, | 292 NetLog::TYPE_SPDY_SESSION, |
| 292 make_scoped_refptr( | 293 make_scoped_refptr( |
| 293 new NetLogSpdySessionParameter(host_port_proxy_pair_))); | 294 new NetLogSpdySessionParameter(host_port_proxy_pair_))); |
| 294 | 295 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 int certificate_error_code) { | 330 int certificate_error_code) { |
| 330 base::StatsCounter spdy_sessions("spdy.sessions"); | 331 base::StatsCounter spdy_sessions("spdy.sessions"); |
| 331 spdy_sessions.Increment(); | 332 spdy_sessions.Increment(); |
| 332 | 333 |
| 333 state_ = CONNECTED; | 334 state_ = CONNECTED; |
| 334 connection_.reset(connection); | 335 connection_.reset(connection); |
| 335 connection_->AddLayeredPool(this); | 336 connection_->AddLayeredPool(this); |
| 336 is_secure_ = is_secure; | 337 is_secure_ = is_secure; |
| 337 certificate_error_code_ = certificate_error_code; | 338 certificate_error_code_ = certificate_error_code; |
| 338 | 339 |
| 340 if (is_secure_) { |
| 341 SSLClientSocket* ssl_socket = |
| 342 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
| 343 DCHECK(ssl_socket); |
| 344 if (ssl_socket->next_protocol_negotiated() == SSLClientSocket::kProtoSPDY21) |
| 345 flow_control_ = true; |
| 346 } |
| 347 |
| 339 // Write out any data that we might have to send, such as the settings frame. | 348 // Write out any data that we might have to send, such as the settings frame. |
| 340 WriteSocketLater(); | 349 WriteSocketLater(); |
| 341 net::Error error = ReadSocket(); | 350 net::Error error = ReadSocket(); |
| 342 if (error == ERR_IO_PENDING) | 351 if (error == ERR_IO_PENDING) |
| 343 return OK; | 352 return OK; |
| 344 return error; | 353 return error; |
| 345 } | 354 } |
| 346 | 355 |
| 347 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { | 356 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { |
| 348 if (!verify_domain_authentication_) | 357 if (!verify_domain_authentication_) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 CHECK_EQ(stream->stream_id(), stream_id); | 559 CHECK_EQ(stream->stream_id(), stream_id); |
| 551 if (!stream) | 560 if (!stream) |
| 552 return ERR_INVALID_SPDY_STREAM; | 561 return ERR_INVALID_SPDY_STREAM; |
| 553 | 562 |
| 554 if (len > kMaxSpdyFrameChunkSize) { | 563 if (len > kMaxSpdyFrameChunkSize) { |
| 555 len = kMaxSpdyFrameChunkSize; | 564 len = kMaxSpdyFrameChunkSize; |
| 556 flags = static_cast<spdy::SpdyDataFlags>(flags & ~spdy::DATA_FLAG_FIN); | 565 flags = static_cast<spdy::SpdyDataFlags>(flags & ~spdy::DATA_FLAG_FIN); |
| 557 } | 566 } |
| 558 | 567 |
| 559 // Obey send window size of the stream if flow control is enabled. | 568 // Obey send window size of the stream if flow control is enabled. |
| 560 if (use_flow_control_) { | 569 if (flow_control_) { |
| 561 if (stream->send_window_size() <= 0) { | 570 if (stream->send_window_size() <= 0) { |
| 562 // Because we queue frames onto the session, it is possible that | 571 // Because we queue frames onto the session, it is possible that |
| 563 // a stream was not flow controlled at the time it attempted the | 572 // a stream was not flow controlled at the time it attempted the |
| 564 // write, but when we go to fulfill the write, it is now flow | 573 // write, but when we go to fulfill the write, it is now flow |
| 565 // controlled. This is why we need the session to mark the stream | 574 // controlled. This is why we need the session to mark the stream |
| 566 // as stalled - because only the session knows for sure when the | 575 // as stalled - because only the session knows for sure when the |
| 567 // stall occurs. | 576 // stall occurs. |
| 568 stream->set_stalled_by_flow_control(true); | 577 stream->set_stalled_by_flow_control(true); |
| 569 net_log().AddEvent( | 578 net_log().AddEvent( |
| 570 NetLog::TYPE_SPDY_SESSION_STALLED_ON_SEND_WINDOW, | 579 NetLog::TYPE_SPDY_SESSION_STALLED_ON_SEND_WINDOW, |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 LOG(WARNING) << "Received WINDOW_UPDATE with an invalid delta_window_size " | 1465 LOG(WARNING) << "Received WINDOW_UPDATE with an invalid delta_window_size " |
| 1457 << delta_window_size; | 1466 << delta_window_size; |
| 1458 ResetStream(stream_id, spdy::FLOW_CONTROL_ERROR); | 1467 ResetStream(stream_id, spdy::FLOW_CONTROL_ERROR); |
| 1459 return; | 1468 return; |
| 1460 } | 1469 } |
| 1461 | 1470 |
| 1462 scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; | 1471 scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; |
| 1463 CHECK_EQ(stream->stream_id(), stream_id); | 1472 CHECK_EQ(stream->stream_id(), stream_id); |
| 1464 CHECK(!stream->cancelled()); | 1473 CHECK(!stream->cancelled()); |
| 1465 | 1474 |
| 1466 if (use_flow_control_) | 1475 if (flow_control_) |
| 1467 stream->IncreaseSendWindowSize(delta_window_size); | 1476 stream->IncreaseSendWindowSize(delta_window_size); |
| 1468 | 1477 |
| 1469 net_log_.AddEvent( | 1478 net_log_.AddEvent( |
| 1470 NetLog::TYPE_SPDY_SESSION_SEND_WINDOW_UPDATE, | 1479 NetLog::TYPE_SPDY_SESSION_SEND_WINDOW_UPDATE, |
| 1471 make_scoped_refptr(new NetLogSpdyWindowUpdateParameter( | 1480 make_scoped_refptr(new NetLogSpdyWindowUpdateParameter( |
| 1472 stream_id, delta_window_size, stream->send_window_size()))); | 1481 stream_id, delta_window_size, stream->send_window_size()))); |
| 1473 } | 1482 } |
| 1474 | 1483 |
| 1475 void SpdySession::SendWindowUpdate(spdy::SpdyStreamId stream_id, | 1484 void SpdySession::SendWindowUpdate(spdy::SpdyStreamId stream_id, |
| 1476 int delta_window_size) { | 1485 int delta_window_size) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 if (it == pending_callback_map_.end()) | 1763 if (it == pending_callback_map_.end()) |
| 1755 return; | 1764 return; |
| 1756 | 1765 |
| 1757 OldCompletionCallback* callback = it->second.callback; | 1766 OldCompletionCallback* callback = it->second.callback; |
| 1758 int result = it->second.result; | 1767 int result = it->second.result; |
| 1759 pending_callback_map_.erase(it); | 1768 pending_callback_map_.erase(it); |
| 1760 callback->Run(result); | 1769 callback->Run(result); |
| 1761 } | 1770 } |
| 1762 | 1771 |
| 1763 } // namespace net | 1772 } // namespace net |
| OLD | NEW |