Chromium Code Reviews| Index: net/spdy/spdy_session.cc | 
| diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc | 
| index 050d35beae9204adfd1771ccc7bf7730a7288c49..ed6a6937a1bd930d876e51499c366b46c34373c0 100644 | 
| --- a/net/spdy/spdy_session.cc | 
| +++ b/net/spdy/spdy_session.cc | 
| @@ -300,6 +300,7 @@ class NetLogSpdyGoAwayParameter : public NetLog::EventParameters { | 
| NextProto g_default_protocol = kProtoUnknown; | 
| size_t g_init_max_concurrent_streams = 10; | 
| size_t g_max_concurrent_stream_limit = 256; | 
| +size_t g_default_initial_rcv_window_size = 10 * 1024 * 1024; // 10MB | 
| bool g_enable_ping_based_connection_checking = true; | 
| } // namespace | 
| @@ -315,6 +316,11 @@ void SpdySession::set_max_concurrent_streams(size_t value) { | 
| } | 
| // static | 
| +void SpdySession::set_default_initial_recv_window_size(size_t value) { | 
| + g_default_initial_rcv_window_size = value; | 
| +} | 
| + | 
| +// static | 
| void SpdySession::set_enable_ping_based_connection_checking(bool enable) { | 
| g_enable_ping_based_connection_checking = enable; | 
| } | 
| @@ -331,6 +337,7 @@ void SpdySession::ResetStaticSettingsToInit() { | 
| g_default_protocol = kProtoUnknown; | 
| g_init_max_concurrent_streams = 10; | 
| g_max_concurrent_stream_limit = 256; | 
| + g_default_initial_rcv_window_size = kSpdyStreamInitialWindowSize; | 
| g_enable_ping_based_connection_checking = true; | 
| } | 
| @@ -369,7 +376,7 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, | 
| check_ping_status_pending_(false), | 
| flow_control_(false), | 
| initial_send_window_size_(kSpdyStreamInitialWindowSize), | 
| - initial_recv_window_size_(kSpdyStreamInitialWindowSize), | 
| + initial_recv_window_size_(g_default_initial_rcv_window_size), | 
| net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), | 
| verify_domain_authentication_(verify_domain_authentication), | 
| credential_state_(SpdyCredentialState::kDefaultNumSlots), | 
| @@ -447,7 +454,7 @@ net::Error SpdySession::InitializeWithSocket( | 
| buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); | 
| buffered_spdy_framer_->set_visitor(this); | 
| - SendSettings(); | 
| + SendInitialSettings(); | 
| // Write out any data that we might have to send, such as the settings frame. | 
| WriteSocketLater(); | 
| @@ -1696,42 +1703,72 @@ uint32 ApplyCwndFieldTrialPolicy(int cwnd) { | 
| return cwnd; | 
| } | 
| -void SpdySession::SendSettings() { | 
| - const SettingsMap& settings_map = | 
| - http_server_properties_->GetSpdySettings(host_port_pair()); | 
| - if (settings_map.empty()) | 
| - return; | 
| +void SpdySession::SendInitialSettings() { | 
| + SettingsMap settings_to_send; | 
| + | 
| + // First notify the server about the settings they should use when | 
| + // communicating with use. | 
| + if (GetProtocolVersion() > 2 && | 
| + initial_recv_window_size_ != kSpdyStreamInitialWindowSize) { | 
| + // Create a new settings frame notifying the sever of our | 
| + // initial window size. | 
| 
 
ramant (doing other things)
2012/06/04 20:22:35
nit: could we update the comment (because initial
 
Ryan Hamilton
2012/06/04 20:48:50
Ugh.  That would be a bug.  We do not want to over
 
 | 
| + settings_to_send[SETTINGS_INITIAL_WINDOW_SIZE] = | 
| + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, initial_recv_window_size_); | 
| + /* | 
| + net_log_.AddEvent( | 
| + NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, | 
| + make_scoped_refptr(new NetLogSpdySettingsParameter(settings_map))); | 
| - // Record Histogram Data and Apply the SpdyCwnd FieldTrial if applicable. | 
| - const SpdySettingsIds id = SETTINGS_CURRENT_CWND; | 
| - SettingsMap::const_iterator it = settings_map.find(id); | 
| - uint32 value = 0; | 
| - if (it != settings_map.end()) | 
| - value = it->second.second; | 
| - uint32 cwnd = ApplyCwndFieldTrialPolicy(value); | 
| - UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); | 
| - if (cwnd != value) { | 
| - http_server_properties_->SetSpdySetting( | 
| - host_port_pair(), id, SETTINGS_FLAG_PLEASE_PERSIST, cwnd); | 
| + // Create the SETTINGS frame and send it. | 
| + DCHECK(buffered_spdy_framer_.get()); | 
| + scoped_ptr<SpdySettingsControlFrame> settings_frame( | 
| + buffered_spdy_framer_->CreateSettings(settings_map)); | 
| + sent_settings_ = true; | 
| + QueueFrame(settings_frame.get(), HIGHEST, NULL); | 
| 
 
ramant (doing other things)
2012/06/04 20:22:35
nit: Should we delete the commented out code?
 
Ryan Hamilton
2012/06/04 20:48:50
Whoops!  Done.  (Now factored into a new helper me
 
 | 
| + */ | 
| } | 
| - const SettingsMap& settings_map_new = | 
| + const SettingsMap& settings_map = | 
| http_server_properties_->GetSpdySettings(host_port_pair()); | 
| - for (SettingsMap::const_iterator i = settings_map_new.begin(), | 
| - end = settings_map_new.end(); i != end; ++i) { | 
| - const SpdySettingsIds new_id = i->first; | 
| - const uint32 new_val = i->second.second; | 
| - HandleSetting(new_id, new_val); | 
| + | 
| + // Next notify the server about the settings they have previously | 
| + // told use to use when communicating with them. | 
| 
 
ramant (doing other things)
2012/06/04 20:22:35
nit: could we update this comment because we are n
 
Ryan Hamilton
2012/06/04 20:48:50
Since I had to change the code, I kept the comment
 
 | 
| + if (!settings_map.empty()) { | 
| + // Record Histogram Data and Apply the SpdyCwnd FieldTrial if applicable. | 
| + const SpdySettingsIds id = SETTINGS_CURRENT_CWND; | 
| + SettingsMap::const_iterator it = settings_map.find(id); | 
| + uint32 value = 0; | 
| + if (it != settings_map.end()) | 
| + value = it->second.second; | 
| + uint32 cwnd = ApplyCwndFieldTrialPolicy(value); | 
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); | 
| + if (cwnd != value) { | 
| + http_server_properties_->SetSpdySetting( | 
| + host_port_pair(), id, SETTINGS_FLAG_PLEASE_PERSIST, cwnd); | 
| + } | 
| + | 
| + const SettingsMap& settings_map_new = | 
| + http_server_properties_->GetSpdySettings(host_port_pair()); | 
| + for (SettingsMap::const_iterator i = settings_map_new.begin(), | 
| + end = settings_map_new.end(); i != end; ++i) { | 
| + const SpdySettingsIds new_id = i->first; | 
| + const uint32 new_val = i->second.second; | 
| + HandleSetting(new_id, new_val); | 
| + settings_to_send[i->first] = i->second; | 
| + } | 
| } | 
| + if (settings_to_send.empty()) | 
| + return; | 
| + | 
| net_log_.AddEvent( | 
| NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, | 
| - make_scoped_refptr(new NetLogSpdySettingsParameter(settings_map_new))); | 
| + make_scoped_refptr(new NetLogSpdySettingsParameter(settings_to_send))); | 
| // Create the SETTINGS frame and send it. | 
| DCHECK(buffered_spdy_framer_.get()); | 
| scoped_ptr<SpdySettingsControlFrame> settings_frame( | 
| - buffered_spdy_framer_->CreateSettings(settings_map_new)); | 
| + buffered_spdy_framer_->CreateSettings(settings_to_send)); | 
| sent_settings_ = true; | 
| QueueFrame(settings_frame.get(), HIGHEST, NULL); | 
| } |