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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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<AudioParameters>::Write(Message* m, |
| 512 const AudioParameters& p) { |
| 513 m->WriteInt(static_cast<int>(p.format())); |
| 514 m->WriteInt(static_cast<int>(p.channel_layout())); |
| 515 m->WriteInt(p.samples_per_second()); |
| 516 m->WriteInt(p.bits_per_sample()); |
| 517 m->WriteInt(p.samples_per_packet()); |
| 518 m->WriteInt(p.channels()); |
| 519 } |
| 520 |
| 521 bool ParamTraits<AudioParameters>::Read(const Message* m, void** iter, |
| 522 AudioParameters* r) { |
| 523 int format, channel_layout, samples_per_second, bits_per_sample, |
| 524 samples_per_packet, channels; |
| 525 |
| 526 if (!m->ReadInt(iter, &format) || |
| 527 !m->ReadInt(iter, &channel_layout) || |
| 528 !m->ReadInt(iter, &samples_per_second) || |
| 529 !m->ReadInt(iter, &bits_per_sample) || |
| 530 !m->ReadInt(iter, &samples_per_packet) || |
| 531 !m->ReadInt(iter, &channels)) |
| 532 return false; |
| 533 r->Reset(static_cast<AudioParameters::Format>(format), |
| 534 static_cast<ChannelLayout>(channel_layout), |
| 535 samples_per_second, bits_per_sample, samples_per_packet); |
| 536 return true; |
| 537 } |
| 538 |
| 539 void ParamTraits<AudioParameters>::Log(const AudioParameters& p, |
| 540 std::string* l) { |
| 541 l->append(base::StringPrintf("<AudioParameters>")); |
| 542 } |
| 543 |
511 void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { | 544 void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) { |
512 m->WriteSize(r.start()); | 545 m->WriteSize(r.start()); |
513 m->WriteSize(r.end()); | 546 m->WriteSize(r.end()); |
514 } | 547 } |
515 | 548 |
516 bool ParamTraits<ui::Range>::Read(const Message* m, void** iter, ui::Range* r) { | 549 bool ParamTraits<ui::Range>::Read(const Message* m, void** iter, ui::Range* r) { |
517 size_t start, end; | 550 size_t start, end; |
518 if (!m->ReadSize(iter, &start) || !m->ReadSize(iter, &end)) | 551 if (!m->ReadSize(iter, &start) || !m->ReadSize(iter, &end)) |
519 return false; | 552 return false; |
520 r->set_start(start); | 553 r->set_start(start); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 const SkBitmap_Data* bmp_data = | 592 const SkBitmap_Data* bmp_data = |
560 reinterpret_cast<const SkBitmap_Data*>(fixed_data); | 593 reinterpret_cast<const SkBitmap_Data*>(fixed_data); |
561 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); | 594 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); |
562 } | 595 } |
563 | 596 |
564 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { | 597 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { |
565 l->append("<SkBitmap>"); | 598 l->append("<SkBitmap>"); |
566 } | 599 } |
567 | 600 |
568 } // namespace IPC | 601 } // namespace IPC |
OLD | NEW |