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

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

Issue 1149763005: Change NetLog::ParametersCallback to return a scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments on ownership removed Created 5 years, 7 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
« no previous file with comments | « net/spdy/spdy_http_stream.cc ('k') | net/spdy/spdy_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(capture_mode, 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 scoped_ptr<base::Value> NetLogSpdySynStreamSentCallback(
74 bool fin, 74 const SpdyHeaderBlock* headers,
75 bool unidirectional, 75 bool fin,
76 SpdyPriority spdy_priority, 76 bool unidirectional,
77 SpdyStreamId stream_id, 77 SpdyPriority spdy_priority,
78 NetLogCaptureMode capture_mode) { 78 SpdyStreamId stream_id,
79 base::DictionaryValue* dict = new base::DictionaryValue(); 79 NetLogCaptureMode capture_mode) {
80 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
80 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 81 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
81 dict->SetBoolean("fin", fin); 82 dict->SetBoolean("fin", fin);
82 dict->SetBoolean("unidirectional", unidirectional); 83 dict->SetBoolean("unidirectional", unidirectional);
83 dict->SetInteger("priority", static_cast<int>(spdy_priority)); 84 dict->SetInteger("priority", static_cast<int>(spdy_priority));
84 dict->SetInteger("stream_id", stream_id); 85 dict->SetInteger("stream_id", stream_id);
85 return dict; 86 return dict.Pass();
86 } 87 }
87 88
88 base::Value* NetLogSpdySynStreamReceivedCallback( 89 scoped_ptr<base::Value> NetLogSpdySynStreamReceivedCallback(
89 const SpdyHeaderBlock* headers, 90 const SpdyHeaderBlock* headers,
90 bool fin, 91 bool fin,
91 bool unidirectional, 92 bool unidirectional,
92 SpdyPriority spdy_priority, 93 SpdyPriority spdy_priority,
93 SpdyStreamId stream_id, 94 SpdyStreamId stream_id,
94 SpdyStreamId associated_stream, 95 SpdyStreamId associated_stream,
95 NetLogCaptureMode capture_mode) { 96 NetLogCaptureMode capture_mode) {
96 base::DictionaryValue* dict = new base::DictionaryValue(); 97 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
97 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 98 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
98 dict->SetBoolean("fin", fin); 99 dict->SetBoolean("fin", fin);
99 dict->SetBoolean("unidirectional", unidirectional); 100 dict->SetBoolean("unidirectional", unidirectional);
100 dict->SetInteger("priority", static_cast<int>(spdy_priority)); 101 dict->SetInteger("priority", static_cast<int>(spdy_priority));
101 dict->SetInteger("stream_id", stream_id); 102 dict->SetInteger("stream_id", stream_id);
102 dict->SetInteger("associated_stream", associated_stream); 103 dict->SetInteger("associated_stream", associated_stream);
103 return dict; 104 return dict.Pass();
104 } 105 }
105 106
106 base::Value* NetLogSpdySynReplyOrHeadersReceivedCallback( 107 scoped_ptr<base::Value> NetLogSpdySynReplyOrHeadersReceivedCallback(
107 const SpdyHeaderBlock* headers, 108 const SpdyHeaderBlock* headers,
108 bool fin, 109 bool fin,
109 SpdyStreamId stream_id, 110 SpdyStreamId stream_id,
110 NetLogCaptureMode capture_mode) { 111 NetLogCaptureMode capture_mode) {
111 base::DictionaryValue* dict = new base::DictionaryValue(); 112 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
112 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 113 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
113 dict->SetBoolean("fin", fin); 114 dict->SetBoolean("fin", fin);
114 dict->SetInteger("stream_id", stream_id); 115 dict->SetInteger("stream_id", stream_id);
115 return dict; 116 return dict.Pass();
116 } 117 }
117 118
118 base::Value* NetLogSpdySessionCloseCallback( 119 scoped_ptr<base::Value> NetLogSpdySessionCloseCallback(
119 int net_error, 120 int net_error,
120 const std::string* description, 121 const std::string* description,
121 NetLogCaptureMode /* capture_mode */) { 122 NetLogCaptureMode /* capture_mode */) {
122 base::DictionaryValue* dict = new base::DictionaryValue(); 123 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
123 dict->SetInteger("net_error", net_error); 124 dict->SetInteger("net_error", net_error);
124 dict->SetString("description", *description); 125 dict->SetString("description", *description);
125 return dict; 126 return dict.Pass();
126 } 127 }
127 128
128 base::Value* NetLogSpdySessionCallback(const HostPortProxyPair* host_pair, 129 scoped_ptr<base::Value> NetLogSpdySessionCallback(
129 NetLogCaptureMode /* capture_mode */) { 130 const HostPortProxyPair* host_pair,
130 base::DictionaryValue* dict = new base::DictionaryValue(); 131 NetLogCaptureMode /* capture_mode */) {
132 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
131 dict->SetString("host", host_pair->first.ToString()); 133 dict->SetString("host", host_pair->first.ToString());
132 dict->SetString("proxy", host_pair->second.ToPacString()); 134 dict->SetString("proxy", host_pair->second.ToPacString());
133 return dict; 135 return dict.Pass();
134 } 136 }
135 137
136 base::Value* NetLogSpdyInitializedCallback( 138 scoped_ptr<base::Value> NetLogSpdyInitializedCallback(
137 NetLog::Source source, 139 NetLog::Source source,
138 const NextProto protocol_version, 140 const NextProto protocol_version,
139 NetLogCaptureMode /* capture_mode */) { 141 NetLogCaptureMode /* capture_mode */) {
140 base::DictionaryValue* dict = new base::DictionaryValue(); 142 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
141 if (source.IsValid()) { 143 if (source.IsValid()) {
142 source.AddToEventParameters(dict); 144 source.AddToEventParameters(dict.get());
143 } 145 }
144 dict->SetString("protocol", 146 dict->SetString("protocol",
145 SSLClientSocket::NextProtoToString(protocol_version)); 147 SSLClientSocket::NextProtoToString(protocol_version));
146 return dict; 148 return dict.Pass();
147 } 149 }
148 150
149 base::Value* NetLogSpdySettingsCallback(const HostPortPair& host_port_pair, 151 scoped_ptr<base::Value> NetLogSpdySettingsCallback(
150 bool clear_persisted, 152 const HostPortPair& host_port_pair,
151 NetLogCaptureMode /* capture_mode */) { 153 bool clear_persisted,
152 base::DictionaryValue* dict = new base::DictionaryValue(); 154 NetLogCaptureMode /* capture_mode */) {
155 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
153 dict->SetString("host", host_port_pair.ToString()); 156 dict->SetString("host", host_port_pair.ToString());
154 dict->SetBoolean("clear_persisted", clear_persisted); 157 dict->SetBoolean("clear_persisted", clear_persisted);
155 return dict; 158 return dict.Pass();
156 } 159 }
157 160
158 base::Value* NetLogSpdySettingCallback(SpdySettingsIds id, 161 scoped_ptr<base::Value> NetLogSpdySettingCallback(
159 const SpdyMajorVersion protocol_version, 162 SpdySettingsIds id,
160 SpdySettingsFlags flags, 163 const SpdyMajorVersion protocol_version,
161 uint32 value, 164 SpdySettingsFlags flags,
162 NetLogCaptureMode /* capture_mode */) { 165 uint32 value,
163 base::DictionaryValue* dict = new base::DictionaryValue(); 166 NetLogCaptureMode /* capture_mode */) {
167 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
164 dict->SetInteger("id", 168 dict->SetInteger("id",
165 SpdyConstants::SerializeSettingId(protocol_version, id)); 169 SpdyConstants::SerializeSettingId(protocol_version, id));
166 dict->SetInteger("flags", flags); 170 dict->SetInteger("flags", flags);
167 dict->SetInteger("value", value); 171 dict->SetInteger("value", value);
168 return dict; 172 return dict.Pass();
169 } 173 }
170 174
171 base::Value* NetLogSpdySendSettingsCallback( 175 scoped_ptr<base::Value> NetLogSpdySendSettingsCallback(
172 const SettingsMap* settings, 176 const SettingsMap* settings,
173 const SpdyMajorVersion protocol_version, 177 const SpdyMajorVersion protocol_version,
174 NetLogCaptureMode /* capture_mode */) { 178 NetLogCaptureMode /* capture_mode */) {
175 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 179 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
176 scoped_ptr<base::ListValue> settings_list(new base::ListValue()); 180 scoped_ptr<base::ListValue> settings_list(new base::ListValue());
177 for (SettingsMap::const_iterator it = settings->begin(); 181 for (SettingsMap::const_iterator it = settings->begin();
178 it != settings->end(); ++it) { 182 it != settings->end(); ++it) {
179 const SpdySettingsIds id = it->first; 183 const SpdySettingsIds id = it->first;
180 const SpdySettingsFlags flags = it->second.first; 184 const SpdySettingsFlags flags = it->second.first;
181 const uint32 value = it->second.second; 185 const uint32 value = it->second.second;
182 settings_list->Append(new base::StringValue(base::StringPrintf( 186 settings_list->Append(new base::StringValue(base::StringPrintf(
183 "[id:%u flags:%u value:%u]", 187 "[id:%u flags:%u value:%u]",
184 SpdyConstants::SerializeSettingId(protocol_version, id), 188 SpdyConstants::SerializeSettingId(protocol_version, id),
185 flags, 189 flags,
186 value))); 190 value)));
187 } 191 }
188 dict->Set("settings", settings_list.Pass()); 192 dict->Set("settings", settings_list.Pass());
189 return dict.release(); 193 return dict.Pass();
190 } 194 }
191 195
192 base::Value* NetLogSpdyWindowUpdateFrameCallback( 196 scoped_ptr<base::Value> NetLogSpdyWindowUpdateFrameCallback(
193 SpdyStreamId stream_id, 197 SpdyStreamId stream_id,
194 uint32 delta, 198 uint32 delta,
195 NetLogCaptureMode /* capture_mode */) { 199 NetLogCaptureMode /* capture_mode */) {
196 base::DictionaryValue* dict = new base::DictionaryValue(); 200 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
197 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 201 dict->SetInteger("stream_id", static_cast<int>(stream_id));
198 dict->SetInteger("delta", delta); 202 dict->SetInteger("delta", delta);
199 return dict; 203 return dict.Pass();
200 } 204 }
201 205
202 base::Value* NetLogSpdySessionWindowUpdateCallback( 206 scoped_ptr<base::Value> NetLogSpdySessionWindowUpdateCallback(
203 int32 delta, 207 int32 delta,
204 int32 window_size, 208 int32 window_size,
205 NetLogCaptureMode /* capture_mode */) { 209 NetLogCaptureMode /* capture_mode */) {
206 base::DictionaryValue* dict = new base::DictionaryValue(); 210 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
207 dict->SetInteger("delta", delta); 211 dict->SetInteger("delta", delta);
208 dict->SetInteger("window_size", window_size); 212 dict->SetInteger("window_size", window_size);
209 return dict; 213 return dict.Pass();
210 } 214 }
211 215
212 base::Value* NetLogSpdyDataCallback(SpdyStreamId stream_id, 216 scoped_ptr<base::Value> NetLogSpdyDataCallback(
213 int size, 217 SpdyStreamId stream_id,
214 bool fin, 218 int size,
215 NetLogCaptureMode /* capture_mode */) { 219 bool fin,
216 base::DictionaryValue* dict = new base::DictionaryValue(); 220 NetLogCaptureMode /* capture_mode */) {
221 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
217 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 222 dict->SetInteger("stream_id", static_cast<int>(stream_id));
218 dict->SetInteger("size", size); 223 dict->SetInteger("size", size);
219 dict->SetBoolean("fin", fin); 224 dict->SetBoolean("fin", fin);
220 return dict; 225 return dict.Pass();
221 } 226 }
222 227
223 base::Value* NetLogSpdyRstCallback(SpdyStreamId stream_id, 228 scoped_ptr<base::Value> NetLogSpdyRstCallback(
224 int status, 229 SpdyStreamId stream_id,
225 const std::string* description, 230 int status,
226 NetLogCaptureMode /* capture_mode */) { 231 const std::string* description,
227 base::DictionaryValue* dict = new base::DictionaryValue(); 232 NetLogCaptureMode /* capture_mode */) {
233 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
228 dict->SetInteger("stream_id", static_cast<int>(stream_id)); 234 dict->SetInteger("stream_id", static_cast<int>(stream_id));
229 dict->SetInteger("status", status); 235 dict->SetInteger("status", status);
230 dict->SetString("description", *description); 236 dict->SetString("description", *description);
231 return dict; 237 return dict.Pass();
232 } 238 }
233 239
234 base::Value* NetLogSpdyPingCallback(SpdyPingId unique_id, 240 scoped_ptr<base::Value> NetLogSpdyPingCallback(
235 bool is_ack, 241 SpdyPingId unique_id,
236 const char* type, 242 bool is_ack,
237 NetLogCaptureMode /* capture_mode */) { 243 const char* type,
238 base::DictionaryValue* dict = new base::DictionaryValue(); 244 NetLogCaptureMode /* capture_mode */) {
245 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
239 dict->SetInteger("unique_id", static_cast<int>(unique_id)); 246 dict->SetInteger("unique_id", static_cast<int>(unique_id));
240 dict->SetString("type", type); 247 dict->SetString("type", type);
241 dict->SetBoolean("is_ack", is_ack); 248 dict->SetBoolean("is_ack", is_ack);
242 return dict; 249 return dict.Pass();
243 } 250 }
244 251
245 base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id, 252 scoped_ptr<base::Value> NetLogSpdyGoAwayCallback(
246 int active_streams, 253 SpdyStreamId last_stream_id,
247 int unclaimed_streams, 254 int active_streams,
248 SpdyGoAwayStatus status, 255 int unclaimed_streams,
249 NetLogCaptureMode /* capture_mode */) { 256 SpdyGoAwayStatus status,
250 base::DictionaryValue* dict = new base::DictionaryValue(); 257 NetLogCaptureMode /* capture_mode */) {
258 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
251 dict->SetInteger("last_accepted_stream_id", 259 dict->SetInteger("last_accepted_stream_id",
252 static_cast<int>(last_stream_id)); 260 static_cast<int>(last_stream_id));
253 dict->SetInteger("active_streams", active_streams); 261 dict->SetInteger("active_streams", active_streams);
254 dict->SetInteger("unclaimed_streams", unclaimed_streams); 262 dict->SetInteger("unclaimed_streams", unclaimed_streams);
255 dict->SetInteger("status", static_cast<int>(status)); 263 dict->SetInteger("status", static_cast<int>(status));
256 return dict; 264 return dict.Pass();
257 } 265 }
258 266
259 base::Value* NetLogSpdyPushPromiseReceivedCallback( 267 scoped_ptr<base::Value> NetLogSpdyPushPromiseReceivedCallback(
260 const SpdyHeaderBlock* headers, 268 const SpdyHeaderBlock* headers,
261 SpdyStreamId stream_id, 269 SpdyStreamId stream_id,
262 SpdyStreamId promised_stream_id, 270 SpdyStreamId promised_stream_id,
263 NetLogCaptureMode capture_mode) { 271 NetLogCaptureMode capture_mode) {
264 base::DictionaryValue* dict = new base::DictionaryValue(); 272 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
265 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode)); 273 dict->Set("headers", SpdyHeaderBlockToListValue(*headers, capture_mode));
266 dict->SetInteger("id", stream_id); 274 dict->SetInteger("id", stream_id);
267 dict->SetInteger("promised_stream_id", promised_stream_id); 275 dict->SetInteger("promised_stream_id", promised_stream_id);
268 return dict; 276 return dict.Pass();
269 } 277 }
270 278
271 base::Value* NetLogSpdyAdoptedPushStreamCallback( 279 scoped_ptr<base::Value> NetLogSpdyAdoptedPushStreamCallback(
272 SpdyStreamId stream_id, 280 SpdyStreamId stream_id,
273 const GURL* url, 281 const GURL* url,
274 NetLogCaptureMode capture_mode) { 282 NetLogCaptureMode capture_mode) {
275 base::DictionaryValue* dict = new base::DictionaryValue(); 283 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
276 dict->SetInteger("stream_id", stream_id); 284 dict->SetInteger("stream_id", stream_id);
277 dict->SetString("url", url->spec()); 285 dict->SetString("url", url->spec());
278 return dict; 286 return dict.Pass();
279 } 287 }
280 288
281 // Helper function to return the total size of an array of objects 289 // Helper function to return the total size of an array of objects
282 // with .size() member functions. 290 // with .size() member functions.
283 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) { 291 template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) {
284 size_t total_size = 0; 292 size_t total_size = 0;
285 for (size_t i = 0; i < N; ++i) { 293 for (size_t i = 0; i < N; ++i) {
286 total_size += arr[i].size(); 294 total_size += arr[i].size();
287 } 295 }
288 return total_size; 296 return total_size;
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 if (!queue->empty()) { 3258 if (!queue->empty()) {
3251 SpdyStreamId stream_id = queue->front(); 3259 SpdyStreamId stream_id = queue->front();
3252 queue->pop_front(); 3260 queue->pop_front();
3253 return stream_id; 3261 return stream_id;
3254 } 3262 }
3255 } 3263 }
3256 return 0; 3264 return 0;
3257 } 3265 }
3258 3266
3259 } // namespace net 3267 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream.cc ('k') | net/spdy/spdy_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698