| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 NOTREACHED(); | 2026 NOTREACHED(); |
| 2027 return base::WeakPtr<SpdyStream>(); | 2027 return base::WeakPtr<SpdyStream>(); |
| 2028 } | 2028 } |
| 2029 | 2029 |
| 2030 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ADOPTED_PUSH_STREAM, | 2030 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ADOPTED_PUSH_STREAM, |
| 2031 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, | 2031 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, |
| 2032 active_it->second.stream->stream_id(), &url)); | 2032 active_it->second.stream->stream_id(), &url)); |
| 2033 return active_it->second.stream->GetWeakPtr(); | 2033 return active_it->second.stream->GetWeakPtr(); |
| 2034 } | 2034 } |
| 2035 | 2035 |
| 2036 url::SchemeHostPort SpdySession::GetSpdyServer() { |
| 2037 SSLInfo ssl_info; |
| 2038 bool is_https = connection_->socket()->GetSSLInfo(&ssl_info); |
| 2039 return url::SchemeHostPort(is_https ? "https" : "http", |
| 2040 host_port_pair().host(), |
| 2041 host_port_pair().port()); |
| 2042 } |
| 2043 |
| 2036 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, | 2044 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, |
| 2037 bool* was_npn_negotiated, | 2045 bool* was_npn_negotiated, |
| 2038 NextProto* protocol_negotiated) { | 2046 NextProto* protocol_negotiated) { |
| 2039 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); | 2047 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); |
| 2040 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); | 2048 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); |
| 2041 return connection_->socket()->GetSSLInfo(ssl_info); | 2049 return connection_->socket()->GetSSLInfo(ssl_info); |
| 2042 } | 2050 } |
| 2043 | 2051 |
| 2044 Error SpdySession::GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, | 2052 Error SpdySession::GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 2045 std::vector<uint8_t>* out) { | 2053 std::vector<uint8_t>* out) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 } | 2180 } |
| 2173 | 2181 |
| 2174 void SpdySession::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { | 2182 void SpdySession::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { |
| 2175 LOG(FATAL); | 2183 LOG(FATAL); |
| 2176 } | 2184 } |
| 2177 | 2185 |
| 2178 void SpdySession::OnSettings(bool clear_persisted) { | 2186 void SpdySession::OnSettings(bool clear_persisted) { |
| 2179 CHECK(in_io_loop_); | 2187 CHECK(in_io_loop_); |
| 2180 | 2188 |
| 2181 if (clear_persisted) | 2189 if (clear_persisted) |
| 2182 http_server_properties_->ClearSpdySettings(host_port_pair()); | 2190 http_server_properties_->ClearSpdySettings(GetSpdyServer()); |
| 2183 | 2191 |
| 2184 if (net_log_.IsCapturing()) { | 2192 if (net_log_.IsCapturing()) { |
| 2185 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, | 2193 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, |
| 2186 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), | 2194 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), |
| 2187 clear_persisted)); | 2195 clear_persisted)); |
| 2188 } | 2196 } |
| 2189 | 2197 |
| 2190 if (GetProtocolVersion() >= HTTP2) { | 2198 if (GetProtocolVersion() >= HTTP2) { |
| 2191 // Send an acknowledgment of the setting. | 2199 // Send an acknowledgment of the setting. |
| 2192 SpdySettingsIR settings_ir; | 2200 SpdySettingsIR settings_ir; |
| 2193 settings_ir.set_is_ack(true); | 2201 settings_ir.set_is_ack(true); |
| 2194 EnqueueSessionWrite( | 2202 EnqueueSessionWrite( |
| 2195 HIGHEST, | 2203 HIGHEST, |
| 2196 SETTINGS, | 2204 SETTINGS, |
| 2197 scoped_ptr<SpdyFrame>( | 2205 scoped_ptr<SpdyFrame>( |
| 2198 buffered_spdy_framer_->SerializeFrame(settings_ir))); | 2206 buffered_spdy_framer_->SerializeFrame(settings_ir))); |
| 2199 } | 2207 } |
| 2200 } | 2208 } |
| 2201 | 2209 |
| 2202 void SpdySession::OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) { | 2210 void SpdySession::OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) { |
| 2203 CHECK(in_io_loop_); | 2211 CHECK(in_io_loop_); |
| 2204 | 2212 |
| 2205 HandleSetting(id, value); | 2213 HandleSetting(id, value); |
| 2206 http_server_properties_->SetSpdySetting( | 2214 http_server_properties_->SetSpdySetting( |
| 2207 host_port_pair(), | 2215 GetSpdyServer(), |
| 2208 id, | 2216 id, |
| 2209 static_cast<SpdySettingsFlags>(flags), | 2217 static_cast<SpdySettingsFlags>(flags), |
| 2210 value); | 2218 value); |
| 2211 received_settings_ = true; | 2219 received_settings_ = true; |
| 2212 | 2220 |
| 2213 // Log the setting. | 2221 // Log the setting. |
| 2214 const SpdyMajorVersion protocol_version = GetProtocolVersion(); | 2222 const SpdyMajorVersion protocol_version = GetProtocolVersion(); |
| 2215 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTING, | 2223 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTING, |
| 2216 base::Bind(&NetLogSpdySettingCallback, id, protocol_version, | 2224 base::Bind(&NetLogSpdySettingCallback, id, protocol_version, |
| 2217 static_cast<SpdySettingsFlags>(flags), value)); | 2225 static_cast<SpdySettingsFlags>(flags), value)); |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2863 if (session_max_recv_window_size_ > session_recv_window_size_) { | 2871 if (session_max_recv_window_size_ > session_recv_window_size_) { |
| 2864 IncreaseRecvWindowSize(session_max_recv_window_size_ - | 2872 IncreaseRecvWindowSize(session_max_recv_window_size_ - |
| 2865 session_recv_window_size_); | 2873 session_recv_window_size_); |
| 2866 } | 2874 } |
| 2867 | 2875 |
| 2868 if (protocol_ == kProtoSPDY31) { | 2876 if (protocol_ == kProtoSPDY31) { |
| 2869 // Finally, notify the server about the settings they have | 2877 // Finally, notify the server about the settings they have |
| 2870 // previously told us to use when communicating with them (after | 2878 // previously told us to use when communicating with them (after |
| 2871 // applying them). | 2879 // applying them). |
| 2872 const SettingsMap& server_settings_map = | 2880 const SettingsMap& server_settings_map = |
| 2873 http_server_properties_->GetSpdySettings(host_port_pair()); | 2881 http_server_properties_->GetSpdySettings(GetSpdyServer()); |
| 2874 if (server_settings_map.empty()) | 2882 if (server_settings_map.empty()) |
| 2875 return; | 2883 return; |
| 2876 | 2884 |
| 2877 SettingsMap::const_iterator it = | 2885 SettingsMap::const_iterator it = |
| 2878 server_settings_map.find(SETTINGS_CURRENT_CWND); | 2886 server_settings_map.find(SETTINGS_CURRENT_CWND); |
| 2879 uint32_t cwnd = (it != server_settings_map.end()) ? it->second.second : 0; | 2887 uint32_t cwnd = (it != server_settings_map.end()) ? it->second.second : 0; |
| 2880 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); | 2888 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); |
| 2881 | 2889 |
| 2882 for (SettingsMap::const_iterator it = server_settings_map.begin(); | 2890 for (SettingsMap::const_iterator it = server_settings_map.begin(); |
| 2883 it != server_settings_map.end(); ++it) { | 2891 it != server_settings_map.end(); ++it) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 received_settings_ ? 1 : 0, 2); | 3078 received_settings_ ? 1 : 0, 2); |
| 3071 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamStallsPerSession", | 3079 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamStallsPerSession", |
| 3072 stalled_streams_, | 3080 stalled_streams_, |
| 3073 0, 300, 50); | 3081 0, 300, 50); |
| 3074 UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionsWithStalls", | 3082 UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionsWithStalls", |
| 3075 stalled_streams_ > 0 ? 1 : 0, 2); | 3083 stalled_streams_ > 0 ? 1 : 0, 2); |
| 3076 | 3084 |
| 3077 if (received_settings_) { | 3085 if (received_settings_) { |
| 3078 // Enumerate the saved settings, and set histograms for it. | 3086 // Enumerate the saved settings, and set histograms for it. |
| 3079 const SettingsMap& settings_map = | 3087 const SettingsMap& settings_map = |
| 3080 http_server_properties_->GetSpdySettings(host_port_pair()); | 3088 http_server_properties_->GetSpdySettings(GetSpdyServer()); |
| 3081 | 3089 |
| 3082 SettingsMap::const_iterator it; | 3090 SettingsMap::const_iterator it; |
| 3083 for (it = settings_map.begin(); it != settings_map.end(); ++it) { | 3091 for (it = settings_map.begin(); it != settings_map.end(); ++it) { |
| 3084 const SpdySettingsIds id = it->first; | 3092 const SpdySettingsIds id = it->first; |
| 3085 const uint32_t val = it->second.second; | 3093 const uint32_t val = it->second.second; |
| 3086 switch (id) { | 3094 switch (id) { |
| 3087 case SETTINGS_CURRENT_CWND: | 3095 case SETTINGS_CURRENT_CWND: |
| 3088 // Record several different histograms to see if cwnd converges | 3096 // Record several different histograms to see if cwnd converges |
| 3089 // for larger volumes of data being sent. | 3097 // for larger volumes of data being sent. |
| 3090 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", | 3098 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3308 if (!queue->empty()) { | 3316 if (!queue->empty()) { |
| 3309 SpdyStreamId stream_id = queue->front(); | 3317 SpdyStreamId stream_id = queue->front(); |
| 3310 queue->pop_front(); | 3318 queue->pop_front(); |
| 3311 return stream_id; | 3319 return stream_id; |
| 3312 } | 3320 } |
| 3313 } | 3321 } |
| 3314 return 0; | 3322 return 0; |
| 3315 } | 3323 } |
| 3316 | 3324 |
| 3317 } // namespace net | 3325 } // namespace net |
| OLD | NEW |