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

Side by Side Diff: content/common/resource_messages.cc

Issue 1966983003: Generate param traits size methods for IPC files in content/ (and traits it depends on). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix owners Created 4 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 | « content/common/resource_messages.h ('k') | content/public/common/OWNERS » ('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 "content/common/resource_messages.h" 5 #include "content/common/resource_messages.h"
6 6
7 #include "net/base/load_timing_info.h" 7 #include "net/base/load_timing_info.h"
8 #include "net/http/http_response_headers.h" 8 #include "net/http/http_response_headers.h"
9 9
10 namespace IPC { 10 namespace IPC {
11 11
12 void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::GetSize(
13 base::PickleSizer* s, const param_type& p) {
14 GetParamSize(s, p.get() != NULL);
15 if (p.get()) {
16 base::Pickle temp;
17 p->Persist(&temp, net::HttpResponseHeaders::PERSIST_SANS_COOKIES);
18 s->AddBytes(temp.payload_size());
19 }
20 }
21
12 void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write( 22 void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write(
13 base::Pickle* m, 23 base::Pickle* m,
14 const param_type& p) { 24 const param_type& p) {
15 WriteParam(m, p.get() != NULL); 25 WriteParam(m, p.get() != NULL);
16 if (p.get()) { 26 if (p.get()) {
17 // Do not disclose Set-Cookie headers over IPC. 27 // Do not disclose Set-Cookie headers over IPC.
18 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); 28 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES);
19 } 29 }
20 } 30 }
21 31
22 bool ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Read( 32 bool ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Read(
23 const base::Pickle* m, 33 const base::Pickle* m,
24 base::PickleIterator* iter, 34 base::PickleIterator* iter,
25 param_type* r) { 35 param_type* r) {
26 bool has_object; 36 bool has_object;
27 if (!ReadParam(m, iter, &has_object)) 37 if (!ReadParam(m, iter, &has_object))
28 return false; 38 return false;
29 if (has_object) 39 if (has_object)
30 *r = new net::HttpResponseHeaders(iter); 40 *r = new net::HttpResponseHeaders(iter);
31 return true; 41 return true;
32 } 42 }
33 43
34 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( 44 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log(
35 const param_type& p, std::string* l) { 45 const param_type& p, std::string* l) {
36 l->append("<HttpResponseHeaders>"); 46 l->append("<HttpResponseHeaders>");
37 } 47 }
38 48
49 void ParamTraits<storage::DataElement>::GetSize(base::PickleSizer* s,
50 const param_type& p) {
51 GetParamSize(s, static_cast<int>(p.type()));
52 switch (p.type()) {
53 case storage::DataElement::TYPE_BYTES: {
54 s->AddData(static_cast<int>(p.length()));
55 break;
56 }
57 case storage::DataElement::TYPE_BYTES_DESCRIPTION: {
58 GetParamSize(s, p.length());
59 break;
60 }
61 case storage::DataElement::TYPE_FILE: {
62 GetParamSize(s, p.path());
63 GetParamSize(s, p.offset());
64 GetParamSize(s, p.length());
65 GetParamSize(s, p.expected_modification_time());
66 break;
67 }
68 case storage::DataElement::TYPE_FILE_FILESYSTEM: {
69 GetParamSize(s, p.filesystem_url());
70 GetParamSize(s, p.offset());
71 GetParamSize(s, p.length());
72 GetParamSize(s, p.expected_modification_time());
73 break;
74 }
75 case storage::DataElement::TYPE_BLOB: {
76 GetParamSize(s, p.blob_uuid());
77 GetParamSize(s, p.offset());
78 GetParamSize(s, p.length());
79 break;
80 }
81 case storage::DataElement::TYPE_DISK_CACHE_ENTRY: {
82 NOTREACHED() << "Can't be sent by IPC.";
83 break;
84 }
85 case storage::DataElement::TYPE_UNKNOWN: {
86 NOTREACHED();
87 break;
88 }
89 }
90 }
91
39 void ParamTraits<storage::DataElement>::Write(base::Pickle* m, 92 void ParamTraits<storage::DataElement>::Write(base::Pickle* m,
40 const param_type& p) { 93 const param_type& p) {
41 WriteParam(m, static_cast<int>(p.type())); 94 WriteParam(m, static_cast<int>(p.type()));
42 switch (p.type()) { 95 switch (p.type()) {
43 case storage::DataElement::TYPE_BYTES: { 96 case storage::DataElement::TYPE_BYTES: {
44 m->WriteData(p.bytes(), static_cast<int>(p.length())); 97 m->WriteData(p.bytes(), static_cast<int>(p.length()));
45 break; 98 break;
46 } 99 }
47 case storage::DataElement::TYPE_BYTES_DESCRIPTION: { 100 case storage::DataElement::TYPE_BYTES_DESCRIPTION: {
48 WriteParam(m, p.length()); 101 WriteParam(m, p.length());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 208 }
156 } 209 }
157 return true; 210 return true;
158 } 211 }
159 212
160 void ParamTraits<storage::DataElement>::Log(const param_type& p, 213 void ParamTraits<storage::DataElement>::Log(const param_type& p,
161 std::string* l) { 214 std::string* l) {
162 l->append("<storage::DataElement>"); 215 l->append("<storage::DataElement>");
163 } 216 }
164 217
218 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::GetSize(
219 base::PickleSizer* s, const param_type& p) {
220 GetParamSize(s, p.get() != NULL);
221 if (p.get()) {
222 GetParamSize(s, p->http_status_code);
223 GetParamSize(s, p->http_status_text);
224 GetParamSize(s, p->request_headers);
225 GetParamSize(s, p->response_headers);
226 GetParamSize(s, p->request_headers_text);
227 GetParamSize(s, p->response_headers_text);
228 }
229 }
230
165 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Write( 231 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Write(
166 base::Pickle* m, 232 base::Pickle* m,
167 const param_type& p) { 233 const param_type& p) {
168 WriteParam(m, p.get() != NULL); 234 WriteParam(m, p.get() != NULL);
169 if (p.get()) { 235 if (p.get()) {
170 WriteParam(m, p->http_status_code); 236 WriteParam(m, p->http_status_code);
171 WriteParam(m, p->http_status_text); 237 WriteParam(m, p->http_status_text);
172 WriteParam(m, p->request_headers); 238 WriteParam(m, p->request_headers);
173 WriteParam(m, p->response_headers); 239 WriteParam(m, p->response_headers);
174 WriteParam(m, p->request_headers_text); 240 WriteParam(m, p->request_headers_text);
(...skipping 24 matching lines...) Expand all
199 const param_type& p, std::string* l) { 265 const param_type& p, std::string* l) {
200 l->append("("); 266 l->append("(");
201 if (p.get()) { 267 if (p.get()) {
202 LogParam(p->request_headers, l); 268 LogParam(p->request_headers, l);
203 l->append(", "); 269 l->append(", ");
204 LogParam(p->response_headers, l); 270 LogParam(p->response_headers, l);
205 } 271 }
206 l->append(")"); 272 l->append(")");
207 } 273 }
208 274
275 void ParamTraits<net::LoadTimingInfo>::GetSize(base::PickleSizer* s,
276 const param_type& p) {
277 GetParamSize(s, p.socket_log_id);
278 GetParamSize(s, p.socket_reused);
279 GetParamSize(s, p.request_start_time.is_null());
280 if (p.request_start_time.is_null())
281 return;
282 GetParamSize(s, p.request_start_time);
283 GetParamSize(s, p.request_start);
284 GetParamSize(s, p.proxy_resolve_start);
285 GetParamSize(s, p.proxy_resolve_end);
286 GetParamSize(s, p.connect_timing.dns_start);
287 GetParamSize(s, p.connect_timing.dns_end);
288 GetParamSize(s, p.connect_timing.connect_start);
289 GetParamSize(s, p.connect_timing.connect_end);
290 GetParamSize(s, p.connect_timing.ssl_start);
291 GetParamSize(s, p.connect_timing.ssl_end);
292 GetParamSize(s, p.send_start);
293 GetParamSize(s, p.send_end);
294 GetParamSize(s, p.receive_headers_end);
295 GetParamSize(s, p.push_start);
296 GetParamSize(s, p.push_end);
297 }
298
209 void ParamTraits<net::LoadTimingInfo>::Write(base::Pickle* m, 299 void ParamTraits<net::LoadTimingInfo>::Write(base::Pickle* m,
210 const param_type& p) { 300 const param_type& p) {
211 WriteParam(m, p.socket_log_id); 301 WriteParam(m, p.socket_log_id);
212 WriteParam(m, p.socket_reused); 302 WriteParam(m, p.socket_reused);
213 WriteParam(m, p.request_start_time.is_null()); 303 WriteParam(m, p.request_start_time.is_null());
214 if (p.request_start_time.is_null()) 304 if (p.request_start_time.is_null())
215 return; 305 return;
216 WriteParam(m, p.request_start_time); 306 WriteParam(m, p.request_start_time);
217 WriteParam(m, p.request_start); 307 WriteParam(m, p.request_start);
218 WriteParam(m, p.proxy_resolve_start); 308 WriteParam(m, p.proxy_resolve_start);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 LogParam(p.send_end, l); 382 LogParam(p.send_end, l);
293 l->append(", "); 383 l->append(", ");
294 LogParam(p.receive_headers_end, l); 384 LogParam(p.receive_headers_end, l);
295 l->append(", "); 385 l->append(", ");
296 LogParam(p.push_start, l); 386 LogParam(p.push_start, l);
297 l->append(", "); 387 l->append(", ");
298 LogParam(p.push_end, l); 388 LogParam(p.push_end, l);
299 l->append(")"); 389 l->append(")");
300 } 390 }
301 391
392 void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::GetSize(
393 base::PickleSizer* s, const param_type& p) {
394 GetParamSize(s, p.get() != NULL);
395 if (p.get()) {
396 GetParamSize(s, *p->elements());
397 GetParamSize(s, p->identifier());
398 }
399 }
400
302 void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Write( 401 void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Write(
303 base::Pickle* m, 402 base::Pickle* m,
304 const param_type& p) { 403 const param_type& p) {
305 WriteParam(m, p.get() != NULL); 404 WriteParam(m, p.get() != NULL);
306 if (p.get()) { 405 if (p.get()) {
307 WriteParam(m, *p->elements()); 406 WriteParam(m, *p->elements());
308 WriteParam(m, p->identifier()); 407 WriteParam(m, p->identifier());
309 } 408 }
310 } 409 }
311 410
(...skipping 17 matching lines...) Expand all
329 (*r)->set_identifier(identifier); 428 (*r)->set_identifier(identifier);
330 return true; 429 return true;
331 } 430 }
332 431
333 void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Log( 432 void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Log(
334 const param_type& p, std::string* l) { 433 const param_type& p, std::string* l) {
335 l->append("<ResourceRequestBody>"); 434 l->append("<ResourceRequestBody>");
336 } 435 }
337 436
338 } // namespace IPC 437 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/resource_messages.h ('k') | content/public/common/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698