| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/render_messages_params.h" | 5 #include "chrome/common/render_messages_params.h" |
| 6 | 6 |
| 7 #include "chrome/common/common_param_traits.h" | 7 #include "chrome/common/common_param_traits.h" |
| 8 #include "chrome/common/extensions/extension_constants.h" | 8 #include "chrome/common/extensions/extension_constants.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "net/base/upload_data.h" | 10 #include "net/base/upload_data.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // base::SharedMemoryHandle to HANDLE. We do not need to initialize this | 132 // base::SharedMemoryHandle to HANDLE. We do not need to initialize this |
| 133 // variable on Posix because it maps base::SharedMemoryHandle to | 133 // variable on Posix because it maps base::SharedMemoryHandle to |
| 134 // FileDescriptior, which has the default constructor. | 134 // FileDescriptior, which has the default constructor. |
| 135 metafile_data_handle = INVALID_HANDLE_VALUE; | 135 metafile_data_handle = INVALID_HANDLE_VALUE; |
| 136 #endif | 136 #endif |
| 137 } | 137 } |
| 138 | 138 |
| 139 ViewHostMsg_DidPrintPage_Params::~ViewHostMsg_DidPrintPage_Params() { | 139 ViewHostMsg_DidPrintPage_Params::~ViewHostMsg_DidPrintPage_Params() { |
| 140 } | 140 } |
| 141 | 141 |
| 142 ViewHostMsg_Audio_CreateStream_Params::ViewHostMsg_Audio_CreateStream_Params() { | |
| 143 } | |
| 144 | |
| 145 ViewHostMsg_Audio_CreateStream_Params:: | |
| 146 ~ViewHostMsg_Audio_CreateStream_Params() { | |
| 147 } | |
| 148 | |
| 149 ViewHostMsg_ShowPopup_Params::ViewHostMsg_ShowPopup_Params() | 142 ViewHostMsg_ShowPopup_Params::ViewHostMsg_ShowPopup_Params() |
| 150 : item_height(0), | 143 : item_height(0), |
| 151 item_font_size(0), | 144 item_font_size(0), |
| 152 selected_item(0), | 145 selected_item(0), |
| 153 right_aligned(false) { | 146 right_aligned(false) { |
| 154 } | 147 } |
| 155 | 148 |
| 156 ViewHostMsg_ShowPopup_Params::~ViewHostMsg_ShowPopup_Params() { | 149 ViewHostMsg_ShowPopup_Params::~ViewHostMsg_ShowPopup_Params() { |
| 157 } | 150 } |
| 158 | 151 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 event = "GESTURE_AUTO"; | 367 event = "GESTURE_AUTO"; |
| 375 break; | 368 break; |
| 376 default: | 369 default: |
| 377 event = "GESTURE_UNKNOWN"; | 370 event = "GESTURE_UNKNOWN"; |
| 378 break; | 371 break; |
| 379 } | 372 } |
| 380 LogParam(event, l); | 373 LogParam(event, l); |
| 381 } | 374 } |
| 382 }; | 375 }; |
| 383 | 376 |
| 384 // Traits for AudioManager::Format. | |
| 385 template <> | |
| 386 struct ParamTraits<AudioParameters::Format> { | |
| 387 typedef AudioParameters::Format param_type; | |
| 388 static void Write(Message* m, const param_type& p) { | |
| 389 m->WriteInt(p); | |
| 390 } | |
| 391 static bool Read(const Message* m, void** iter, param_type* p) { | |
| 392 int type; | |
| 393 if (!m->ReadInt(iter, &type)) | |
| 394 return false; | |
| 395 *p = static_cast<AudioParameters::Format>(type); | |
| 396 return true; | |
| 397 } | |
| 398 static void Log(const param_type& p, std::string* l) { | |
| 399 std::string format; | |
| 400 switch (p) { | |
| 401 case AudioParameters::AUDIO_PCM_LINEAR: | |
| 402 format = "AUDIO_PCM_LINEAR"; | |
| 403 break; | |
| 404 case AudioParameters::AUDIO_PCM_LOW_LATENCY: | |
| 405 format = "AUDIO_PCM_LOW_LATENCY"; | |
| 406 break; | |
| 407 case AudioParameters::AUDIO_MOCK: | |
| 408 format = "AUDIO_MOCK"; | |
| 409 break; | |
| 410 default: | |
| 411 format = "AUDIO_LAST_FORMAT"; | |
| 412 break; | |
| 413 } | |
| 414 LogParam(format, l); | |
| 415 } | |
| 416 }; | |
| 417 | |
| 418 template <> | 377 template <> |
| 419 struct ParamTraits<WindowContainerType> { | 378 struct ParamTraits<WindowContainerType> { |
| 420 typedef WindowContainerType param_type; | 379 typedef WindowContainerType param_type; |
| 421 static void Write(Message* m, const param_type& p) { | 380 static void Write(Message* m, const param_type& p) { |
| 422 int val = static_cast<int>(p); | 381 int val = static_cast<int>(p); |
| 423 WriteParam(m, val); | 382 WriteParam(m, val); |
| 424 } | 383 } |
| 425 static bool Read(const Message* m, void** iter, param_type* p) { | 384 static bool Read(const Message* m, void** iter, param_type* p) { |
| 426 int val = 0; | 385 int val = 0; |
| 427 if (!ReadParam(m, iter, &val) || | 386 if (!ReadParam(m, iter, &val) || |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 LogParam(p.state, l); | 484 LogParam(p.state, l); |
| 526 l->append(", "); | 485 l->append(", "); |
| 527 LogParam(p.navigation_type, l); | 486 LogParam(p.navigation_type, l); |
| 528 l->append(", "); | 487 l->append(", "); |
| 529 LogParam(p.request_time, l); | 488 LogParam(p.request_time, l); |
| 530 l->append(", "); | 489 l->append(", "); |
| 531 LogParam(p.extra_headers, l); | 490 LogParam(p.extra_headers, l); |
| 532 l->append(")"); | 491 l->append(")"); |
| 533 } | 492 } |
| 534 | 493 |
| 535 void ParamTraits<ViewMsg_AudioStreamState_Params>::Write(Message* m, | |
| 536 const param_type& p) { | |
| 537 m->WriteInt(p.state); | |
| 538 } | |
| 539 | |
| 540 bool ParamTraits<ViewMsg_AudioStreamState_Params>::Read(const Message* m, | |
| 541 void** iter, | |
| 542 param_type* p) { | |
| 543 int type; | |
| 544 if (!m->ReadInt(iter, &type)) | |
| 545 return false; | |
| 546 p->state = static_cast<ViewMsg_AudioStreamState_Params::State>(type); | |
| 547 return true; | |
| 548 } | |
| 549 | |
| 550 void ParamTraits<ViewMsg_AudioStreamState_Params>::Log(const param_type& p, | |
| 551 std::string* l) { | |
| 552 std::string state; | |
| 553 switch (p.state) { | |
| 554 case ViewMsg_AudioStreamState_Params::kPlaying: | |
| 555 state = "ViewMsg_AudioStreamState_Params::kPlaying"; | |
| 556 break; | |
| 557 case ViewMsg_AudioStreamState_Params::kPaused: | |
| 558 state = "ViewMsg_AudioStreamState_Params::kPaused"; | |
| 559 break; | |
| 560 case ViewMsg_AudioStreamState_Params::kError: | |
| 561 state = "ViewMsg_AudioStreamState_Params::kError"; | |
| 562 break; | |
| 563 default: | |
| 564 state = "UNKNOWN"; | |
| 565 break; | |
| 566 } | |
| 567 LogParam(state, l); | |
| 568 } | |
| 569 | |
| 570 void ParamTraits<ViewMsg_StopFinding_Params>::Write(Message* m, | 494 void ParamTraits<ViewMsg_StopFinding_Params>::Write(Message* m, |
| 571 const param_type& p) { | 495 const param_type& p) { |
| 572 m->WriteInt(p.action); | 496 m->WriteInt(p.action); |
| 573 } | 497 } |
| 574 | 498 |
| 575 bool ParamTraits<ViewMsg_StopFinding_Params>::Read(const Message* m, | 499 bool ParamTraits<ViewMsg_StopFinding_Params>::Read(const Message* m, |
| 576 void** iter, | 500 void** iter, |
| 577 param_type* p) { | 501 param_type* p) { |
| 578 int type; | 502 int type; |
| 579 if (!m->ReadInt(iter, &type)) | 503 if (!m->ReadInt(iter, &type)) |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 ReadParam(m, iter, &p->page_size) && | 898 ReadParam(m, iter, &p->page_size) && |
| 975 ReadParam(m, iter, &p->content_area) && | 899 ReadParam(m, iter, &p->content_area) && |
| 976 ReadParam(m, iter, &p->has_visible_overlays); | 900 ReadParam(m, iter, &p->has_visible_overlays); |
| 977 } | 901 } |
| 978 | 902 |
| 979 void ParamTraits<ViewHostMsg_DidPrintPage_Params>::Log(const param_type& p, | 903 void ParamTraits<ViewHostMsg_DidPrintPage_Params>::Log(const param_type& p, |
| 980 std::string* l) { | 904 std::string* l) { |
| 981 l->append("<ViewHostMsg_DidPrintPage_Params>"); | 905 l->append("<ViewHostMsg_DidPrintPage_Params>"); |
| 982 } | 906 } |
| 983 | 907 |
| 984 void ParamTraits<ViewHostMsg_Audio_CreateStream_Params>::Write( | |
| 985 Message* m, | |
| 986 const param_type& p) { | |
| 987 WriteParam(m, p.params.format); | |
| 988 WriteParam(m, p.params.channels); | |
| 989 WriteParam(m, p.params.sample_rate); | |
| 990 WriteParam(m, p.params.bits_per_sample); | |
| 991 WriteParam(m, p.params.samples_per_packet); | |
| 992 } | |
| 993 | |
| 994 bool ParamTraits<ViewHostMsg_Audio_CreateStream_Params>::Read(const Message* m, | |
| 995 void** iter, | |
| 996 param_type* p) { | |
| 997 return | |
| 998 ReadParam(m, iter, &p->params.format) && | |
| 999 ReadParam(m, iter, &p->params.channels) && | |
| 1000 ReadParam(m, iter, &p->params.sample_rate) && | |
| 1001 ReadParam(m, iter, &p->params.bits_per_sample) && | |
| 1002 ReadParam(m, iter, &p->params.samples_per_packet); | |
| 1003 } | |
| 1004 | |
| 1005 void ParamTraits<ViewHostMsg_Audio_CreateStream_Params>::Log( | |
| 1006 const param_type& p, | |
| 1007 std::string* l) { | |
| 1008 l->append("<ViewHostMsg_Audio_CreateStream_Params>("); | |
| 1009 LogParam(p.params.format, l); | |
| 1010 l->append(", "); | |
| 1011 LogParam(p.params.channels, l); | |
| 1012 l->append(", "); | |
| 1013 LogParam(p.params.sample_rate, l); | |
| 1014 l->append(", "); | |
| 1015 LogParam(p.params.bits_per_sample, l); | |
| 1016 l->append(", "); | |
| 1017 LogParam(p.params.samples_per_packet, l); | |
| 1018 l->append(")"); | |
| 1019 } | |
| 1020 | |
| 1021 void ParamTraits<ViewHostMsg_ShowPopup_Params>::Write(Message* m, | 908 void ParamTraits<ViewHostMsg_ShowPopup_Params>::Write(Message* m, |
| 1022 const param_type& p) { | 909 const param_type& p) { |
| 1023 WriteParam(m, p.bounds); | 910 WriteParam(m, p.bounds); |
| 1024 WriteParam(m, p.item_height); | 911 WriteParam(m, p.item_height); |
| 1025 WriteParam(m, p.item_font_size); | 912 WriteParam(m, p.item_font_size); |
| 1026 WriteParam(m, p.selected_item); | 913 WriteParam(m, p.selected_item); |
| 1027 WriteParam(m, p.popup_items); | 914 WriteParam(m, p.popup_items); |
| 1028 WriteParam(m, p.right_aligned); | 915 WriteParam(m, p.right_aligned); |
| 1029 } | 916 } |
| 1030 | 917 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 l->append(", "); | 1332 l->append(", "); |
| 1446 LogParam(p.tag_name, l); | 1333 LogParam(p.tag_name, l); |
| 1447 l->append(", "); | 1334 l->append(", "); |
| 1448 LogParam(p.parent, l); | 1335 LogParam(p.parent, l); |
| 1449 l->append(", "); | 1336 l->append(", "); |
| 1450 LogParam(p.children, l); | 1337 LogParam(p.children, l); |
| 1451 l->append(")"); | 1338 l->append(")"); |
| 1452 } | 1339 } |
| 1453 | 1340 |
| 1454 } // namespace IPC | 1341 } // namespace IPC |
| OLD | NEW |