| 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "net/base/connection_type_histograms.h" | 26 #include "net/base/connection_type_histograms.h" |
| 27 #include "net/base/net_log.h" | 27 #include "net/base/net_log.h" |
| 28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 29 #include "net/base/server_bound_cert_service.h" | 29 #include "net/base/server_bound_cert_service.h" |
| 30 #include "net/http/http_network_session.h" | 30 #include "net/http/http_network_session.h" |
| 31 #include "net/http/http_server_properties.h" | 31 #include "net/http/http_server_properties.h" |
| 32 #include "net/spdy/spdy_frame_builder.h" | 32 #include "net/spdy/spdy_frame_builder.h" |
| 33 #include "net/spdy/spdy_http_utils.h" | 33 #include "net/spdy/spdy_http_utils.h" |
| 34 #include "net/spdy/spdy_protocol.h" | 34 #include "net/spdy/spdy_protocol.h" |
| 35 #include "net/spdy/spdy_session_pool.h" | 35 #include "net/spdy/spdy_session_pool.h" |
| 36 #include "net/spdy/spdy_settings_storage.h" | |
| 37 #include "net/spdy/spdy_stream.h" | 36 #include "net/spdy/spdy_stream.h" |
| 38 | 37 |
| 39 namespace net { | 38 namespace net { |
| 40 | 39 |
| 41 NetLogSpdySynParameter::NetLogSpdySynParameter( | 40 NetLogSpdySynParameter::NetLogSpdySynParameter( |
| 42 const linked_ptr<SpdyHeaderBlock>& headers, | 41 const linked_ptr<SpdyHeaderBlock>& headers, |
| 43 SpdyControlFlags flags, | 42 SpdyControlFlags flags, |
| 44 SpdyStreamId id, | 43 SpdyStreamId id, |
| 45 SpdyStreamId associated_stream) | 44 SpdyStreamId associated_stream) |
| 46 : headers_(headers), | 45 : headers_(headers), |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 ~NetLogSpdySettingParameter() {} | 144 ~NetLogSpdySettingParameter() {} |
| 146 const SpdySettingsIds id_; | 145 const SpdySettingsIds id_; |
| 147 const SpdySettingsFlags flags_; | 146 const SpdySettingsFlags flags_; |
| 148 const uint32 value_; | 147 const uint32 value_; |
| 149 | 148 |
| 150 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySettingParameter); | 149 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySettingParameter); |
| 151 }; | 150 }; |
| 152 | 151 |
| 153 class NetLogSpdySettingsParameter : public NetLog::EventParameters { | 152 class NetLogSpdySettingsParameter : public NetLog::EventParameters { |
| 154 public: | 153 public: |
| 155 explicit NetLogSpdySettingsParameter(const SpdySettings& settings) | 154 explicit NetLogSpdySettingsParameter(const SettingsMap& settings) |
| 156 : settings_(settings) {} | 155 : settings_(settings) {} |
| 157 | 156 |
| 158 virtual Value* ToValue() const { | 157 virtual Value* ToValue() const { |
| 159 DictionaryValue* dict = new DictionaryValue(); | 158 DictionaryValue* dict = new DictionaryValue(); |
| 160 ListValue* settings = new ListValue(); | 159 ListValue* settings = new ListValue(); |
| 161 for (SpdySettings::const_iterator it = settings_.begin(); | 160 for (SettingsMap::const_iterator it = settings_.begin(); |
| 162 it != settings_.end(); ++it) { | 161 it != settings_.end(); ++it) { |
| 162 const SpdySettingsIds id = it->first; |
| 163 const SpdySettingsFlags flags = it->second.first; |
| 164 const uint32 value = it->second.second; |
| 163 settings->Append(new StringValue( | 165 settings->Append(new StringValue( |
| 164 base::StringPrintf("[%u:%u]", it->first.id(), it->second))); | 166 base::StringPrintf("[id:%u flags:%u value:%u]", id, flags, value))); |
| 165 } | 167 } |
| 166 dict->Set("settings", settings); | 168 dict->Set("settings", settings); |
| 167 return dict; | 169 return dict; |
| 168 } | 170 } |
| 169 | 171 |
| 170 private: | 172 private: |
| 171 ~NetLogSpdySettingsParameter() {} | 173 ~NetLogSpdySettingsParameter() {} |
| 172 const SpdySettings settings_; | 174 const SettingsMap settings_; |
| 173 | 175 |
| 174 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySettingsParameter); | 176 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySettingsParameter); |
| 175 }; | 177 }; |
| 176 | 178 |
| 177 class NetLogSpdyWindowUpdateParameter : public NetLog::EventParameters { | 179 class NetLogSpdyWindowUpdateParameter : public NetLog::EventParameters { |
| 178 public: | 180 public: |
| 179 NetLogSpdyWindowUpdateParameter(SpdyStreamId stream_id, int32 delta) | 181 NetLogSpdyWindowUpdateParameter(SpdyStreamId stream_id, int32 delta) |
| 180 : stream_id_(stream_id), delta_(delta) {} | 182 : stream_id_(stream_id), delta_(delta) {} |
| 181 | 183 |
| 182 virtual Value* ToValue() const { | 184 virtual Value* ToValue() const { |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 value = it->second.second; | 1716 value = it->second.second; |
| 1715 uint32 cwnd = ApplyCwndFieldTrialPolicy(value); | 1717 uint32 cwnd = ApplyCwndFieldTrialPolicy(value); |
| 1716 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); | 1718 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); |
| 1717 if (cwnd != value) { | 1719 if (cwnd != value) { |
| 1718 http_server_properties_->SetSpdySetting( | 1720 http_server_properties_->SetSpdySetting( |
| 1719 host_port_pair(), id, SETTINGS_FLAG_PLEASE_PERSIST, cwnd); | 1721 host_port_pair(), id, SETTINGS_FLAG_PLEASE_PERSIST, cwnd); |
| 1720 } | 1722 } |
| 1721 | 1723 |
| 1722 const SettingsMap& settings_map_new = | 1724 const SettingsMap& settings_map_new = |
| 1723 http_server_properties_->GetSpdySettings(host_port_pair()); | 1725 http_server_properties_->GetSpdySettings(host_port_pair()); |
| 1724 | |
| 1725 SpdySettings settings; | |
| 1726 for (SettingsMap::const_iterator i = settings_map_new.begin(), | 1726 for (SettingsMap::const_iterator i = settings_map_new.begin(), |
| 1727 end = settings_map_new.end(); i != end; ++i) { | 1727 end = settings_map_new.end(); i != end; ++i) { |
| 1728 const SpdySettingsIds new_id = i->first; | 1728 const SpdySettingsIds new_id = i->first; |
| 1729 const SpdySettingsFlags new_flags = i->second.first; | |
| 1730 const uint32 new_val = i->second.second; | 1729 const uint32 new_val = i->second.second; |
| 1731 HandleSetting(new_id, new_val); | 1730 HandleSetting(new_id, new_val); |
| 1732 SettingsFlagsAndId flags_and_id(new_flags, new_id); | |
| 1733 settings.push_back(SpdySetting(flags_and_id, new_val)); | |
| 1734 } | 1731 } |
| 1735 | 1732 |
| 1736 net_log_.AddEvent( | 1733 net_log_.AddEvent( |
| 1737 NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, | 1734 NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, |
| 1738 make_scoped_refptr(new NetLogSpdySettingsParameter(settings))); | 1735 make_scoped_refptr(new NetLogSpdySettingsParameter(settings_map_new))); |
| 1739 | 1736 |
| 1740 // Create the SETTINGS frame and send it. | 1737 // Create the SETTINGS frame and send it. |
| 1741 DCHECK(buffered_spdy_framer_.get()); | 1738 DCHECK(buffered_spdy_framer_.get()); |
| 1742 scoped_ptr<SpdySettingsControlFrame> settings_frame( | 1739 scoped_ptr<SpdySettingsControlFrame> settings_frame( |
| 1743 buffered_spdy_framer_->CreateSettings(settings)); | 1740 buffered_spdy_framer_->CreateSettings(settings_map_new)); |
| 1744 sent_settings_ = true; | 1741 sent_settings_ = true; |
| 1745 QueueFrame(settings_frame.get(), 0, NULL); | 1742 QueueFrame(settings_frame.get(), 0, NULL); |
| 1746 } | 1743 } |
| 1747 | 1744 |
| 1748 void SpdySession::HandleSetting(uint32 id, uint32 value) { | 1745 void SpdySession::HandleSetting(uint32 id, uint32 value) { |
| 1749 switch (id) { | 1746 switch (id) { |
| 1750 case SETTINGS_MAX_CONCURRENT_STREAMS: | 1747 case SETTINGS_MAX_CONCURRENT_STREAMS: |
| 1751 max_concurrent_streams_ = std::min(static_cast<size_t>(value), | 1748 max_concurrent_streams_ = std::min(static_cast<size_t>(value), |
| 1752 g_max_concurrent_stream_limit); | 1749 g_max_concurrent_stream_limit); |
| 1753 ProcessPendingCreateStreams(); | 1750 ProcessPendingCreateStreams(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 1964 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
| 1968 if (!is_secure_) | 1965 if (!is_secure_) |
| 1969 return NULL; | 1966 return NULL; |
| 1970 SSLClientSocket* ssl_socket = | 1967 SSLClientSocket* ssl_socket = |
| 1971 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1968 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
| 1972 DCHECK(ssl_socket); | 1969 DCHECK(ssl_socket); |
| 1973 return ssl_socket; | 1970 return ssl_socket; |
| 1974 } | 1971 } |
| 1975 | 1972 |
| 1976 } // namespace net | 1973 } // namespace net |
| OLD | NEW |