Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1379)

Side by Side Diff: net/spdy/spdy_session.cc

Issue 1059843002: Refactor NetLog::LogLevel --> NetLogCaptureMode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update copyright Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 const int kReadBufferSize = 8 * 1024; 53 const int kReadBufferSize = 8 * 1024;
54 const int kDefaultConnectionAtRiskOfLossSeconds = 10; 54 const int kDefaultConnectionAtRiskOfLossSeconds = 10;
55 const int kHungIntervalSeconds = 10; 55 const int kHungIntervalSeconds = 10;
56 56
57 // Minimum seconds that unclaimed pushed streams will be kept in memory. 57 // Minimum seconds that unclaimed pushed streams will be kept in memory.
58 const int kMinPushedStreamLifetimeSeconds = 300; 58 const int kMinPushedStreamLifetimeSeconds = 300;
59 59
60 scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue( 60 scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue(
61 const SpdyHeaderBlock& headers, 61 const SpdyHeaderBlock& headers,
62 net::NetLog::LogLevel log_level) { 62 net::NetLogCaptureMode capture_mode) {
63 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); 63 scoped_ptr<base::ListValue> headers_list(new base::ListValue());
64 for (SpdyHeaderBlock::const_iterator it = headers.begin(); 64 for (SpdyHeaderBlock::const_iterator it = headers.begin();
65 it != headers.end(); ++it) { 65 it != headers.end(); ++it) {
66 headers_list->AppendString( 66 headers_list->AppendString(
67 it->first + ": " + 67 it->first + ": " +
68 ElideHeaderValueForNetLog(log_level, it->first, it->second)); 68 ElideHeaderValueForNetLog(capture_mode, it->first, it->second));
69 } 69 }
70 return headers_list.Pass(); 70 return headers_list.Pass();
71 } 71 }
72 72
73 base::Value* NetLogSpdySynStreamSentCallback(const SpdyHeaderBlock* headers, 73 base::Value* NetLogSpdySynStreamSentCallback(const SpdyHeaderBlock* headers,
74 bool fin, 74 bool fin,
75 bool unidirectional, 75 bool unidirectional,
76 SpdyPriority spdy_priority, 76 SpdyPriority spdy_priority,
77 SpdyStreamId stream_id, 77 SpdyStreamId stream_id,
78 NetLog::LogLevel log_level) { 78 NetLogCaptureMode capture_mode) {
79 base::DictionaryValue* dict = new base::DictionaryValue(); 79 base::DictionaryValue* dict = new base::DictionaryValue();
80 dict->Set("headers", 80 dict->Set("headers",
81 SpdyHeaderBlockToListValue(*headers, log_level).release()); 81 SpdyHeaderBlockToListValue(*headers, capture_mode).release());
82 dict->SetBoolean("fin", fin); 82 dict->SetBoolean("fin", fin);
83 dict->SetBoolean("unidirectional", unidirectional); 83 dict->SetBoolean("unidirectional", unidirectional);
84 dict->SetInteger("priority", static_cast<int>(spdy_priority)); 84 dict->SetInteger("priority", static_cast<int>(spdy_priority));
85 dict->SetInteger("stream_id", stream_id); 85 dict->SetInteger("stream_id", stream_id);
86 return dict; 86 return dict;
87 } 87 }
88 88
89 base::Value* NetLogSpdySynStreamReceivedCallback( 89 base::Value* NetLogSpdySynStreamReceivedCallback(
90 const SpdyHeaderBlock* headers, 90 const SpdyHeaderBlock* headers,
91 bool fin, 91 bool fin,
92 bool unidirectional, 92 bool unidirectional,
93 SpdyPriority spdy_priority, 93 SpdyPriority spdy_priority,
94 SpdyStreamId stream_id, 94 SpdyStreamId stream_id,
95 SpdyStreamId associated_stream, 95 SpdyStreamId associated_stream,
96 NetLog::LogLevel log_level) { 96 NetLogCaptureMode capture_mode) {
97 base::DictionaryValue* dict = new base::DictionaryValue(); 97 base::DictionaryValue* dict = new base::DictionaryValue();
98 dict->Set("headers", 98 dict->Set("headers",
99 SpdyHeaderBlockToListValue(*headers, log_level).release()); 99 SpdyHeaderBlockToListValue(*headers, capture_mode).release());
100 dict->SetBoolean("fin", fin); 100 dict->SetBoolean("fin", fin);
101 dict->SetBoolean("unidirectional", unidirectional); 101 dict->SetBoolean("unidirectional", unidirectional);
102 dict->SetInteger("priority", static_cast<int>(spdy_priority)); 102 dict->SetInteger("priority", static_cast<int>(spdy_priority));
103 dict->SetInteger("stream_id", stream_id); 103 dict->SetInteger("stream_id", stream_id);
104 dict->SetInteger("associated_stream", associated_stream); 104 dict->SetInteger("associated_stream", associated_stream);
105 return dict; 105 return dict;
106 } 106 }
107 107
108 base::Value* NetLogSpdySynReplyOrHeadersReceivedCallback( 108 base::Value* NetLogSpdySynReplyOrHeadersReceivedCallback(
109 const SpdyHeaderBlock* headers, 109 const SpdyHeaderBlock* headers,
110 bool fin, 110 bool fin,
111 SpdyStreamId stream_id, 111 SpdyStreamId stream_id,
112 NetLog::LogLevel log_level) { 112 NetLogCaptureMode capture_mode) {
113 base::DictionaryValue* dict = new base::DictionaryValue(); 113 base::DictionaryValue* dict = new base::DictionaryValue();
114 dict->Set("headers", 114 dict->Set("headers",
115 SpdyHeaderBlockToListValue(*headers, log_level).release()); 115 SpdyHeaderBlockToListValue(*headers, capture_mode).release());
116 dict->SetBoolean("fin", fin); 116 dict->SetBoolean("fin", fin);
117 dict->SetInteger("stream_id", stream_id); 117 dict->SetInteger("stream_id", stream_id);
118 return dict; 118 return dict;
119 } 119 }
120 120
121 base::Value* NetLogSpdySessionCloseCallback(int net_error, 121 base::Value* NetLogSpdySessionCloseCallback(
122 const std::string* description, 122 int net_error,
123 NetLog::LogLevel /* log_level */) { 123 const std::string* description,
124 NetLogCaptureMode /* capture_mode */) {
124 base::DictionaryValue* dict = new base::DictionaryValue(); 125 base::DictionaryValue* dict = new base::DictionaryValue();
125 dict->SetInteger("net_error", net_error); 126 dict->SetInteger("net_error", net_error);
126 dict->SetString("description", *description); 127 dict->SetString("description", *description);
127 return dict; 128 return dict;
128 } 129 }
129 130
130 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair, 131 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair,
131 NetLog::LogLevel /* log_level */) { 132 NetLogCaptureMode /* capture_mode */) {
132 base::DictionaryValue* dict = new base::DictionaryValue(); 133 base::DictionaryValue* dict = new base::DictionaryValue();
133 dict->SetString("host", host_pair->first.ToString()); 134 dict->SetString("host", host_pair->first.ToString());
134 dict->SetString("proxy", host_pair->second.ToPacString()); 135 dict->SetString("proxy", host_pair->second.ToPacString());
135 return dict; 136 return dict;
136 } 137 }
137 138
138 base::Value* NetLogSpdyInitializedCallback(NetLog::Source source, 139 base::Value* NetLogSpdyInitializedCallback(
139 const NextProto protocol_version, 140 NetLog::Source source,
140 NetLog::LogLevel /* log_level */) { 141 const NextProto protocol_version,
142 NetLogCaptureMode /* capture_mode */) {
141 base::DictionaryValue* dict = new base::DictionaryValue(); 143 base::DictionaryValue* dict = new base::DictionaryValue();
142 if (source.IsValid()) { 144 if (source.IsValid()) {
143 source.AddToEventParameters(dict); 145 source.AddToEventParameters(dict);
144 } 146 }
145 dict->SetString("protocol", 147 dict->SetString("protocol",
146 SSLClientSocket::NextProtoToString(protocol_version)); 148 SSLClientSocket::NextProtoToString(protocol_version));
147 return dict; 149 return dict;
148 } 150 }
149 151
150 base::Value* NetLogSpdySettingsCallback(const HostPortPair& host_port_pair, 152 base::Value* NetLogSpdySettingsCallback(const HostPortPair& host_port_pair,
151 bool clear_persisted, 153 bool clear_persisted,
152 NetLog::LogLevel /* log_level */) { 154 NetLogCaptureMode /* capture_mode */) {
153 base::DictionaryValue* dict = new base::DictionaryValue(); 155 base::DictionaryValue* dict = new base::DictionaryValue();
154 dict->SetString("host", host_port_pair.ToString()); 156 dict->SetString("host", host_port_pair.ToString());
155 dict->SetBoolean("clear_persisted", clear_persisted); 157 dict->SetBoolean("clear_persisted", clear_persisted);
156 return dict; 158 return dict;
157 } 159 }
158 160
159 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id, 161 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id,
160 const SpdyMajorVersion protocol_version, 162 const SpdyMajorVersion protocol_version,
161 SpdySettingsFlags flags, 163 SpdySettingsFlags flags,
162 uint32 value, 164 uint32 value,
163 NetLog::LogLevel /* log_level */) { 165 NetLogCaptureMode /* capture_mode */) {
164 base::DictionaryValue* dict = new base::DictionaryValue(); 166 base::DictionaryValue* dict = new base::DictionaryValue();
165 dict->SetInteger("id", 167 dict->SetInteger("id",
166 SpdyConstants::SerializeSettingId(protocol_version, id)); 168 SpdyConstants::SerializeSettingId(protocol_version, id));
167 dict->SetInteger("flags", flags); 169 dict->SetInteger("flags", flags);
168 dict->SetInteger("value", value); 170 dict->SetInteger("value", value);
169 return dict; 171 return dict;
170 } 172 }
171 173
172 base::Value* NetLogSpdySendSettingsCallback( 174 base::Value* NetLogSpdySendSettingsCallback(
173 const SettingsMap* settings, 175 const SettingsMap* settings,
174 const SpdyMajorVersion protocol_version, 176 const SpdyMajorVersion protocol_version,
175 NetLog::LogLevel /* log_level */) { 177 NetLogCaptureMode /* capture_mode */) {
176 base::DictionaryValue* dict = new base::DictionaryValue(); 178 base::DictionaryValue* dict = new base::DictionaryValue();
177 base::ListValue* settings_list = new base::ListValue(); 179 base::ListValue* settings_list = new base::ListValue();
178 for (SettingsMap::const_iterator it = settings->begin(); 180 for (SettingsMap::const_iterator it = settings->begin();
179 it != settings->end(); ++it) { 181 it != settings->end(); ++it) {
180 const SpdySettingsIds id = it->first; 182 const SpdySettingsIds id = it->first;
181 const SpdySettingsFlags flags = it->second.first; 183 const SpdySettingsFlags flags = it->second.first;
182 const uint32 value = it->second.second; 184 const uint32 value = it->second.second;
183 settings_list->Append(new base::StringValue(base::StringPrintf( 185 settings_list->Append(new base::StringValue(base::StringPrintf(
184 "[id:%u flags:%u value:%u]", 186 "[id:%u flags:%u value:%u]",
185 SpdyConstants::SerializeSettingId(protocol_version, id), 187 SpdyConstants::SerializeSettingId(protocol_version, id),
186 flags, 188 flags,
187 value))); 189 value)));
188 } 190 }
189 dict->Set("settings", settings_list); 191 dict->Set("settings", settings_list);
190 return dict; 192 return dict;
191 } 193 }
192 194
193 base::Value* NetLogSpdyWindowUpdateFrameCallback( 195 base::Value* NetLogSpdyWindowUpdateFrameCallback(
194 SpdyStreamId stream_id, 196 SpdyStreamId stream_id,
195 uint32 delta, 197 uint32 delta,
196 NetLog::LogLevel /* log_level */) { 198 NetLogCaptureMode /* capture_mode */) {
197 base::DictionaryValue* dict = new base::DictionaryValue(); 199 base::DictionaryValue* dict = new base::DictionaryValue();
198 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 200 dict->SetInteger("stream_id", static_cast<int>(stream_id));
199 dict->SetInteger("delta", delta); 201 dict->SetInteger("delta", delta);
200 return dict; 202 return dict;
201 } 203 }
202 204
203 base::Value* NetLogSpdySessionWindowUpdateCallback( 205 base::Value* NetLogSpdySessionWindowUpdateCallback(
204 int32 delta, 206 int32 delta,
205 int32 window_size, 207 int32 window_size,
206 NetLog::LogLevel /* log_level */) { 208 NetLogCaptureMode /* capture_mode */) {
207 base::DictionaryValue* dict = new base::DictionaryValue(); 209 base::DictionaryValue* dict = new base::DictionaryValue();
208 dict->SetInteger("delta", delta); 210 dict->SetInteger("delta", delta);
209 dict->SetInteger("window_size", window_size); 211 dict->SetInteger("window_size", window_size);
210 return dict; 212 return dict;
211 } 213 }
212 214
213 base::Value* NetLogSpdyDataCallback(SpdyStreamId stream_id, 215 base::Value* NetLogSpdyDataCallback(SpdyStreamId stream_id,
214 int size, 216 int size,
215 bool fin, 217 bool fin,
216 NetLog::LogLevel /* log_level */) { 218 NetLogCaptureMode /* capture_mode */) {
217 base::DictionaryValue* dict = new base::DictionaryValue(); 219 base::DictionaryValue* dict = new base::DictionaryValue();
218 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 220 dict->SetInteger("stream_id", static_cast<int>(stream_id));
219 dict->SetInteger("size", size); 221 dict->SetInteger("size", size);
220 dict->SetBoolean("fin", fin); 222 dict->SetBoolean("fin", fin);
221 return dict; 223 return dict;
222 } 224 }
223 225
224 base::Value* NetLogSpdyRstCallback(SpdyStreamId stream_id, 226 base::Value* NetLogSpdyRstCallback(SpdyStreamId stream_id,
225 int status, 227 int status,
226 const std::string* description, 228 const std::string* description,
227 NetLog::LogLevel /* log_level */) { 229 NetLogCaptureMode /* capture_mode */) {
228 base::DictionaryValue* dict = new base::DictionaryValue(); 230 base::DictionaryValue* dict = new base::DictionaryValue();
229 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 231 dict->SetInteger("stream_id", static_cast<int>(stream_id));
230 dict->SetInteger("status", status); 232 dict->SetInteger("status", status);
231 dict->SetString("description", *description); 233 dict->SetString("description", *description);
232 return dict; 234 return dict;
233 } 235 }
234 236
235 base::Value* NetLogSpdyPingCallback(SpdyPingId unique_id, 237 base::Value* NetLogSpdyPingCallback(SpdyPingId unique_id,
236 bool is_ack, 238 bool is_ack,
237 const char* type, 239 const char* type,
238 NetLog::LogLevel /* log_level */) { 240 NetLogCaptureMode /* capture_mode */) {
239 base::DictionaryValue* dict = new base::DictionaryValue(); 241 base::DictionaryValue* dict = new base::DictionaryValue();
240 dict->SetInteger("unique_id", static_cast<int>(unique_id)); 242 dict->SetInteger("unique_id", static_cast<int>(unique_id));
241 dict->SetString("type", type); 243 dict->SetString("type", type);
242 dict->SetBoolean("is_ack", is_ack); 244 dict->SetBoolean("is_ack", is_ack);
243 return dict; 245 return dict;
244 } 246 }
245 247
246 base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id, 248 base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id,
247 int active_streams, 249 int active_streams,
248 int unclaimed_streams, 250 int unclaimed_streams,
249 SpdyGoAwayStatus status, 251 SpdyGoAwayStatus status,
250 NetLog::LogLevel /* log_level */) { 252 NetLogCaptureMode /* capture_mode */) {
251 base::DictionaryValue* dict = new base::DictionaryValue(); 253 base::DictionaryValue* dict = new base::DictionaryValue();
252 dict->SetInteger("last_accepted_stream_id", 254 dict->SetInteger("last_accepted_stream_id",
253 static_cast<int>(last_stream_id)); 255 static_cast<int>(last_stream_id));
254 dict->SetInteger("active_streams", active_streams); 256 dict->SetInteger("active_streams", active_streams);
255 dict->SetInteger("unclaimed_streams", unclaimed_streams); 257 dict->SetInteger("unclaimed_streams", unclaimed_streams);
256 dict->SetInteger("status", static_cast<int>(status)); 258 dict->SetInteger("status", static_cast<int>(status));
257 return dict; 259 return dict;
258 } 260 }
259 261
260 base::Value* NetLogSpdyPushPromiseReceivedCallback( 262 base::Value* NetLogSpdyPushPromiseReceivedCallback(
261 const SpdyHeaderBlock* headers, 263 const SpdyHeaderBlock* headers,
262 SpdyStreamId stream_id, 264 SpdyStreamId stream_id,
263 SpdyStreamId promised_stream_id, 265 SpdyStreamId promised_stream_id,
264 NetLog::LogLevel log_level) { 266 NetLogCaptureMode capture_mode) {
265 base::DictionaryValue* dict = new base::DictionaryValue(); 267 base::DictionaryValue* dict = new base::DictionaryValue();
266 dict->Set("headers", 268 dict->Set("headers",
267 SpdyHeaderBlockToListValue(*headers, log_level).release()); 269 SpdyHeaderBlockToListValue(*headers, capture_mode).release());
268 dict->SetInteger("id", stream_id); 270 dict->SetInteger("id", stream_id);
269 dict->SetInteger("promised_stream_id", promised_stream_id); 271 dict->SetInteger("promised_stream_id", promised_stream_id);
270 return dict; 272 return dict;
271 } 273 }
272 274
273 base::Value* NetLogSpdyAdoptedPushStreamCallback( 275 base::Value* NetLogSpdyAdoptedPushStreamCallback(
274 SpdyStreamId stream_id, const GURL* url, NetLog::LogLevel log_level) { 276 SpdyStreamId stream_id,
277 const GURL* url,
278 NetLogCaptureMode capture_mode) {
275 base::DictionaryValue* dict = new base::DictionaryValue(); 279 base::DictionaryValue* dict = new base::DictionaryValue();
276 dict->SetInteger("stream_id", stream_id); 280 dict->SetInteger("stream_id", stream_id);
277 dict->SetString("url", url->spec()); 281 dict->SetString("url", url->spec());
278 return dict; 282 return dict;
279 } 283 }
280 284
281 // Helper function to return the total size of an array of objects 285 // Helper function to return the total size of an array of objects
282 // with .size() member functions. 286 // with .size() member functions.
283 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) { 287 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) {
284 size_t total_size = 0; 288 size_t total_size = 0;
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 SpdyHeadersIR headers(stream_id); 1074 SpdyHeadersIR headers(stream_id);
1071 headers.set_priority(spdy_priority); 1075 headers.set_priority(spdy_priority);
1072 headers.set_has_priority(true); 1076 headers.set_has_priority(true);
1073 headers.set_fin((flags & CONTROL_FLAG_FIN) != 0); 1077 headers.set_fin((flags & CONTROL_FLAG_FIN) != 0);
1074 headers.set_name_value_block(block); 1078 headers.set_name_value_block(block);
1075 syn_frame.reset(buffered_spdy_framer_->SerializeFrame(headers)); 1079 syn_frame.reset(buffered_spdy_framer_->SerializeFrame(headers));
1076 } 1080 }
1077 1081
1078 streams_initiated_count_++; 1082 streams_initiated_count_++;
1079 1083
1080 if (net_log().IsLogging()) { 1084 if (net_log().GetCaptureMode().enabled()) {
1081 const NetLog::EventType type = 1085 const NetLog::EventType type =
1082 (GetProtocolVersion() <= SPDY3) 1086 (GetProtocolVersion() <= SPDY3)
1083 ? NetLog::TYPE_HTTP2_SESSION_SYN_STREAM 1087 ? NetLog::TYPE_HTTP2_SESSION_SYN_STREAM
1084 : NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS; 1088 : NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS;
1085 net_log().AddEvent(type, 1089 net_log().AddEvent(type,
1086 base::Bind(&NetLogSpdySynStreamSentCallback, &block, 1090 base::Bind(&NetLogSpdySynStreamSentCallback, &block,
1087 (flags & CONTROL_FLAG_FIN) != 0, 1091 (flags & CONTROL_FLAG_FIN) != 0,
1088 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, 1092 (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0,
1089 spdy_priority, stream_id)); 1093 spdy_priority, stream_id));
1090 } 1094 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 effective_len = std::min(effective_len, session_send_window_size_); 1184 effective_len = std::min(effective_len, session_send_window_size_);
1181 } 1185 }
1182 1186
1183 DCHECK_GE(effective_len, 0); 1187 DCHECK_GE(effective_len, 0);
1184 1188
1185 // Clear FIN flag if only some of the data will be in the data 1189 // Clear FIN flag if only some of the data will be in the data
1186 // frame. 1190 // frame.
1187 if (effective_len < len) 1191 if (effective_len < len)
1188 flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_FIN); 1192 flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_FIN);
1189 1193
1190 if (net_log().IsLogging()) { 1194 if (net_log().GetCaptureMode().enabled()) {
1191 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SEND_DATA, 1195 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SEND_DATA,
1192 base::Bind(&NetLogSpdyDataCallback, stream_id, 1196 base::Bind(&NetLogSpdyDataCallback, stream_id,
1193 effective_len, (flags & DATA_FLAG_FIN) != 0)); 1197 effective_len, (flags & DATA_FLAG_FIN) != 0));
1194 } 1198 }
1195 1199
1196 // Send PrefacePing for DATA_FRAMEs with nonzero payload size. 1200 // Send PrefacePing for DATA_FRAMEs with nonzero payload size.
1197 if (effective_len > 0) 1201 if (effective_len > 0)
1198 SendPrefacePingIfNoneInFlight(); 1202 SendPrefacePingIfNoneInFlight();
1199 1203
1200 // TODO(mbelshe): reduce memory copies here. 1204 // TODO(mbelshe): reduce memory copies here.
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 size_t header_len = buffered_spdy_framer_->GetDataFrameMinimumSize(); 2038 size_t header_len = buffered_spdy_framer_->GetDataFrameMinimumSize();
2035 stream->IncrementRawReceivedBytes(header_len); 2039 stream->IncrementRawReceivedBytes(header_len);
2036 } 2040 }
2037 2041
2038 void SpdySession::OnStreamFrameData(SpdyStreamId stream_id, 2042 void SpdySession::OnStreamFrameData(SpdyStreamId stream_id,
2039 const char* data, 2043 const char* data,
2040 size_t len, 2044 size_t len,
2041 bool fin) { 2045 bool fin) {
2042 CHECK(in_io_loop_); 2046 CHECK(in_io_loop_);
2043 DCHECK_LT(len, 1u << 24); 2047 DCHECK_LT(len, 1u << 24);
2044 if (net_log().IsLogging()) { 2048 if (net_log().GetCaptureMode().enabled()) {
2045 net_log().AddEvent( 2049 net_log().AddEvent(
2046 NetLog::TYPE_HTTP2_SESSION_RECV_DATA, 2050 NetLog::TYPE_HTTP2_SESSION_RECV_DATA,
2047 base::Bind(&NetLogSpdyDataCallback, stream_id, len, fin)); 2051 base::Bind(&NetLogSpdyDataCallback, stream_id, len, fin));
2048 } 2052 }
2049 2053
2050 // Build the buffer as early as possible so that we go through the 2054 // Build the buffer as early as possible so that we go through the
2051 // session flow control checks and update 2055 // session flow control checks and update
2052 // |unacked_recv_window_bytes_| properly even when the stream is 2056 // |unacked_recv_window_bytes_| properly even when the stream is
2053 // inactive (since the other side has still reduced its session send 2057 // inactive (since the other side has still reduced its session send
2054 // window). 2058 // window).
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 return; 2111 return;
2108 it->second.stream->OnPaddingConsumed(len); 2112 it->second.stream->OnPaddingConsumed(len);
2109 } 2113 }
2110 2114
2111 void SpdySession::OnSettings(bool clear_persisted) { 2115 void SpdySession::OnSettings(bool clear_persisted) {
2112 CHECK(in_io_loop_); 2116 CHECK(in_io_loop_);
2113 2117
2114 if (clear_persisted) 2118 if (clear_persisted)
2115 http_server_properties_->ClearSpdySettings(host_port_pair()); 2119 http_server_properties_->ClearSpdySettings(host_port_pair());
2116 2120
2117 if (net_log_.IsLogging()) { 2121 if (net_log_.GetCaptureMode().enabled()) {
2118 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS, 2122 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_SETTINGS,
2119 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), 2123 base::Bind(&NetLogSpdySettingsCallback, host_port_pair(),
2120 clear_persisted)); 2124 clear_persisted));
2121 } 2125 }
2122 2126
2123 if (GetProtocolVersion() >= SPDY4) { 2127 if (GetProtocolVersion() >= SPDY4) {
2124 // Send an acknowledgment of the setting. 2128 // Send an acknowledgment of the setting.
2125 SpdySettingsIR settings_ir; 2129 SpdySettingsIR settings_ir;
2126 settings_ir.set_is_ack(true); 2130 settings_ir.set_is_ack(true);
2127 EnqueueSessionWrite( 2131 EnqueueSessionWrite(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 bool fin, 2224 bool fin,
2221 bool unidirectional, 2225 bool unidirectional,
2222 const SpdyHeaderBlock& headers) { 2226 const SpdyHeaderBlock& headers) {
2223 CHECK(in_io_loop_); 2227 CHECK(in_io_loop_);
2224 2228
2225 DCHECK_LE(GetProtocolVersion(), SPDY3); 2229 DCHECK_LE(GetProtocolVersion(), SPDY3);
2226 2230
2227 base::Time response_time = base::Time::Now(); 2231 base::Time response_time = base::Time::Now();
2228 base::TimeTicks recv_first_byte_time = time_func_(); 2232 base::TimeTicks recv_first_byte_time = time_func_();
2229 2233
2230 if (net_log_.IsLogging()) { 2234 if (net_log_.GetCaptureMode().enabled()) {
2231 net_log_.AddEvent( 2235 net_log_.AddEvent(
2232 NetLog::TYPE_HTTP2_SESSION_PUSHED_SYN_STREAM, 2236 NetLog::TYPE_HTTP2_SESSION_PUSHED_SYN_STREAM,
2233 base::Bind(&NetLogSpdySynStreamReceivedCallback, &headers, fin, 2237 base::Bind(&NetLogSpdySynStreamReceivedCallback, &headers, fin,
2234 unidirectional, priority, stream_id, associated_stream_id)); 2238 unidirectional, priority, stream_id, associated_stream_id));
2235 } 2239 }
2236 2240
2237 // Split headers to simulate push promise and response. 2241 // Split headers to simulate push promise and response.
2238 SpdyHeaderBlock request_headers; 2242 SpdyHeaderBlock request_headers;
2239 SpdyHeaderBlock response_headers; 2243 SpdyHeaderBlock response_headers;
2240 SplitPushedHeadersToRequestAndResponse( 2244 SplitPushedHeadersToRequestAndResponse(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 } 2296 }
2293 2297
2294 void SpdySession::OnSynReply(SpdyStreamId stream_id, 2298 void SpdySession::OnSynReply(SpdyStreamId stream_id,
2295 bool fin, 2299 bool fin,
2296 const SpdyHeaderBlock& headers) { 2300 const SpdyHeaderBlock& headers) {
2297 CHECK(in_io_loop_); 2301 CHECK(in_io_loop_);
2298 2302
2299 base::Time response_time = base::Time::Now(); 2303 base::Time response_time = base::Time::Now();
2300 base::TimeTicks recv_first_byte_time = time_func_(); 2304 base::TimeTicks recv_first_byte_time = time_func_();
2301 2305
2302 if (net_log().IsLogging()) { 2306 if (net_log().GetCaptureMode().enabled()) {
2303 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SYN_REPLY, 2307 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_SYN_REPLY,
2304 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, 2308 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback,
2305 &headers, fin, stream_id)); 2309 &headers, fin, stream_id));
2306 } 2310 }
2307 2311
2308 ActiveStreamMap::iterator it = active_streams_.find(stream_id); 2312 ActiveStreamMap::iterator it = active_streams_.find(stream_id);
2309 if (it == active_streams_.end()) { 2313 if (it == active_streams_.end()) {
2310 // NOTE: it may just be that the stream was cancelled. 2314 // NOTE: it may just be that the stream was cancelled.
2311 return; 2315 return;
2312 } 2316 }
(...skipping 24 matching lines...) Expand all
2337 headers, response_time, recv_first_byte_time, stream)); 2341 headers, response_time, recv_first_byte_time, stream));
2338 } 2342 }
2339 2343
2340 void SpdySession::OnHeaders(SpdyStreamId stream_id, 2344 void SpdySession::OnHeaders(SpdyStreamId stream_id,
2341 bool has_priority, 2345 bool has_priority,
2342 SpdyPriority priority, 2346 SpdyPriority priority,
2343 bool fin, 2347 bool fin,
2344 const SpdyHeaderBlock& headers) { 2348 const SpdyHeaderBlock& headers) {
2345 CHECK(in_io_loop_); 2349 CHECK(in_io_loop_);
2346 2350
2347 if (net_log().IsLogging()) { 2351 if (net_log().GetCaptureMode().enabled()) {
2348 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_HEADERS, 2352 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_HEADERS,
2349 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, 2353 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback,
2350 &headers, fin, stream_id)); 2354 &headers, fin, stream_id));
2351 } 2355 }
2352 2356
2353 ActiveStreamMap::iterator it = active_streams_.find(stream_id); 2357 ActiveStreamMap::iterator it = active_streams_.find(stream_id);
2354 if (it == active_streams_.end()) { 2358 if (it == active_streams_.end()) {
2355 // NOTE: it may just be that the stream was cancelled. 2359 // NOTE: it may just be that the stream was cancelled.
2356 LOG(WARNING) << "Received HEADERS for invalid stream " << stream_id; 2360 LOG(WARNING) << "Received HEADERS for invalid stream " << stream_id;
2357 return; 2361 return;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 DCHECK(active_it->second.stream->IsReservedRemote()); 2724 DCHECK(active_it->second.stream->IsReservedRemote());
2721 num_pushed_streams_++; 2725 num_pushed_streams_++;
2722 return true; 2726 return true;
2723 } 2727 }
2724 2728
2725 void SpdySession::OnPushPromise(SpdyStreamId stream_id, 2729 void SpdySession::OnPushPromise(SpdyStreamId stream_id,
2726 SpdyStreamId promised_stream_id, 2730 SpdyStreamId promised_stream_id,
2727 const SpdyHeaderBlock& headers) { 2731 const SpdyHeaderBlock& headers) {
2728 CHECK(in_io_loop_); 2732 CHECK(in_io_loop_);
2729 2733
2730 if (net_log_.IsLogging()) { 2734 if (net_log_.GetCaptureMode().enabled()) {
2731 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_PUSH_PROMISE, 2735 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_PUSH_PROMISE,
2732 base::Bind(&NetLogSpdyPushPromiseReceivedCallback, 2736 base::Bind(&NetLogSpdyPushPromiseReceivedCallback,
2733 &headers, stream_id, promised_stream_id)); 2737 &headers, stream_id, promised_stream_id));
2734 } 2738 }
2735 2739
2736 // Any priority will do. 2740 // Any priority will do.
2737 // TODO(baranovich): pass parent stream id priority? 2741 // TODO(baranovich): pass parent stream id priority?
2738 if (!TryCreatePushStream(promised_stream_id, stream_id, 0, headers)) 2742 if (!TryCreatePushStream(promised_stream_id, stream_id, 0, headers))
2739 return; 2743 return;
2740 } 2744 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 buffered_spdy_framer_->CreateWindowUpdate(stream_id, delta_window_size)); 2918 buffered_spdy_framer_->CreateWindowUpdate(stream_id, delta_window_size));
2915 EnqueueSessionWrite(priority, WINDOW_UPDATE, window_update_frame.Pass()); 2919 EnqueueSessionWrite(priority, WINDOW_UPDATE, window_update_frame.Pass());
2916 } 2920 }
2917 2921
2918 void SpdySession::WritePingFrame(SpdyPingId unique_id, bool is_ack) { 2922 void SpdySession::WritePingFrame(SpdyPingId unique_id, bool is_ack) {
2919 DCHECK(buffered_spdy_framer_.get()); 2923 DCHECK(buffered_spdy_framer_.get());
2920 scoped_ptr<SpdyFrame> ping_frame( 2924 scoped_ptr<SpdyFrame> ping_frame(
2921 buffered_spdy_framer_->CreatePingFrame(unique_id, is_ack)); 2925 buffered_spdy_framer_->CreatePingFrame(unique_id, is_ack));
2922 EnqueueSessionWrite(HIGHEST, PING, ping_frame.Pass()); 2926 EnqueueSessionWrite(HIGHEST, PING, ping_frame.Pass());
2923 2927
2924 if (net_log().IsLogging()) { 2928 if (net_log().GetCaptureMode().enabled()) {
2925 net_log().AddEvent( 2929 net_log().AddEvent(
2926 NetLog::TYPE_HTTP2_SESSION_PING, 2930 NetLog::TYPE_HTTP2_SESSION_PING,
2927 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "sent")); 2931 base::Bind(&NetLogSpdyPingCallback, unique_id, is_ack, "sent"));
2928 } 2932 }
2929 if (!is_ack) { 2933 if (!is_ack) {
2930 next_ping_id_ += 2; 2934 next_ping_id_ += 2;
2931 ++pings_in_flight_; 2935 ++pings_in_flight_;
2932 PlanToCheckPingStatus(); 2936 PlanToCheckPingStatus();
2933 last_ping_sent_time_ = time_func_(); 2937 last_ping_sent_time_ = time_func_();
2934 } 2938 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 if (!queue->empty()) { 3266 if (!queue->empty()) {
3263 SpdyStreamId stream_id = queue->front(); 3267 SpdyStreamId stream_id = queue->front();
3264 queue->pop_front(); 3268 queue->pop_front();
3265 return stream_id; 3269 return stream_id;
3266 } 3270 }
3267 } 3271 }
3268 return 0; 3272 return 0;
3269 } 3273 }
3270 3274
3271 } // namespace net 3275 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698