| 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 // Get basic type definitions. | 5 // Get basic type definitions. |
| 6 #define IPC_MESSAGE_IMPL | 6 #define IPC_MESSAGE_IMPL |
| 7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/common/common_param_traits.h" | 8 #include "chrome/common/common_param_traits.h" |
| 9 | 9 |
| 10 // Generate constructors. | 10 // Generate constructors. |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 LogParam(p.attributes, l); | 793 LogParam(p.attributes, l); |
| 794 l->append(", "); | 794 l->append(", "); |
| 795 LogParam(p.children, l); | 795 LogParam(p.children, l); |
| 796 l->append(", "); | 796 l->append(", "); |
| 797 LogParam(p.html_attributes, l); | 797 LogParam(p.html_attributes, l); |
| 798 l->append(", "); | 798 l->append(", "); |
| 799 LogParam(p.indirect_child_ids, l); | 799 LogParam(p.indirect_child_ids, l); |
| 800 l->append(")"); | 800 l->append(")"); |
| 801 } | 801 } |
| 802 | 802 |
| 803 // Only the webkit_blob::BlobData ParamTraits<> definition needs this | |
| 804 // definition, so keep this in the implementation file so we can forward declare | |
| 805 // BlobData in the header. | |
| 806 template <> | |
| 807 struct ParamTraits<webkit_blob::BlobData::Item> { | |
| 808 typedef webkit_blob::BlobData::Item param_type; | |
| 809 static void Write(Message* m, const param_type& p) { | |
| 810 WriteParam(m, static_cast<int>(p.type())); | |
| 811 if (p.type() == webkit_blob::BlobData::TYPE_DATA) { | |
| 812 WriteParam(m, p.data()); | |
| 813 } else if (p.type() == webkit_blob::BlobData::TYPE_FILE) { | |
| 814 WriteParam(m, p.file_path()); | |
| 815 WriteParam(m, p.offset()); | |
| 816 WriteParam(m, p.length()); | |
| 817 WriteParam(m, p.expected_modification_time()); | |
| 818 } else { | |
| 819 WriteParam(m, p.blob_url()); | |
| 820 WriteParam(m, p.offset()); | |
| 821 WriteParam(m, p.length()); | |
| 822 } | |
| 823 } | |
| 824 static bool Read(const Message* m, void** iter, param_type* r) { | |
| 825 int type; | |
| 826 if (!ReadParam(m, iter, &type)) | |
| 827 return false; | |
| 828 if (type == webkit_blob::BlobData::TYPE_DATA) { | |
| 829 std::string data; | |
| 830 if (!ReadParam(m, iter, &data)) | |
| 831 return false; | |
| 832 r->SetToData(data); | |
| 833 } else if (type == webkit_blob::BlobData::TYPE_FILE) { | |
| 834 FilePath file_path; | |
| 835 uint64 offset, length; | |
| 836 base::Time expected_modification_time; | |
| 837 if (!ReadParam(m, iter, &file_path)) | |
| 838 return false; | |
| 839 if (!ReadParam(m, iter, &offset)) | |
| 840 return false; | |
| 841 if (!ReadParam(m, iter, &length)) | |
| 842 return false; | |
| 843 if (!ReadParam(m, iter, &expected_modification_time)) | |
| 844 return false; | |
| 845 r->SetToFile(file_path, offset, length, expected_modification_time); | |
| 846 } else { | |
| 847 DCHECK(type == webkit_blob::BlobData::TYPE_BLOB); | |
| 848 GURL blob_url; | |
| 849 uint64 offset, length; | |
| 850 if (!ReadParam(m, iter, &blob_url)) | |
| 851 return false; | |
| 852 if (!ReadParam(m, iter, &offset)) | |
| 853 return false; | |
| 854 if (!ReadParam(m, iter, &length)) | |
| 855 return false; | |
| 856 r->SetToBlob(blob_url, offset, length); | |
| 857 } | |
| 858 return true; | |
| 859 } | |
| 860 static void Log(const param_type& p, std::string* l) { | |
| 861 l->append("<BlobData::Item>"); | |
| 862 } | |
| 863 }; | |
| 864 | |
| 865 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Write( | |
| 866 Message* m, const param_type& p) { | |
| 867 WriteParam(m, p.get() != NULL); | |
| 868 if (p) { | |
| 869 WriteParam(m, p->items()); | |
| 870 WriteParam(m, p->content_type()); | |
| 871 WriteParam(m, p->content_disposition()); | |
| 872 } | |
| 873 } | |
| 874 | |
| 875 bool ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Read( | |
| 876 const Message* m, void** iter, param_type* r) { | |
| 877 bool has_object; | |
| 878 if (!ReadParam(m, iter, &has_object)) | |
| 879 return false; | |
| 880 if (!has_object) | |
| 881 return true; | |
| 882 std::vector<webkit_blob::BlobData::Item> items; | |
| 883 if (!ReadParam(m, iter, &items)) | |
| 884 return false; | |
| 885 std::string content_type; | |
| 886 if (!ReadParam(m, iter, &content_type)) | |
| 887 return false; | |
| 888 std::string content_disposition; | |
| 889 if (!ReadParam(m, iter, &content_disposition)) | |
| 890 return false; | |
| 891 *r = new webkit_blob::BlobData; | |
| 892 (*r)->swap_items(&items); | |
| 893 (*r)->set_content_type(content_type); | |
| 894 (*r)->set_content_disposition(content_disposition); | |
| 895 return true; | |
| 896 } | |
| 897 | |
| 898 void ParamTraits<scoped_refptr<webkit_blob::BlobData> >::Log( | |
| 899 const param_type& p, std::string* l) { | |
| 900 l->append("<webkit_blob::BlobData>"); | |
| 901 } | |
| 902 | |
| 903 void ParamTraits<AudioBuffersState>::Write(Message* m, const param_type& p) { | 803 void ParamTraits<AudioBuffersState>::Write(Message* m, const param_type& p) { |
| 904 WriteParam(m, p.pending_bytes); | 804 WriteParam(m, p.pending_bytes); |
| 905 WriteParam(m, p.hardware_delay_bytes); | 805 WriteParam(m, p.hardware_delay_bytes); |
| 906 WriteParam(m, p.timestamp); | 806 WriteParam(m, p.timestamp); |
| 907 } | 807 } |
| 908 | 808 |
| 909 bool ParamTraits<AudioBuffersState>::Read(const Message* m, | 809 bool ParamTraits<AudioBuffersState>::Read(const Message* m, |
| 910 void** iter, | 810 void** iter, |
| 911 param_type* p) { | 811 param_type* p) { |
| 912 return | 812 return |
| 913 ReadParam(m, iter, &p->pending_bytes) && | 813 ReadParam(m, iter, &p->pending_bytes) && |
| 914 ReadParam(m, iter, &p->hardware_delay_bytes) && | 814 ReadParam(m, iter, &p->hardware_delay_bytes) && |
| 915 ReadParam(m, iter, &p->timestamp); | 815 ReadParam(m, iter, &p->timestamp); |
| 916 } | 816 } |
| 917 | 817 |
| 918 void ParamTraits<AudioBuffersState>::Log(const param_type& p, std::string* l) { | 818 void ParamTraits<AudioBuffersState>::Log(const param_type& p, std::string* l) { |
| 919 l->append("("); | 819 l->append("("); |
| 920 LogParam(p.pending_bytes, l); | 820 LogParam(p.pending_bytes, l); |
| 921 l->append(", "); | 821 l->append(", "); |
| 922 LogParam(p.hardware_delay_bytes, l); | 822 LogParam(p.hardware_delay_bytes, l); |
| 923 l->append(", "); | 823 l->append(", "); |
| 924 LogParam(p.timestamp, l); | 824 LogParam(p.timestamp, l); |
| 925 l->append(")"); | 825 l->append(")"); |
| 926 } | 826 } |
| 927 | 827 |
| 928 } // namespace IPC | 828 } // namespace IPC |
| OLD | NEW |