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