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

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

Issue 1659003003: IPC::Message -> base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more mac fix Created 4 years, 10 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/common_param_traits.h » ('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> >::Write( 12 void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write(
13 Message* m, const param_type& p) { 13 base::Pickle* m,
14 const param_type& p) {
14 WriteParam(m, p.get() != NULL); 15 WriteParam(m, p.get() != NULL);
15 if (p.get()) { 16 if (p.get()) {
16 // Do not disclose Set-Cookie headers over IPC. 17 // Do not disclose Set-Cookie headers over IPC.
17 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); 18 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES);
18 } 19 }
19 } 20 }
20 21
21 bool ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Read( 22 bool ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Read(
22 const Message* m, 23 const base::Pickle* m,
23 base::PickleIterator* iter, 24 base::PickleIterator* iter,
24 param_type* r) { 25 param_type* r) {
25 bool has_object; 26 bool has_object;
26 if (!ReadParam(m, iter, &has_object)) 27 if (!ReadParam(m, iter, &has_object))
27 return false; 28 return false;
28 if (has_object) 29 if (has_object)
29 *r = new net::HttpResponseHeaders(iter); 30 *r = new net::HttpResponseHeaders(iter);
30 return true; 31 return true;
31 } 32 }
32 33
33 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( 34 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log(
34 const param_type& p, std::string* l) { 35 const param_type& p, std::string* l) {
35 l->append("<HttpResponseHeaders>"); 36 l->append("<HttpResponseHeaders>");
36 } 37 }
37 38
38 void ParamTraits<storage::DataElement>::Write(Message* m, const param_type& p) { 39 void ParamTraits<storage::DataElement>::Write(base::Pickle* m,
40 const param_type& p) {
39 WriteParam(m, static_cast<int>(p.type())); 41 WriteParam(m, static_cast<int>(p.type()));
40 switch (p.type()) { 42 switch (p.type()) {
41 case storage::DataElement::TYPE_BYTES: { 43 case storage::DataElement::TYPE_BYTES: {
42 m->WriteData(p.bytes(), static_cast<int>(p.length())); 44 m->WriteData(p.bytes(), static_cast<int>(p.length()));
43 break; 45 break;
44 } 46 }
45 case storage::DataElement::TYPE_BYTES_DESCRIPTION: { 47 case storage::DataElement::TYPE_BYTES_DESCRIPTION: {
46 WriteParam(m, p.length()); 48 WriteParam(m, p.length());
47 break; 49 break;
48 } 50 }
(...skipping 21 matching lines...) Expand all
70 NOTREACHED() << "Can't be sent by IPC."; 72 NOTREACHED() << "Can't be sent by IPC.";
71 break; 73 break;
72 } 74 }
73 case storage::DataElement::TYPE_UNKNOWN: { 75 case storage::DataElement::TYPE_UNKNOWN: {
74 NOTREACHED(); 76 NOTREACHED();
75 break; 77 break;
76 } 78 }
77 } 79 }
78 } 80 }
79 81
80 bool ParamTraits<storage::DataElement>::Read(const Message* m, 82 bool ParamTraits<storage::DataElement>::Read(const base::Pickle* m,
81 base::PickleIterator* iter, 83 base::PickleIterator* iter,
82 param_type* r) { 84 param_type* r) {
83 int type; 85 int type;
84 if (!ReadParam(m, iter, &type)) 86 if (!ReadParam(m, iter, &type))
85 return false; 87 return false;
86 switch (type) { 88 switch (type) {
87 case storage::DataElement::TYPE_BYTES: { 89 case storage::DataElement::TYPE_BYTES: {
88 const char* data; 90 const char* data;
89 int len; 91 int len;
90 if (!iter->ReadData(&data, &len)) 92 if (!iter->ReadData(&data, &len))
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 155 }
154 } 156 }
155 return true; 157 return true;
156 } 158 }
157 159
158 void ParamTraits<storage::DataElement>::Log(const param_type& p, 160 void ParamTraits<storage::DataElement>::Log(const param_type& p,
159 std::string* l) { 161 std::string* l) {
160 l->append("<storage::DataElement>"); 162 l->append("<storage::DataElement>");
161 } 163 }
162 164
163 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Write( 165 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Write(
164 Message* m, const param_type& p) { 166 base::Pickle* m,
167 const param_type& p) {
165 WriteParam(m, p.get() != NULL); 168 WriteParam(m, p.get() != NULL);
166 if (p.get()) { 169 if (p.get()) {
167 WriteParam(m, p->http_status_code); 170 WriteParam(m, p->http_status_code);
168 WriteParam(m, p->http_status_text); 171 WriteParam(m, p->http_status_text);
169 WriteParam(m, p->request_headers); 172 WriteParam(m, p->request_headers);
170 WriteParam(m, p->response_headers); 173 WriteParam(m, p->response_headers);
171 WriteParam(m, p->request_headers_text); 174 WriteParam(m, p->request_headers_text);
172 WriteParam(m, p->response_headers_text); 175 WriteParam(m, p->response_headers_text);
173 } 176 }
174 } 177 }
175 178
176 bool ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Read( 179 bool ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Read(
177 const Message* m, 180 const base::Pickle* m,
178 base::PickleIterator* iter, 181 base::PickleIterator* iter,
179 param_type* r) { 182 param_type* r) {
180 bool has_object; 183 bool has_object;
181 if (!ReadParam(m, iter, &has_object)) 184 if (!ReadParam(m, iter, &has_object))
182 return false; 185 return false;
183 if (!has_object) 186 if (!has_object)
184 return true; 187 return true;
185 *r = new content::ResourceDevToolsInfo(); 188 *r = new content::ResourceDevToolsInfo();
186 return 189 return
187 ReadParam(m, iter, &(*r)->http_status_code) && 190 ReadParam(m, iter, &(*r)->http_status_code) &&
188 ReadParam(m, iter, &(*r)->http_status_text) && 191 ReadParam(m, iter, &(*r)->http_status_text) &&
189 ReadParam(m, iter, &(*r)->request_headers) && 192 ReadParam(m, iter, &(*r)->request_headers) &&
190 ReadParam(m, iter, &(*r)->response_headers) && 193 ReadParam(m, iter, &(*r)->response_headers) &&
191 ReadParam(m, iter, &(*r)->request_headers_text) && 194 ReadParam(m, iter, &(*r)->request_headers_text) &&
192 ReadParam(m, iter, &(*r)->response_headers_text); 195 ReadParam(m, iter, &(*r)->response_headers_text);
193 } 196 }
194 197
195 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Log( 198 void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Log(
196 const param_type& p, std::string* l) { 199 const param_type& p, std::string* l) {
197 l->append("("); 200 l->append("(");
198 if (p.get()) { 201 if (p.get()) {
199 LogParam(p->request_headers, l); 202 LogParam(p->request_headers, l);
200 l->append(", "); 203 l->append(", ");
201 LogParam(p->response_headers, l); 204 LogParam(p->response_headers, l);
202 } 205 }
203 l->append(")"); 206 l->append(")");
204 } 207 }
205 208
206 void ParamTraits<net::LoadTimingInfo>::Write( 209 void ParamTraits<net::LoadTimingInfo>::Write(base::Pickle* m,
207 Message* m, const param_type& p) { 210 const param_type& p) {
208 WriteParam(m, p.socket_log_id); 211 WriteParam(m, p.socket_log_id);
209 WriteParam(m, p.socket_reused); 212 WriteParam(m, p.socket_reused);
210 WriteParam(m, p.request_start_time.is_null()); 213 WriteParam(m, p.request_start_time.is_null());
211 if (p.request_start_time.is_null()) 214 if (p.request_start_time.is_null())
212 return; 215 return;
213 WriteParam(m, p.request_start_time); 216 WriteParam(m, p.request_start_time);
214 WriteParam(m, p.request_start); 217 WriteParam(m, p.request_start);
215 WriteParam(m, p.proxy_resolve_start); 218 WriteParam(m, p.proxy_resolve_start);
216 WriteParam(m, p.proxy_resolve_end); 219 WriteParam(m, p.proxy_resolve_end);
217 WriteParam(m, p.connect_timing.dns_start); 220 WriteParam(m, p.connect_timing.dns_start);
218 WriteParam(m, p.connect_timing.dns_end); 221 WriteParam(m, p.connect_timing.dns_end);
219 WriteParam(m, p.connect_timing.connect_start); 222 WriteParam(m, p.connect_timing.connect_start);
220 WriteParam(m, p.connect_timing.connect_end); 223 WriteParam(m, p.connect_timing.connect_end);
221 WriteParam(m, p.connect_timing.ssl_start); 224 WriteParam(m, p.connect_timing.ssl_start);
222 WriteParam(m, p.connect_timing.ssl_end); 225 WriteParam(m, p.connect_timing.ssl_end);
223 WriteParam(m, p.send_start); 226 WriteParam(m, p.send_start);
224 WriteParam(m, p.send_end); 227 WriteParam(m, p.send_end);
225 WriteParam(m, p.receive_headers_end); 228 WriteParam(m, p.receive_headers_end);
226 } 229 }
227 230
228 bool ParamTraits<net::LoadTimingInfo>::Read(const Message* m, 231 bool ParamTraits<net::LoadTimingInfo>::Read(const base::Pickle* m,
229 base::PickleIterator* iter, 232 base::PickleIterator* iter,
230 param_type* r) { 233 param_type* r) {
231 bool has_no_times; 234 bool has_no_times;
232 if (!ReadParam(m, iter, &r->socket_log_id) || 235 if (!ReadParam(m, iter, &r->socket_log_id) ||
233 !ReadParam(m, iter, &r->socket_reused) || 236 !ReadParam(m, iter, &r->socket_reused) ||
234 !ReadParam(m, iter, &has_no_times)) { 237 !ReadParam(m, iter, &has_no_times)) {
235 return false; 238 return false;
236 } 239 }
237 if (has_no_times) 240 if (has_no_times)
238 return true; 241 return true;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 LogParam(p.connect_timing.ssl_end, l); 284 LogParam(p.connect_timing.ssl_end, l);
282 l->append(", "); 285 l->append(", ");
283 LogParam(p.send_start, l); 286 LogParam(p.send_start, l);
284 l->append(", "); 287 l->append(", ");
285 LogParam(p.send_end, l); 288 LogParam(p.send_end, l);
286 l->append(", "); 289 l->append(", ");
287 LogParam(p.receive_headers_end, l); 290 LogParam(p.receive_headers_end, l);
288 l->append(")"); 291 l->append(")");
289 } 292 }
290 293
291 void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Write( 294 void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Write(
292 Message* m, 295 base::Pickle* m,
293 const param_type& p) { 296 const param_type& p) {
294 WriteParam(m, p.get() != NULL); 297 WriteParam(m, p.get() != NULL);
295 if (p.get()) { 298 if (p.get()) {
296 WriteParam(m, *p->elements()); 299 WriteParam(m, *p->elements());
297 WriteParam(m, p->identifier()); 300 WriteParam(m, p->identifier());
298 } 301 }
299 } 302 }
300 303
301 bool ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Read( 304 bool ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Read(
302 const Message* m, 305 const base::Pickle* m,
303 base::PickleIterator* iter, 306 base::PickleIterator* iter,
304 param_type* r) { 307 param_type* r) {
305 bool has_object; 308 bool has_object;
306 if (!ReadParam(m, iter, &has_object)) 309 if (!ReadParam(m, iter, &has_object))
307 return false; 310 return false;
308 if (!has_object) 311 if (!has_object)
309 return true; 312 return true;
310 std::vector<storage::DataElement> elements; 313 std::vector<storage::DataElement> elements;
311 if (!ReadParam(m, iter, &elements)) 314 if (!ReadParam(m, iter, &elements))
312 return false; 315 return false;
313 int64_t identifier; 316 int64_t identifier;
314 if (!ReadParam(m, iter, &identifier)) 317 if (!ReadParam(m, iter, &identifier))
315 return false; 318 return false;
316 *r = new content::ResourceRequestBody; 319 *r = new content::ResourceRequestBody;
317 (*r)->swap_elements(&elements); 320 (*r)->swap_elements(&elements);
318 (*r)->set_identifier(identifier); 321 (*r)->set_identifier(identifier);
319 return true; 322 return true;
320 } 323 }
321 324
322 void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Log( 325 void ParamTraits<scoped_refptr<content::ResourceRequestBody> >::Log(
323 const param_type& p, std::string* l) { 326 const param_type& p, std::string* l) {
324 l->append("<ResourceRequestBody>"); 327 l->append("<ResourceRequestBody>");
325 } 328 }
326 329
327 } // namespace IPC 330 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/resource_messages.h ('k') | content/public/common/common_param_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698