| 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 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 NOTREACHED(); | 2038 NOTREACHED(); |
| 2039 return base::WeakPtr<SpdyStream>(); | 2039 return base::WeakPtr<SpdyStream>(); |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ADOPTED_PUSH_STREAM, | 2042 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ADOPTED_PUSH_STREAM, |
| 2043 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, | 2043 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, |
| 2044 active_it->second.stream->stream_id(), &url)); | 2044 active_it->second.stream->stream_id(), &url)); |
| 2045 return active_it->second.stream->GetWeakPtr(); | 2045 return active_it->second.stream->GetWeakPtr(); |
| 2046 } | 2046 } |
| 2047 | 2047 |
| 2048 url::SchemeHostPort SpdySession::GetServer() { |
| 2049 return url::SchemeHostPort(is_secure_ ? "https" : "http", |
| 2050 host_port_pair().host(), |
| 2051 host_port_pair().port()); |
| 2052 } |
| 2053 |
| 2048 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, | 2054 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, |
| 2049 bool* was_npn_negotiated, | 2055 bool* was_npn_negotiated, |
| 2050 NextProto* protocol_negotiated) { | 2056 NextProto* protocol_negotiated) { |
| 2051 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); | 2057 *was_npn_negotiated = connection_->socket()->WasNpnNegotiated(); |
| 2052 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); | 2058 *protocol_negotiated = connection_->socket()->GetNegotiatedProtocol(); |
| 2053 return connection_->socket()->GetSSLInfo(ssl_info); | 2059 return connection_->socket()->GetSSLInfo(ssl_info); |
| 2054 } | 2060 } |
| 2055 | 2061 |
| 2056 Error SpdySession::GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, | 2062 Error SpdySession::GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 2057 std::vector<uint8_t>* out) { | 2063 std::vector<uint8_t>* out) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 } | 2190 } |
| 2185 | 2191 |
| 2186 void SpdySession::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { | 2192 void SpdySession::OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) { |
| 2187 LOG(FATAL); | 2193 LOG(FATAL); |
| 2188 } | 2194 } |
| 2189 | 2195 |
| 2190 void SpdySession::OnSettings(bool clear_persisted) { | 2196 void SpdySession::OnSettings(bool clear_persisted) { |
| 2191 CHECK(in_io_loop_); | 2197 CHECK(in_io_loop_); |
| 2192 | 2198 |
| 2193 if (clear_persisted) | 2199 if (clear_persisted) |
| 2194 http_server_properties_->ClearSpdySettings(host_port_pair()); | 2200 http_server_properties_->ClearSpdySettings(GetServer()); |
| 2195 | 2201 |
| 2196 if (net_log_.IsCapturing()) { | 2202 if (net_log_.IsCapturing()) { |
| 2197 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, | 2203 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, |
| 2198 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), | 2204 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), |
| 2199 clear_persisted)); | 2205 clear_persisted)); |
| 2200 } | 2206 } |
| 2201 | 2207 |
| 2202 if (GetProtocolVersion() >= HTTP2) { | 2208 if (GetProtocolVersion() >= HTTP2) { |
| 2203 // Send an acknowledgment of the setting. | 2209 // Send an acknowledgment of the setting. |
| 2204 SpdySettingsIR settings_ir; | 2210 SpdySettingsIR settings_ir; |
| 2205 settings_ir.set_is_ack(true); | 2211 settings_ir.set_is_ack(true); |
| 2206 EnqueueSessionWrite( | 2212 EnqueueSessionWrite( |
| 2207 HIGHEST, SETTINGS, | 2213 HIGHEST, SETTINGS, |
| 2208 std::unique_ptr<SpdySerializedFrame>(new SpdySerializedFrame( | 2214 std::unique_ptr<SpdySerializedFrame>(new SpdySerializedFrame( |
| 2209 buffered_spdy_framer_->SerializeFrame(settings_ir)))); | 2215 buffered_spdy_framer_->SerializeFrame(settings_ir)))); |
| 2210 } | 2216 } |
| 2211 } | 2217 } |
| 2212 | 2218 |
| 2213 void SpdySession::OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) { | 2219 void SpdySession::OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) { |
| 2214 CHECK(in_io_loop_); | 2220 CHECK(in_io_loop_); |
| 2215 | 2221 |
| 2216 HandleSetting(id, value); | 2222 HandleSetting(id, value); |
| 2217 http_server_properties_->SetSpdySetting( | 2223 http_server_properties_->SetSpdySetting( |
| 2218 host_port_pair(), | 2224 GetServer(), |
| 2219 id, | 2225 id, |
| 2220 static_cast<SpdySettingsFlags>(flags), | 2226 static_cast<SpdySettingsFlags>(flags), |
| 2221 value); | 2227 value); |
| 2222 received_settings_ = true; | 2228 received_settings_ = true; |
| 2223 | 2229 |
| 2224 // Log the setting. | 2230 // Log the setting. |
| 2225 const SpdyMajorVersion protocol_version = GetProtocolVersion(); | 2231 const SpdyMajorVersion protocol_version = GetProtocolVersion(); |
| 2226 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTING, | 2232 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTING, |
| 2227 base::Bind(&NetLogSpdySettingCallback, id, protocol_version, | 2233 base::Bind(&NetLogSpdySettingCallback, id, protocol_version, |
| 2228 static_cast<SpdySettingsFlags>(flags), value)); | 2234 static_cast<SpdySettingsFlags>(flags), value)); |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2874 if (session_max_recv_window_size_ > session_recv_window_size_) { | 2880 if (session_max_recv_window_size_ > session_recv_window_size_) { |
| 2875 IncreaseRecvWindowSize(session_max_recv_window_size_ - | 2881 IncreaseRecvWindowSize(session_max_recv_window_size_ - |
| 2876 session_recv_window_size_); | 2882 session_recv_window_size_); |
| 2877 } | 2883 } |
| 2878 | 2884 |
| 2879 if (protocol_ == kProtoSPDY31) { | 2885 if (protocol_ == kProtoSPDY31) { |
| 2880 // Finally, notify the server about the settings they have | 2886 // Finally, notify the server about the settings they have |
| 2881 // previously told us to use when communicating with them (after | 2887 // previously told us to use when communicating with them (after |
| 2882 // applying them). | 2888 // applying them). |
| 2883 const SettingsMap& server_settings_map = | 2889 const SettingsMap& server_settings_map = |
| 2884 http_server_properties_->GetSpdySettings(host_port_pair()); | 2890 http_server_properties_->GetSpdySettings(GetServer()); |
| 2885 if (server_settings_map.empty()) | 2891 if (server_settings_map.empty()) |
| 2886 return; | 2892 return; |
| 2887 | 2893 |
| 2888 SettingsMap::const_iterator it = | 2894 SettingsMap::const_iterator it = |
| 2889 server_settings_map.find(SETTINGS_CURRENT_CWND); | 2895 server_settings_map.find(SETTINGS_CURRENT_CWND); |
| 2890 uint32_t cwnd = (it != server_settings_map.end()) ? it->second.second : 0; | 2896 uint32_t cwnd = (it != server_settings_map.end()) ? it->second.second : 0; |
| 2891 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); | 2897 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); |
| 2892 | 2898 |
| 2893 for (SettingsMap::const_iterator it = server_settings_map.begin(); | 2899 for (SettingsMap::const_iterator it = server_settings_map.begin(); |
| 2894 it != server_settings_map.end(); ++it) { | 2900 it != server_settings_map.end(); ++it) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3081 received_settings_ ? 1 : 0, 2); | 3087 received_settings_ ? 1 : 0, 2); |
| 3082 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamStallsPerSession", | 3088 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamStallsPerSession", |
| 3083 stalled_streams_, | 3089 stalled_streams_, |
| 3084 0, 300, 50); | 3090 0, 300, 50); |
| 3085 UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionsWithStalls", | 3091 UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionsWithStalls", |
| 3086 stalled_streams_ > 0 ? 1 : 0, 2); | 3092 stalled_streams_ > 0 ? 1 : 0, 2); |
| 3087 | 3093 |
| 3088 if (received_settings_) { | 3094 if (received_settings_) { |
| 3089 // Enumerate the saved settings, and set histograms for it. | 3095 // Enumerate the saved settings, and set histograms for it. |
| 3090 const SettingsMap& settings_map = | 3096 const SettingsMap& settings_map = |
| 3091 http_server_properties_->GetSpdySettings(host_port_pair()); | 3097 http_server_properties_->GetSpdySettings(GetServer()); |
| 3092 | 3098 |
| 3093 SettingsMap::const_iterator it; | 3099 SettingsMap::const_iterator it; |
| 3094 for (it = settings_map.begin(); it != settings_map.end(); ++it) { | 3100 for (it = settings_map.begin(); it != settings_map.end(); ++it) { |
| 3095 const SpdySettingsIds id = it->first; | 3101 const SpdySettingsIds id = it->first; |
| 3096 const uint32_t val = it->second.second; | 3102 const uint32_t val = it->second.second; |
| 3097 switch (id) { | 3103 switch (id) { |
| 3098 case SETTINGS_CURRENT_CWND: | 3104 case SETTINGS_CURRENT_CWND: |
| 3099 // Record several different histograms to see if cwnd converges | 3105 // Record several different histograms to see if cwnd converges |
| 3100 // for larger volumes of data being sent. | 3106 // for larger volumes of data being sent. |
| 3101 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", | 3107 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3319 if (!queue->empty()) { | 3325 if (!queue->empty()) { |
| 3320 SpdyStreamId stream_id = queue->front(); | 3326 SpdyStreamId stream_id = queue->front(); |
| 3321 queue->pop_front(); | 3327 queue->pop_front(); |
| 3322 return stream_id; | 3328 return stream_id; |
| 3323 } | 3329 } |
| 3324 } | 3330 } |
| 3325 return 0; | 3331 return 0; |
| 3326 } | 3332 } |
| 3327 | 3333 |
| 3328 } // namespace net | 3334 } // namespace net |
| OLD | NEW |