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

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

Issue 10479014: Increase Chrome SPDY/3 stream receive window to 10MB. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix raman's comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_spdy3_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 const SpdyStreamId last_stream_id_; 293 const SpdyStreamId last_stream_id_;
294 const int active_streams_; 294 const int active_streams_;
295 const int unclaimed_streams_; 295 const int unclaimed_streams_;
296 296
297 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyGoAwayParameter); 297 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyGoAwayParameter);
298 }; 298 };
299 299
300 NextProto g_default_protocol = kProtoUnknown; 300 NextProto g_default_protocol = kProtoUnknown;
301 size_t g_init_max_concurrent_streams = 10; 301 size_t g_init_max_concurrent_streams = 10;
302 size_t g_max_concurrent_stream_limit = 256; 302 size_t g_max_concurrent_stream_limit = 256;
303 size_t g_default_initial_rcv_window_size = 10 * 1024 * 1024; // 10MB
303 bool g_enable_ping_based_connection_checking = true; 304 bool g_enable_ping_based_connection_checking = true;
304 305
305 } // namespace 306 } // namespace
306 307
307 // static 308 // static
308 void SpdySession::set_default_protocol(NextProto default_protocol) { 309 void SpdySession::set_default_protocol(NextProto default_protocol) {
309 g_default_protocol = default_protocol; 310 g_default_protocol = default_protocol;
310 } 311 }
311 312
312 // static 313 // static
313 void SpdySession::set_max_concurrent_streams(size_t value) { 314 void SpdySession::set_max_concurrent_streams(size_t value) {
314 g_max_concurrent_stream_limit = value; 315 g_max_concurrent_stream_limit = value;
315 } 316 }
316 317
317 // static 318 // static
319 void SpdySession::set_default_initial_recv_window_size(size_t value) {
320 g_default_initial_rcv_window_size = value;
321 }
322
323 // static
318 void SpdySession::set_enable_ping_based_connection_checking(bool enable) { 324 void SpdySession::set_enable_ping_based_connection_checking(bool enable) {
319 g_enable_ping_based_connection_checking = enable; 325 g_enable_ping_based_connection_checking = enable;
320 } 326 }
321 327
322 // static 328 // static
323 void SpdySession::set_init_max_concurrent_streams(size_t value) { 329 void SpdySession::set_init_max_concurrent_streams(size_t value) {
324 g_init_max_concurrent_streams = 330 g_init_max_concurrent_streams =
325 std::min(value, g_max_concurrent_stream_limit); 331 std::min(value, g_max_concurrent_stream_limit);
326 } 332 }
327 333
328 // static 334 // static
329 void SpdySession::ResetStaticSettingsToInit() { 335 void SpdySession::ResetStaticSettingsToInit() {
330 // WARNING: These must match the initializers above. 336 // WARNING: These must match the initializers above.
331 g_default_protocol = kProtoUnknown; 337 g_default_protocol = kProtoUnknown;
332 g_init_max_concurrent_streams = 10; 338 g_init_max_concurrent_streams = 10;
333 g_max_concurrent_stream_limit = 256; 339 g_max_concurrent_stream_limit = 256;
340 g_default_initial_rcv_window_size = kSpdyStreamInitialWindowSize;
334 g_enable_ping_based_connection_checking = true; 341 g_enable_ping_based_connection_checking = true;
335 } 342 }
336 343
337 SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, 344 SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
338 SpdySessionPool* spdy_session_pool, 345 SpdySessionPool* spdy_session_pool,
339 HttpServerProperties* http_server_properties, 346 HttpServerProperties* http_server_properties,
340 bool verify_domain_authentication, 347 bool verify_domain_authentication,
341 const HostPortPair& trusted_spdy_proxy, 348 const HostPortPair& trusted_spdy_proxy,
342 NetLog* net_log) 349 NetLog* net_log)
343 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 350 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
(...skipping 18 matching lines...) Expand all
362 bytes_received_(0), 369 bytes_received_(0),
363 sent_settings_(false), 370 sent_settings_(false),
364 received_settings_(false), 371 received_settings_(false),
365 stalled_streams_(0), 372 stalled_streams_(0),
366 pings_in_flight_(0), 373 pings_in_flight_(0),
367 next_ping_id_(1), 374 next_ping_id_(1),
368 last_activity_time_(base::TimeTicks::Now()), 375 last_activity_time_(base::TimeTicks::Now()),
369 check_ping_status_pending_(false), 376 check_ping_status_pending_(false),
370 flow_control_(false), 377 flow_control_(false),
371 initial_send_window_size_(kSpdyStreamInitialWindowSize), 378 initial_send_window_size_(kSpdyStreamInitialWindowSize),
372 initial_recv_window_size_(kSpdyStreamInitialWindowSize), 379 initial_recv_window_size_(g_default_initial_rcv_window_size),
373 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), 380 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)),
374 verify_domain_authentication_(verify_domain_authentication), 381 verify_domain_authentication_(verify_domain_authentication),
375 credential_state_(SpdyCredentialState::kDefaultNumSlots), 382 credential_state_(SpdyCredentialState::kDefaultNumSlots),
376 connection_at_risk_of_loss_time_( 383 connection_at_risk_of_loss_time_(
377 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), 384 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)),
378 hung_interval_( 385 hung_interval_(
379 base::TimeDelta::FromSeconds(kHungIntervalSeconds)), 386 base::TimeDelta::FromSeconds(kHungIntervalSeconds)),
380 trusted_spdy_proxy_(trusted_spdy_proxy) { 387 trusted_spdy_proxy_(trusted_spdy_proxy) {
381 DCHECK(HttpStreamFactory::spdy_enabled()); 388 DCHECK(HttpStreamFactory::spdy_enabled());
382 net_log_.BeginEvent( 389 net_log_.BeginEvent(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 host_port_pair().ToString())); 447 host_port_pair().ToString()));
441 } 448 }
442 449
443 DCHECK(protocol >= kProtoSPDY2); 450 DCHECK(protocol >= kProtoSPDY2);
444 DCHECK(protocol <= kProtoSPDY3); 451 DCHECK(protocol <= kProtoSPDY3);
445 int version = (protocol == kProtoSPDY3) ? 3 : 2; 452 int version = (protocol == kProtoSPDY3) ? 3 : 2;
446 flow_control_ = (protocol >= kProtoSPDY3); 453 flow_control_ = (protocol >= kProtoSPDY3);
447 454
448 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); 455 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version));
449 buffered_spdy_framer_->set_visitor(this); 456 buffered_spdy_framer_->set_visitor(this);
450 SendSettings(); 457 SendInitialSettings();
451 458
452 // Write out any data that we might have to send, such as the settings frame. 459 // Write out any data that we might have to send, such as the settings frame.
453 WriteSocketLater(); 460 WriteSocketLater();
454 net::Error error = ReadSocket(); 461 net::Error error = ReadSocket();
455 if (error == ERR_IO_PENDING) 462 if (error == ERR_IO_PENDING)
456 return OK; 463 return OK;
457 return error; 464 return error;
458 } 465 }
459 466
460 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 467 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 else if (trial->group_name() == "cwndMin16") 1696 else if (trial->group_name() == "cwndMin16")
1690 return std::max(cwnd, 16); 1697 return std::max(cwnd, 16);
1691 else if (trial->group_name() == "cwndMin10") 1698 else if (trial->group_name() == "cwndMin10")
1692 return std::max(cwnd, 10); 1699 return std::max(cwnd, 10);
1693 else if (trial->group_name() == "cwndDynamic") 1700 else if (trial->group_name() == "cwndDynamic")
1694 return cwnd; 1701 return cwnd;
1695 NOTREACHED(); 1702 NOTREACHED();
1696 return cwnd; 1703 return cwnd;
1697 } 1704 }
1698 1705
1699 void SpdySession::SendSettings() { 1706 void SpdySession::SendInitialSettings() {
1707 // First notify the server about the settings they should use when
1708 // communicating with us.
1709 if (GetProtocolVersion() > 2 &&
1710 initial_recv_window_size_ != kSpdyStreamInitialWindowSize) {
1711 SettingsMap settings_map;
1712 // Create a new settings frame notifying the sever of our
1713 // initial window size.
1714 settings_map[SETTINGS_INITIAL_WINDOW_SIZE] =
1715 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, initial_recv_window_size_);
1716 sent_settings_ = true;
1717 SendSettings(settings_map);
1718 }
1719
1720 // Next notify the server about the settings they have previously
1721 // told us to use when communicating with them.
1700 const SettingsMap& settings_map = 1722 const SettingsMap& settings_map =
1701 http_server_properties_->GetSpdySettings(host_port_pair()); 1723 http_server_properties_->GetSpdySettings(host_port_pair());
1702 if (settings_map.empty()) 1724 if (settings_map.empty())
1703 return; 1725 return;
1704 1726
1705 // Record Histogram Data and Apply the SpdyCwnd FieldTrial if applicable. 1727 // Record Histogram Data and Apply the SpdyCwnd FieldTrial if applicable.
1706 const SpdySettingsIds id = SETTINGS_CURRENT_CWND; 1728 const SpdySettingsIds id = SETTINGS_CURRENT_CWND;
1707 SettingsMap::const_iterator it = settings_map.find(id); 1729 SettingsMap::const_iterator it = settings_map.find(id);
1708 uint32 value = 0; 1730 uint32 value = 0;
1709 if (it != settings_map.end()) 1731 if (it != settings_map.end())
1710 value = it->second.second; 1732 value = it->second.second;
1711 uint32 cwnd = ApplyCwndFieldTrialPolicy(value); 1733 uint32 cwnd = ApplyCwndFieldTrialPolicy(value);
1712 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); 1734 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100);
1713 if (cwnd != value) { 1735 if (cwnd != value) {
1714 http_server_properties_->SetSpdySetting( 1736 http_server_properties_->SetSpdySetting(
1715 host_port_pair(), id, SETTINGS_FLAG_PLEASE_PERSIST, cwnd); 1737 host_port_pair(), id, SETTINGS_FLAG_PLEASE_PERSIST, cwnd);
1716 } 1738 }
1717 1739
1718 const SettingsMap& settings_map_new = 1740 const SettingsMap& settings_map_new =
1719 http_server_properties_->GetSpdySettings(host_port_pair()); 1741 http_server_properties_->GetSpdySettings(host_port_pair());
1720 for (SettingsMap::const_iterator i = settings_map_new.begin(), 1742 for (SettingsMap::const_iterator i = settings_map_new.begin(),
1721 end = settings_map_new.end(); i != end; ++i) { 1743 end = settings_map_new.end(); i != end; ++i) {
1722 const SpdySettingsIds new_id = i->first; 1744 const SpdySettingsIds new_id = i->first;
1723 const uint32 new_val = i->second.second; 1745 const uint32 new_val = i->second.second;
1724 HandleSetting(new_id, new_val); 1746 HandleSetting(new_id, new_val);
1725 } 1747 }
1726 1748
1749 sent_settings_ = true;
1750 SendSettings(settings_map_new);
1751 }
1752
1753
1754 void SpdySession::SendSettings(const SettingsMap& settings) {
1727 net_log_.AddEvent( 1755 net_log_.AddEvent(
1728 NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, 1756 NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS,
1729 make_scoped_refptr(new NetLogSpdySettingsParameter(settings_map_new))); 1757 make_scoped_refptr(new NetLogSpdySettingsParameter(settings)));
1730 1758
1731 // Create the SETTINGS frame and send it. 1759 // Create the SETTINGS frame and send it.
1732 DCHECK(buffered_spdy_framer_.get()); 1760 DCHECK(buffered_spdy_framer_.get());
1733 scoped_ptr<SpdySettingsControlFrame> settings_frame( 1761 scoped_ptr<SpdySettingsControlFrame> settings_frame(
1734 buffered_spdy_framer_->CreateSettings(settings_map_new)); 1762 buffered_spdy_framer_->CreateSettings(settings));
1735 sent_settings_ = true;
1736 QueueFrame(settings_frame.get(), HIGHEST, NULL); 1763 QueueFrame(settings_frame.get(), HIGHEST, NULL);
1737 } 1764 }
1738 1765
1739 void SpdySession::HandleSetting(uint32 id, uint32 value) { 1766 void SpdySession::HandleSetting(uint32 id, uint32 value) {
1740 switch (id) { 1767 switch (id) {
1741 case SETTINGS_MAX_CONCURRENT_STREAMS: 1768 case SETTINGS_MAX_CONCURRENT_STREAMS:
1742 max_concurrent_streams_ = std::min(static_cast<size_t>(value), 1769 max_concurrent_streams_ = std::min(static_cast<size_t>(value),
1743 g_max_concurrent_stream_limit); 1770 g_max_concurrent_stream_limit);
1744 ProcessPendingCreateStreams(); 1771 ProcessPendingCreateStreams();
1745 break; 1772 break;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1973 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1947 if (!is_secure_) 1974 if (!is_secure_)
1948 return NULL; 1975 return NULL;
1949 SSLClientSocket* ssl_socket = 1976 SSLClientSocket* ssl_socket =
1950 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1977 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1951 DCHECK(ssl_socket); 1978 DCHECK(ssl_socket);
1952 return ssl_socket; 1979 return ssl_socket;
1953 } 1980 }
1954 1981
1955 } // namespace net 1982 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698