| 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 "content/public/common/common_param_traits.h" | 5 #include "content/public/common/common_param_traits.h" |
| 6 | 6 |
| 7 #include "content/public/common/content_constants.h" | 7 #include "content/public/common/content_constants.h" |
| 8 #include "content/public/common/referrer.h" | 8 #include "content/public/common/referrer.h" |
| 9 #include "net/base/host_port_pair.h" | 9 #include "net/base/host_port_pair.h" |
| 10 #include "net/base/upload_data.h" | 10 #include "net/base/upload_data.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 (*r)->set_identifier(identifier); | 253 (*r)->set_identifier(identifier); |
| 254 (*r)->set_is_chunked(is_chunked); | 254 (*r)->set_is_chunked(is_chunked); |
| 255 return true; | 255 return true; |
| 256 } | 256 } |
| 257 | 257 |
| 258 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, | 258 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, |
| 259 std::string* l) { | 259 std::string* l) { |
| 260 l->append("<net::UploadData>"); | 260 l->append("<net::UploadData>"); |
| 261 } | 261 } |
| 262 | 262 |
| 263 template <> | 263 void ParamTraits<webkit_base::DataElement>::Write( |
| 264 struct ParamTraits<webkit_glue::ResourceRequestBody::Element> { | 264 Message* m, const param_type& p) { |
| 265 typedef webkit_glue::ResourceRequestBody::Element param_type; | 265 WriteParam(m, static_cast<int>(p.type())); |
| 266 static void Write(Message* m, const param_type& p) { | 266 switch (p.type()) { |
| 267 WriteParam(m, static_cast<int>(p.type())); | 267 case webkit_base::DataElement::TYPE_BYTES: { |
| 268 switch (p.type()) { | 268 m->WriteData(p.bytes(), static_cast<int>(p.length())); |
| 269 case webkit_glue::ResourceRequestBody::TYPE_BYTES: { | 269 break; |
| 270 m->WriteData(p.bytes(), static_cast<int>(p.bytes_length())); | 270 } |
| 271 break; | 271 case webkit_base::DataElement::TYPE_FILE: { |
| 272 } | 272 WriteParam(m, p.path()); |
| 273 case webkit_glue::ResourceRequestBody::TYPE_FILE: { | 273 WriteParam(m, p.offset()); |
| 274 WriteParam(m, p.file_path()); | 274 WriteParam(m, p.length()); |
| 275 WriteParam(m, p.file_range_offset()); | 275 WriteParam(m, p.expected_modification_time()); |
| 276 WriteParam(m, p.file_range_length()); | 276 break; |
| 277 WriteParam(m, p.expected_file_modification_time()); | 277 } |
| 278 break; | 278 default: { |
| 279 } | 279 WriteParam(m, p.url()); |
| 280 default: { | 280 break; |
| 281 WriteParam(m, p.blob_url()); | |
| 282 break; | |
| 283 } | |
| 284 } | 281 } |
| 285 } | 282 } |
| 286 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { | 283 } |
| 287 int type; | 284 |
| 288 if (!ReadParam(m, iter, &type)) | 285 bool ParamTraits<webkit_base::DataElement>::Read( |
| 289 return false; | 286 const Message* m, PickleIterator* iter, param_type* r) { |
| 290 switch (type) { | 287 int type; |
| 291 case webkit_glue::ResourceRequestBody::TYPE_BYTES: { | 288 if (!ReadParam(m, iter, &type)) |
| 292 const char* data; | 289 return false; |
| 293 int len; | 290 switch (type) { |
| 294 if (!m->ReadData(iter, &data, &len)) | 291 case webkit_base::DataElement::TYPE_BYTES: { |
| 295 return false; | 292 const char* data; |
| 296 r->SetToBytes(data, len); | 293 int len; |
| 297 break; | 294 if (!m->ReadData(iter, &data, &len)) |
| 298 } | 295 return false; |
| 299 case webkit_glue::ResourceRequestBody::TYPE_FILE: { | 296 r->SetToBytes(data, len); |
| 300 FilePath file_path; | 297 break; |
| 301 uint64 offset, length; | |
| 302 base::Time expected_modification_time; | |
| 303 if (!ReadParam(m, iter, &file_path)) | |
| 304 return false; | |
| 305 if (!ReadParam(m, iter, &offset)) | |
| 306 return false; | |
| 307 if (!ReadParam(m, iter, &length)) | |
| 308 return false; | |
| 309 if (!ReadParam(m, iter, &expected_modification_time)) | |
| 310 return false; | |
| 311 r->SetToFilePathRange(file_path, offset, length, | |
| 312 expected_modification_time); | |
| 313 break; | |
| 314 } | |
| 315 default: { | |
| 316 DCHECK(type == webkit_glue::ResourceRequestBody::TYPE_BLOB); | |
| 317 GURL blob_url; | |
| 318 if (!ReadParam(m, iter, &blob_url)) | |
| 319 return false; | |
| 320 r->SetToBlobUrl(blob_url); | |
| 321 break; | |
| 322 } | |
| 323 } | 298 } |
| 324 return true; | 299 case webkit_base::DataElement::TYPE_FILE: { |
| 300 FilePath file_path; |
| 301 uint64 offset, length; |
| 302 base::Time expected_modification_time; |
| 303 if (!ReadParam(m, iter, &file_path)) |
| 304 return false; |
| 305 if (!ReadParam(m, iter, &offset)) |
| 306 return false; |
| 307 if (!ReadParam(m, iter, &length)) |
| 308 return false; |
| 309 if (!ReadParam(m, iter, &expected_modification_time)) |
| 310 return false; |
| 311 r->SetToFilePathRange(file_path, offset, length, |
| 312 expected_modification_time); |
| 313 break; |
| 314 } |
| 315 default: { |
| 316 DCHECK(type == webkit_base::DataElement::TYPE_BLOB); |
| 317 GURL blob_url; |
| 318 if (!ReadParam(m, iter, &blob_url)) |
| 319 return false; |
| 320 r->SetToBlobUrl(blob_url); |
| 321 break; |
| 322 } |
| 325 } | 323 } |
| 326 static void Log(const param_type& p, std::string* l) { | 324 return true; |
| 327 l->append("<webkit_glue::ResourceRequestBody::Element>"); | 325 } |
| 328 } | 326 |
| 329 }; | 327 void ParamTraits<webkit_base::DataElement>::Log( |
| 328 const param_type& p, std::string* l) { |
| 329 l->append("<webkit_base::DataElement>"); |
| 330 } |
| 330 | 331 |
| 331 void ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Write( | 332 void ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Write( |
| 332 Message* m, | 333 Message* m, |
| 333 const param_type& p) { | 334 const param_type& p) { |
| 334 WriteParam(m, p.get() != NULL); | 335 WriteParam(m, p.get() != NULL); |
| 335 if (p) { | 336 if (p) { |
| 336 WriteParam(m, *p->elements()); | 337 WriteParam(m, *p->elements()); |
| 337 WriteParam(m, p->identifier()); | 338 WriteParam(m, p->identifier()); |
| 338 } | 339 } |
| 339 } | 340 } |
| 340 | 341 |
| 341 bool ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Read( | 342 bool ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> >::Read( |
| 342 const Message* m, | 343 const Message* m, |
| 343 PickleIterator* iter, | 344 PickleIterator* iter, |
| 344 param_type* r) { | 345 param_type* r) { |
| 345 bool has_object; | 346 bool has_object; |
| 346 if (!ReadParam(m, iter, &has_object)) | 347 if (!ReadParam(m, iter, &has_object)) |
| 347 return false; | 348 return false; |
| 348 if (!has_object) | 349 if (!has_object) |
| 349 return true; | 350 return true; |
| 350 std::vector<webkit_glue::ResourceRequestBody::Element> elements; | 351 std::vector<webkit_base::DataElement> elements; |
| 351 if (!ReadParam(m, iter, &elements)) | 352 if (!ReadParam(m, iter, &elements)) |
| 352 return false; | 353 return false; |
| 353 int64 identifier; | 354 int64 identifier; |
| 354 if (!ReadParam(m, iter, &identifier)) | 355 if (!ReadParam(m, iter, &identifier)) |
| 355 return false; | 356 return false; |
| 356 *r = new webkit_glue::ResourceRequestBody; | 357 *r = new webkit_glue::ResourceRequestBody; |
| 357 (*r)->swap_elements(&elements); | 358 (*r)->swap_elements(&elements); |
| 358 (*r)->set_identifier(identifier); | 359 (*r)->set_identifier(identifier); |
| 359 return true; | 360 return true; |
| 360 } | 361 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 623 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
| 623 #include "content/public/common/common_param_traits_macros.h" | 624 #include "content/public/common/common_param_traits_macros.h" |
| 624 } // namespace IPC | 625 } // namespace IPC |
| 625 | 626 |
| 626 // Generate param traits log methods. | 627 // Generate param traits log methods. |
| 627 #include "ipc/param_traits_log_macros.h" | 628 #include "ipc/param_traits_log_macros.h" |
| 628 namespace IPC { | 629 namespace IPC { |
| 629 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 630 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
| 630 #include "content/public/common/common_param_traits_macros.h" | 631 #include "content/public/common/common_param_traits_macros.h" |
| 631 } // namespace IPC | 632 } // namespace IPC |
| OLD | NEW |