| 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 <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "net/base/connection_type_histograms.h" | 28 #include "net/base/connection_type_histograms.h" |
| 29 #include "net/base/net_log.h" | 29 #include "net/base/net_log.h" |
| 30 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
| 31 #include "net/cert/asn1_util.h" | 31 #include "net/cert/asn1_util.h" |
| 32 #include "net/cert/cert_verify_result.h" | 32 #include "net/cert/cert_verify_result.h" |
| 33 #include "net/http/http_log_util.h" | 33 #include "net/http/http_log_util.h" |
| 34 #include "net/http/http_network_session.h" | 34 #include "net/http/http_network_session.h" |
| 35 #include "net/http/http_server_properties.h" | 35 #include "net/http/http_server_properties.h" |
| 36 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
| 37 #include "net/http/transport_security_state.h" | 37 #include "net/http/transport_security_state.h" |
| 38 #include "net/socket/ssl_client_socket.h" |
| 38 #include "net/spdy/spdy_buffer_producer.h" | 39 #include "net/spdy/spdy_buffer_producer.h" |
| 39 #include "net/spdy/spdy_frame_builder.h" | 40 #include "net/spdy/spdy_frame_builder.h" |
| 40 #include "net/spdy/spdy_http_utils.h" | 41 #include "net/spdy/spdy_http_utils.h" |
| 41 #include "net/spdy/spdy_protocol.h" | 42 #include "net/spdy/spdy_protocol.h" |
| 42 #include "net/spdy/spdy_session_pool.h" | 43 #include "net/spdy/spdy_session_pool.h" |
| 43 #include "net/spdy/spdy_stream.h" | 44 #include "net/spdy/spdy_stream.h" |
| 44 #include "net/ssl/channel_id_service.h" | 45 #include "net/ssl/channel_id_service.h" |
| 45 #include "net/ssl/ssl_cipher_suite_names.h" | 46 #include "net/ssl/ssl_cipher_suite_names.h" |
| 46 #include "net/ssl/ssl_connection_status_flags.h" | 47 #include "net/ssl/ssl_connection_status_flags.h" |
| 47 | 48 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 128 } |
| 128 | 129 |
| 129 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair, | 130 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair, |
| 130 NetLog::LogLevel /* log_level */) { | 131 NetLog::LogLevel /* log_level */) { |
| 131 base::DictionaryValue* dict = new base::DictionaryValue(); | 132 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 132 dict->SetString("host", host_pair->first.ToString()); | 133 dict->SetString("host", host_pair->first.ToString()); |
| 133 dict->SetString("proxy", host_pair->second.ToPacString()); | 134 dict->SetString("proxy", host_pair->second.ToPacString()); |
| 134 return dict; | 135 return dict; |
| 135 } | 136 } |
| 136 | 137 |
| 138 base::Value* NetLogSpdyInitializedCallback(NetLog::Source source, |
| 139 const NextProto protocol_version, |
| 140 NetLog::LogLevel /* log_level */) { |
| 141 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 142 if (source.IsValid()) { |
| 143 source.AddToEventParameters(dict); |
| 144 } |
| 145 dict->SetString("protocol", |
| 146 SSLClientSocket::NextProtoToString(protocol_version)); |
| 147 return dict; |
| 148 } |
| 149 |
| 137 base::Value* NetLogSpdySettingsCallback(const HostPortPair& host_port_pair, | 150 base::Value* NetLogSpdySettingsCallback(const HostPortPair& host_port_pair, |
| 138 bool clear_persisted, | 151 bool clear_persisted, |
| 139 NetLog::LogLevel /* log_level */) { | 152 NetLog::LogLevel /* log_level */) { |
| 140 base::DictionaryValue* dict = new base::DictionaryValue(); | 153 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 141 dict->SetString("host", host_port_pair.ToString()); | 154 dict->SetString("host", host_port_pair.ToString()); |
| 142 dict->SetBoolean("clear_persisted", clear_persisted); | 155 dict->SetBoolean("clear_persisted", clear_persisted); |
| 143 return dict; | 156 return dict; |
| 144 } | 157 } |
| 145 | 158 |
| 146 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id, | 159 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id, |
| 160 const SpdyMajorVersion protocol_version, |
| 147 SpdySettingsFlags flags, | 161 SpdySettingsFlags flags, |
| 148 uint32 value, | 162 uint32 value, |
| 149 NetLog::LogLevel /* log_level */) { | 163 NetLog::LogLevel /* log_level */) { |
| 150 base::DictionaryValue* dict = new base::DictionaryValue(); | 164 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 151 dict->SetInteger("id", id); | 165 dict->SetInteger("id", |
| 166 SpdyConstants::SerializeSettingId(protocol_version, id)); |
| 152 dict->SetInteger("flags", flags); | 167 dict->SetInteger("flags", flags); |
| 153 dict->SetInteger("value", value); | 168 dict->SetInteger("value", value); |
| 154 return dict; | 169 return dict; |
| 155 } | 170 } |
| 156 | 171 |
| 157 base::Value* NetLogSpdySendSettingsCallback(const SettingsMap* settings, | 172 base::Value* NetLogSpdySendSettingsCallback( |
| 158 NetLog::LogLevel /* log_level */) { | 173 const SettingsMap* settings, |
| 174 const SpdyMajorVersion protocol_version, |
| 175 NetLog::LogLevel /* log_level */) { |
| 159 base::DictionaryValue* dict = new base::DictionaryValue(); | 176 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 160 base::ListValue* settings_list = new base::ListValue(); | 177 base::ListValue* settings_list = new base::ListValue(); |
| 161 for (SettingsMap::const_iterator it = settings->begin(); | 178 for (SettingsMap::const_iterator it = settings->begin(); |
| 162 it != settings->end(); ++it) { | 179 it != settings->end(); ++it) { |
| 163 const SpdySettingsIds id = it->first; | 180 const SpdySettingsIds id = it->first; |
| 164 const SpdySettingsFlags flags = it->second.first; | 181 const SpdySettingsFlags flags = it->second.first; |
| 165 const uint32 value = it->second.second; | 182 const uint32 value = it->second.second; |
| 166 settings_list->Append(new base::StringValue( | 183 settings_list->Append(new base::StringValue(base::StringPrintf( |
| 167 base::StringPrintf("[id:%u flags:%u value:%u]", id, flags, value))); | 184 "[id:%u flags:%u value:%u]", |
| 185 SpdyConstants::SerializeSettingId(protocol_version, id), |
| 186 flags, |
| 187 value))); |
| 168 } | 188 } |
| 169 dict->Set("settings", settings_list); | 189 dict->Set("settings", settings_list); |
| 170 return dict; | 190 return dict; |
| 171 } | 191 } |
| 172 | 192 |
| 173 base::Value* NetLogSpdyWindowUpdateFrameCallback( | 193 base::Value* NetLogSpdyWindowUpdateFrameCallback( |
| 174 SpdyStreamId stream_id, | 194 SpdyStreamId stream_id, |
| 175 uint32 delta, | 195 uint32 delta, |
| 176 NetLog::LogLevel /* log_level */) { | 196 NetLog::LogLevel /* log_level */) { |
| 177 base::DictionaryValue* dict = new base::DictionaryValue(); | 197 base::DictionaryValue* dict = new base::DictionaryValue(); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 enable_compression_)); | 739 enable_compression_)); |
| 720 buffered_spdy_framer_->set_visitor(this); | 740 buffered_spdy_framer_->set_visitor(this); |
| 721 buffered_spdy_framer_->set_debug_visitor(this); | 741 buffered_spdy_framer_->set_debug_visitor(this); |
| 722 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol_, kProtoMaximumVersion); | 742 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol_, kProtoMaximumVersion); |
| 723 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 743 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 724 UMA_HISTOGRAM_BOOLEAN("Net.SpdySessions_DataReductionProxy", | 744 UMA_HISTOGRAM_BOOLEAN("Net.SpdySessions_DataReductionProxy", |
| 725 host_port_pair().Equals(HostPortPair::FromURL( | 745 host_port_pair().Equals(HostPortPair::FromURL( |
| 726 GURL(SPDY_PROXY_AUTH_ORIGIN)))); | 746 GURL(SPDY_PROXY_AUTH_ORIGIN)))); |
| 727 #endif | 747 #endif |
| 728 | 748 |
| 729 net_log_.AddEvent( | 749 net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_INITIALIZED, |
| 730 NetLog::TYPE_SPDY_SESSION_INITIALIZED, | 750 base::Bind(&NetLogSpdyInitializedCallback, |
| 731 connection_->socket()->NetLog().source().ToEventParametersCallback()); | 751 connection_->socket()->NetLog().source(), |
| 752 protocol_)); |
| 732 | 753 |
| 733 DCHECK_EQ(availability_state_, STATE_AVAILABLE); | 754 DCHECK_EQ(availability_state_, STATE_AVAILABLE); |
| 734 connection_->AddHigherLayeredPool(this); | 755 connection_->AddHigherLayeredPool(this); |
| 735 if (enable_sending_initial_data_) | 756 if (enable_sending_initial_data_) |
| 736 SendInitialData(); | 757 SendInitialData(); |
| 737 pool_ = pool; | 758 pool_ = pool; |
| 738 | 759 |
| 739 // Bootstrap the read loop. | 760 // Bootstrap the read loop. |
| 740 base::MessageLoop::current()->PostTask( | 761 base::MessageLoop::current()->PostTask( |
| 741 FROM_HERE, | 762 FROM_HERE, |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 | 2116 |
| 2096 HandleSetting(id, value); | 2117 HandleSetting(id, value); |
| 2097 http_server_properties_->SetSpdySetting( | 2118 http_server_properties_->SetSpdySetting( |
| 2098 host_port_pair(), | 2119 host_port_pair(), |
| 2099 id, | 2120 id, |
| 2100 static_cast<SpdySettingsFlags>(flags), | 2121 static_cast<SpdySettingsFlags>(flags), |
| 2101 value); | 2122 value); |
| 2102 received_settings_ = true; | 2123 received_settings_ = true; |
| 2103 | 2124 |
| 2104 // Log the setting. | 2125 // Log the setting. |
| 2105 net_log_.AddEvent( | 2126 const SpdyMajorVersion protocol_version = GetProtocolVersion(); |
| 2106 NetLog::TYPE_SPDY_SESSION_RECV_SETTING, | 2127 net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_RECV_SETTING, |
| 2107 base::Bind(&NetLogSpdySettingCallback, | 2128 base::Bind(&NetLogSpdySettingCallback, |
| 2108 id, static_cast<SpdySettingsFlags>(flags), value)); | 2129 id, |
| 2130 protocol_version, |
| 2131 static_cast<SpdySettingsFlags>(flags), |
| 2132 value)); |
| 2109 } | 2133 } |
| 2110 | 2134 |
| 2111 void SpdySession::OnSendCompressedFrame( | 2135 void SpdySession::OnSendCompressedFrame( |
| 2112 SpdyStreamId stream_id, | 2136 SpdyStreamId stream_id, |
| 2113 SpdyFrameType type, | 2137 SpdyFrameType type, |
| 2114 size_t payload_len, | 2138 size_t payload_len, |
| 2115 size_t frame_len) { | 2139 size_t frame_len) { |
| 2116 if (type != SYN_STREAM && type != HEADERS) | 2140 if (type != SYN_STREAM && type != HEADERS) |
| 2117 return; | 2141 return; |
| 2118 | 2142 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 const uint32 new_val = it->second.second; | 2801 const uint32 new_val = it->second.second; |
| 2778 HandleSetting(new_id, new_val); | 2802 HandleSetting(new_id, new_val); |
| 2779 } | 2803 } |
| 2780 | 2804 |
| 2781 SendSettings(server_settings_map); | 2805 SendSettings(server_settings_map); |
| 2782 } | 2806 } |
| 2783 } | 2807 } |
| 2784 | 2808 |
| 2785 | 2809 |
| 2786 void SpdySession::SendSettings(const SettingsMap& settings) { | 2810 void SpdySession::SendSettings(const SettingsMap& settings) { |
| 2811 const SpdyMajorVersion protocol_version = GetProtocolVersion(); |
| 2787 net_log_.AddEvent( | 2812 net_log_.AddEvent( |
| 2788 NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, | 2813 NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, |
| 2789 base::Bind(&NetLogSpdySendSettingsCallback, &settings)); | 2814 base::Bind(&NetLogSpdySendSettingsCallback, &settings, protocol_version)); |
| 2790 | |
| 2791 // Create the SETTINGS frame and send it. | 2815 // Create the SETTINGS frame and send it. |
| 2792 DCHECK(buffered_spdy_framer_.get()); | 2816 DCHECK(buffered_spdy_framer_.get()); |
| 2793 scoped_ptr<SpdyFrame> settings_frame( | 2817 scoped_ptr<SpdyFrame> settings_frame( |
| 2794 buffered_spdy_framer_->CreateSettings(settings)); | 2818 buffered_spdy_framer_->CreateSettings(settings)); |
| 2795 sent_settings_ = true; | 2819 sent_settings_ = true; |
| 2796 EnqueueSessionWrite(HIGHEST, SETTINGS, settings_frame.Pass()); | 2820 EnqueueSessionWrite(HIGHEST, SETTINGS, settings_frame.Pass()); |
| 2797 } | 2821 } |
| 2798 | 2822 |
| 2799 void SpdySession::HandleSetting(uint32 id, uint32 value) { | 2823 void SpdySession::HandleSetting(uint32 id, uint32 value) { |
| 2800 switch (id) { | 2824 switch (id) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3231 if (!queue->empty()) { | 3255 if (!queue->empty()) { |
| 3232 SpdyStreamId stream_id = queue->front(); | 3256 SpdyStreamId stream_id = queue->front(); |
| 3233 queue->pop_front(); | 3257 queue->pop_front(); |
| 3234 return stream_id; | 3258 return stream_id; |
| 3235 } | 3259 } |
| 3236 } | 3260 } |
| 3237 return 0; | 3261 return 0; |
| 3238 } | 3262 } |
| 3239 | 3263 |
| 3240 } // namespace net | 3264 } // namespace net |
| OLD | NEW |