OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/host_port_pair.h" | 8 #include "net/base/host_port_pair.h" |
9 #include "net/base/upload_data.h" | 9 #include "net/base/upload_data.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 namespace IPC { | 50 namespace IPC { |
51 | 51 |
52 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { | 52 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { |
53 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars); | 53 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars); |
54 m->WriteString(p.possibly_invalid_spec()); | 54 m->WriteString(p.possibly_invalid_spec()); |
55 // TODO(brettw) bug 684583: Add encoding for query params. | 55 // TODO(brettw) bug 684583: Add encoding for query params. |
56 } | 56 } |
57 | 57 |
58 bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) { | 58 bool ParamTraits<GURL>::Read(const Message* m, PickleReader* iter, GURL* p) { |
59 std::string s; | 59 std::string s; |
60 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { | 60 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { |
61 *p = GURL(); | 61 *p = GURL(); |
62 return false; | 62 return false; |
63 } | 63 } |
64 *p = GURL(s); | 64 *p = GURL(s); |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { | 68 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { |
69 l->append(p.spec()); | 69 l->append(p.spec()); |
70 } | 70 } |
71 | 71 |
72 void ParamTraits<ResourceType::Type>::Write(Message* m, const param_type& p) { | 72 void ParamTraits<ResourceType::Type>::Write(Message* m, const param_type& p) { |
73 m->WriteInt(p); | 73 m->WriteInt(p); |
74 } | 74 } |
75 | 75 |
76 bool ParamTraits<ResourceType::Type>::Read(const Message* m, | 76 bool ParamTraits<ResourceType::Type>::Read(const Message* m, |
77 void** iter, | 77 PickleReader* iter, |
78 param_type* p) { | 78 param_type* p) { |
79 int type; | 79 int type; |
80 if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) | 80 if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) |
81 return false; | 81 return false; |
82 *p = ResourceType::FromInt(type); | 82 *p = ResourceType::FromInt(type); |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 void ParamTraits<ResourceType::Type>::Log(const param_type& p, std::string* l) { | 86 void ParamTraits<ResourceType::Type>::Log(const param_type& p, std::string* l) { |
87 std::string type; | 87 std::string type; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 LogParam(type, l); | 139 LogParam(type, l); |
140 } | 140 } |
141 | 141 |
142 void ParamTraits<net::URLRequestStatus>::Write(Message* m, | 142 void ParamTraits<net::URLRequestStatus>::Write(Message* m, |
143 const param_type& p) { | 143 const param_type& p) { |
144 WriteParam(m, static_cast<int>(p.status())); | 144 WriteParam(m, static_cast<int>(p.status())); |
145 WriteParam(m, p.error()); | 145 WriteParam(m, p.error()); |
146 } | 146 } |
147 | 147 |
148 bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, void** iter, | 148 bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, PickleReader* it
er, |
149 param_type* r) { | 149 param_type* r) { |
150 int status, error; | 150 int status, error; |
151 if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &error)) | 151 if (!ReadParam(m, iter, &status) || !ReadParam(m, iter, &error)) |
152 return false; | 152 return false; |
153 r->set_status(static_cast<net::URLRequestStatus::Status>(status)); | 153 r->set_status(static_cast<net::URLRequestStatus::Status>(status)); |
154 r->set_error(error); | 154 r->set_error(error); |
155 return true; | 155 return true; |
156 } | 156 } |
157 | 157 |
158 void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, | 158 void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 WriteParam(m, p.file_range_length()); | 230 WriteParam(m, p.file_range_length()); |
231 WriteParam(m, p.expected_file_modification_time()); | 231 WriteParam(m, p.expected_file_modification_time()); |
232 break; | 232 break; |
233 } | 233 } |
234 default: { | 234 default: { |
235 WriteParam(m, p.blob_url()); | 235 WriteParam(m, p.blob_url()); |
236 break; | 236 break; |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 static bool Read(const Message* m, void** iter, param_type* r) { | 240 static bool Read(const Message* m, PickleReader* iter, param_type* r) { |
241 int type; | 241 int type; |
242 if (!ReadParam(m, iter, &type)) | 242 if (!ReadParam(m, iter, &type)) |
243 return false; | 243 return false; |
244 switch (type) { | 244 switch (type) { |
245 case net::UploadData::TYPE_BYTES: { | 245 case net::UploadData::TYPE_BYTES: { |
246 const char* data; | 246 const char* data; |
247 int len; | 247 int len; |
248 if (!m->ReadData(iter, &data, &len)) | 248 if (!m->ReadData(iter, &data, &len)) |
249 return false; | 249 return false; |
250 r->SetToBytes(data, len); | 250 r->SetToBytes(data, len); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 const param_type& p) { | 301 const param_type& p) { |
302 WriteParam(m, p.get() != NULL); | 302 WriteParam(m, p.get() != NULL); |
303 if (p) { | 303 if (p) { |
304 WriteParam(m, *p->elements()); | 304 WriteParam(m, *p->elements()); |
305 WriteParam(m, p->identifier()); | 305 WriteParam(m, p->identifier()); |
306 WriteParam(m, p->is_chunked()); | 306 WriteParam(m, p->is_chunked()); |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, | 310 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, |
311 void** iter, | 311 PickleReader* iter, |
312 param_type* r) { | 312 param_type* r) { |
313 bool has_object; | 313 bool has_object; |
314 if (!ReadParam(m, iter, &has_object)) | 314 if (!ReadParam(m, iter, &has_object)) |
315 return false; | 315 return false; |
316 if (!has_object) | 316 if (!has_object) |
317 return true; | 317 return true; |
318 std::vector<net::UploadData::Element> elements; | 318 std::vector<net::UploadData::Element> elements; |
319 if (!ReadParam(m, iter, &elements)) | 319 if (!ReadParam(m, iter, &elements)) |
320 return false; | 320 return false; |
321 int64 identifier; | 321 int64 identifier; |
(...skipping 12 matching lines...) Expand all Loading... |
334 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, | 334 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, |
335 std::string* l) { | 335 std::string* l) { |
336 l->append("<net::UploadData>"); | 336 l->append("<net::UploadData>"); |
337 } | 337 } |
338 | 338 |
339 void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { | 339 void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { |
340 WriteParam(m, p.host()); | 340 WriteParam(m, p.host()); |
341 WriteParam(m, p.port()); | 341 WriteParam(m, p.port()); |
342 } | 342 } |
343 | 343 |
344 bool ParamTraits<net::HostPortPair>::Read(const Message* m, void** iter, | 344 bool ParamTraits<net::HostPortPair>::Read(const Message* m, PickleReader* iter, |
345 param_type* r) { | 345 param_type* r) { |
346 std::string host; | 346 std::string host; |
347 uint16 port; | 347 uint16 port; |
348 if (!ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) | 348 if (!ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) |
349 return false; | 349 return false; |
350 | 350 |
351 r->set_host(host); | 351 r->set_host(host); |
352 r->set_port(port); | 352 r->set_port(port); |
353 return true; | 353 return true; |
354 } | 354 } |
355 | 355 |
356 void ParamTraits<net::HostPortPair>::Log(const param_type& p, std::string* l) { | 356 void ParamTraits<net::HostPortPair>::Log(const param_type& p, std::string* l) { |
357 l->append(p.ToString()); | 357 l->append(p.ToString()); |
358 } | 358 } |
359 | 359 |
360 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( | 360 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Write( |
361 Message* m, const param_type& p) { | 361 Message* m, const param_type& p) { |
362 WriteParam(m, p.get() != NULL); | 362 WriteParam(m, p.get() != NULL); |
363 if (p) { | 363 if (p) { |
364 // Do not disclose Set-Cookie headers over IPC. | 364 // Do not disclose Set-Cookie headers over IPC. |
365 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); | 365 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 bool ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Read( | 369 bool ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Read( |
370 const Message* m, void** iter, param_type* r) { | 370 const Message* m, PickleReader* iter, param_type* r) { |
371 bool has_object; | 371 bool has_object; |
372 if (!ReadParam(m, iter, &has_object)) | 372 if (!ReadParam(m, iter, &has_object)) |
373 return false; | 373 return false; |
374 if (has_object) | 374 if (has_object) |
375 *r = new net::HttpResponseHeaders(*m, iter); | 375 *r = new net::HttpResponseHeaders(*m, iter); |
376 return true; | 376 return true; |
377 } | 377 } |
378 | 378 |
379 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( | 379 void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( |
380 const param_type& p, std::string* l) { | 380 const param_type& p, std::string* l) { |
381 l->append("<HttpResponseHeaders>"); | 381 l->append("<HttpResponseHeaders>"); |
382 } | 382 } |
383 | 383 |
384 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { | 384 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { |
385 WriteParam(m, p.address()); | 385 WriteParam(m, p.address()); |
386 WriteParam(m, p.port()); | 386 WriteParam(m, p.port()); |
387 } | 387 } |
388 | 388 |
389 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, void** iter, | 389 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleReader* iter, |
390 param_type* p) { | 390 param_type* p) { |
391 net::IPAddressNumber address; | 391 net::IPAddressNumber address; |
392 int port; | 392 int port; |
393 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) | 393 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) |
394 return false; | 394 return false; |
395 *p = net::IPEndPoint(address, port); | 395 *p = net::IPEndPoint(address, port); |
396 return true; | 396 return true; |
397 } | 397 } |
398 | 398 |
399 void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { | 399 void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { |
400 LogParam("IPEndPoint:" + p.ToString(), l); | 400 LogParam("IPEndPoint:" + p.ToString(), l); |
401 } | 401 } |
402 | 402 |
403 void ParamTraits<base::PlatformFileInfo>::Write( | 403 void ParamTraits<base::PlatformFileInfo>::Write( |
404 Message* m, const param_type& p) { | 404 Message* m, const param_type& p) { |
405 WriteParam(m, p.size); | 405 WriteParam(m, p.size); |
406 WriteParam(m, p.is_directory); | 406 WriteParam(m, p.is_directory); |
407 WriteParam(m, p.last_modified.ToDoubleT()); | 407 WriteParam(m, p.last_modified.ToDoubleT()); |
408 WriteParam(m, p.last_accessed.ToDoubleT()); | 408 WriteParam(m, p.last_accessed.ToDoubleT()); |
409 WriteParam(m, p.creation_time.ToDoubleT()); | 409 WriteParam(m, p.creation_time.ToDoubleT()); |
410 } | 410 } |
411 | 411 |
412 bool ParamTraits<base::PlatformFileInfo>::Read( | 412 bool ParamTraits<base::PlatformFileInfo>::Read( |
413 const Message* m, void** iter, param_type* p) { | 413 const Message* m, PickleReader* iter, param_type* p) { |
414 double last_modified; | 414 double last_modified; |
415 double last_accessed; | 415 double last_accessed; |
416 double creation_time; | 416 double creation_time; |
417 bool result = | 417 bool result = |
418 ReadParam(m, iter, &p->size) && | 418 ReadParam(m, iter, &p->size) && |
419 ReadParam(m, iter, &p->is_directory) && | 419 ReadParam(m, iter, &p->is_directory) && |
420 ReadParam(m, iter, &last_modified) && | 420 ReadParam(m, iter, &last_modified) && |
421 ReadParam(m, iter, &last_accessed) && | 421 ReadParam(m, iter, &last_accessed) && |
422 ReadParam(m, iter, &creation_time); | 422 ReadParam(m, iter, &creation_time); |
423 if (result) { | 423 if (result) { |
(...skipping 17 matching lines...) Expand all Loading... |
441 l->append(","); | 441 l->append(","); |
442 LogParam(p.creation_time.ToDoubleT(), l); | 442 LogParam(p.creation_time.ToDoubleT(), l); |
443 l->append(")"); | 443 l->append(")"); |
444 } | 444 } |
445 | 445 |
446 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { | 446 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { |
447 m->WriteInt(p.x()); | 447 m->WriteInt(p.x()); |
448 m->WriteInt(p.y()); | 448 m->WriteInt(p.y()); |
449 } | 449 } |
450 | 450 |
451 bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter, | 451 bool ParamTraits<gfx::Point>::Read(const Message* m, PickleReader* iter, |
452 gfx::Point* r) { | 452 gfx::Point* r) { |
453 int x, y; | 453 int x, y; |
454 if (!m->ReadInt(iter, &x) || | 454 if (!m->ReadInt(iter, &x) || |
455 !m->ReadInt(iter, &y)) | 455 !m->ReadInt(iter, &y)) |
456 return false; | 456 return false; |
457 r->set_x(x); | 457 r->set_x(x); |
458 r->set_y(y); | 458 r->set_y(y); |
459 return true; | 459 return true; |
460 } | 460 } |
461 | 461 |
462 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { | 462 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { |
463 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); | 463 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); |
464 } | 464 } |
465 | 465 |
466 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { | 466 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { |
467 m->WriteInt(p.width()); | 467 m->WriteInt(p.width()); |
468 m->WriteInt(p.height()); | 468 m->WriteInt(p.height()); |
469 } | 469 } |
470 | 470 |
471 bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) { | 471 bool ParamTraits<gfx::Size>::Read(const Message* m, PickleReader* iter, gfx::Siz
e* r) { |
472 int w, h; | 472 int w, h; |
473 if (!m->ReadInt(iter, &w) || | 473 if (!m->ReadInt(iter, &w) || |
474 !m->ReadInt(iter, &h)) | 474 !m->ReadInt(iter, &h)) |
475 return false; | 475 return false; |
476 r->set_width(w); | 476 r->set_width(w); |
477 r->set_height(h); | 477 r->set_height(h); |
478 return true; | 478 return true; |
479 } | 479 } |
480 | 480 |
481 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) { | 481 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) { |
482 l->append(base::StringPrintf("(%d, %d)", p.width(), p.height())); | 482 l->append(base::StringPrintf("(%d, %d)", p.width(), p.height())); |
483 } | 483 } |
484 | 484 |
485 void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { | 485 void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { |
486 m->WriteInt(p.x()); | 486 m->WriteInt(p.x()); |
487 m->WriteInt(p.y()); | 487 m->WriteInt(p.y()); |
488 m->WriteInt(p.width()); | 488 m->WriteInt(p.width()); |
489 m->WriteInt(p.height()); | 489 m->WriteInt(p.height()); |
490 } | 490 } |
491 | 491 |
492 bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) { | 492 bool ParamTraits<gfx::Rect>::Read(const Message* m, PickleReader* iter, gfx::Rec
t* r) { |
493 int x, y, w, h; | 493 int x, y, w, h; |
494 if (!m->ReadInt(iter, &x) || | 494 if (!m->ReadInt(iter, &x) || |
495 !m->ReadInt(iter, &y) || | 495 !m->ReadInt(iter, &y) || |
496 !m->ReadInt(iter, &w) || | 496 !m->ReadInt(iter, &w) || |
497 !m->ReadInt(iter, &h)) | 497 !m->ReadInt(iter, &h)) |
498 return false; | 498 return false; |
499 r->set_x(x); | 499 r->set_x(x); |
500 r->set_y(y); | 500 r->set_y(y); |
501 r->set_width(w); | 501 r->set_width(w); |
502 r->set_height(h); | 502 r->set_height(h); |
503 return true; | 503 return true; |
504 } | 504 } |
505 | 505 |
506 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { | 506 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { |
507 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), | 507 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), |
508 p.width(), p.height())); | 508 p.width(), p.height())); |
509 } | 509 } |
510 | 510 |
511 void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { | 511 void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { |
512 m->WriteSize(r.start()); | 512 m->WriteSize(r.start()); |
513 m->WriteSize(r.end()); | 513 m->WriteSize(r.end()); |
514 } | 514 } |
515 | 515 |
516 bool ParamTraits<ui::Range>::Read(const Message* m, void** iter, ui::Range* r) { | 516 bool ParamTraits<ui::Range>::Read(const Message* m, PickleReader* iter, ui::Rang
e* r) { |
517 size_t start, end; | 517 size_t start, end; |
518 if (!m->ReadSize(iter, &start) || !m->ReadSize(iter, &end)) | 518 if (!m->ReadSize(iter, &start) || !m->ReadSize(iter, &end)) |
519 return false; | 519 return false; |
520 r->set_start(start); | 520 r->set_start(start); |
521 r->set_end(end); | 521 r->set_end(end); |
522 return true; | 522 return true; |
523 } | 523 } |
524 | 524 |
525 void ParamTraits<ui::Range>::Log(const ui::Range& r, std::string* l) { | 525 void ParamTraits<ui::Range>::Log(const ui::Range& r, std::string* l) { |
526 l->append(base::StringPrintf("(%"PRIuS", %"PRIuS")", r.start(), r.end())); | 526 l->append(base::StringPrintf("(%"PRIuS", %"PRIuS")", r.start(), r.end())); |
527 } | 527 } |
528 | 528 |
529 void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { | 529 void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { |
530 size_t fixed_size = sizeof(SkBitmap_Data); | 530 size_t fixed_size = sizeof(SkBitmap_Data); |
531 SkBitmap_Data bmp_data; | 531 SkBitmap_Data bmp_data; |
532 bmp_data.InitSkBitmapDataForTransfer(p); | 532 bmp_data.InitSkBitmapDataForTransfer(p); |
533 m->WriteData(reinterpret_cast<const char*>(&bmp_data), | 533 m->WriteData(reinterpret_cast<const char*>(&bmp_data), |
534 static_cast<int>(fixed_size)); | 534 static_cast<int>(fixed_size)); |
535 size_t pixel_size = p.getSize(); | 535 size_t pixel_size = p.getSize(); |
536 SkAutoLockPixels p_lock(p); | 536 SkAutoLockPixels p_lock(p); |
537 m->WriteData(reinterpret_cast<const char*>(p.getPixels()), | 537 m->WriteData(reinterpret_cast<const char*>(p.getPixels()), |
538 static_cast<int>(pixel_size)); | 538 static_cast<int>(pixel_size)); |
539 } | 539 } |
540 | 540 |
541 bool ParamTraits<SkBitmap>::Read(const Message* m, void** iter, SkBitmap* r) { | 541 bool ParamTraits<SkBitmap>::Read(const Message* m, PickleReader* iter, SkBitmap*
r) { |
542 const char* fixed_data; | 542 const char* fixed_data; |
543 int fixed_data_size = 0; | 543 int fixed_data_size = 0; |
544 if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || | 544 if (!m->ReadData(iter, &fixed_data, &fixed_data_size) || |
545 (fixed_data_size <= 0)) { | 545 (fixed_data_size <= 0)) { |
546 NOTREACHED(); | 546 NOTREACHED(); |
547 return false; | 547 return false; |
548 } | 548 } |
549 if (fixed_data_size != sizeof(SkBitmap_Data)) | 549 if (fixed_data_size != sizeof(SkBitmap_Data)) |
550 return false; // Message is malformed. | 550 return false; // Message is malformed. |
551 | 551 |
552 const char* variable_data; | 552 const char* variable_data; |
553 int variable_data_size = 0; | 553 int variable_data_size = 0; |
554 if (!m->ReadData(iter, &variable_data, &variable_data_size) || | 554 if (!m->ReadData(iter, &variable_data, &variable_data_size) || |
555 (variable_data_size < 0)) { | 555 (variable_data_size < 0)) { |
556 NOTREACHED(); | 556 NOTREACHED(); |
557 return false; | 557 return false; |
558 } | 558 } |
559 const SkBitmap_Data* bmp_data = | 559 const SkBitmap_Data* bmp_data = |
560 reinterpret_cast<const SkBitmap_Data*>(fixed_data); | 560 reinterpret_cast<const SkBitmap_Data*>(fixed_data); |
561 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); | 561 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); |
562 } | 562 } |
563 | 563 |
564 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { | 564 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { |
565 l->append("<SkBitmap>"); | 565 l->append("<SkBitmap>"); |
566 } | 566 } |
567 | 567 |
568 } // namespace IPC | 568 } // namespace IPC |
OLD | NEW |