OLD | NEW |
1 // Copyright (c) 2011 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 // This file is used to define IPC::ParamTraits<> specializations for a number | 5 // This file is used to define IPC::ParamTraits<> specializations for a number |
6 // of WebKit types so that they can be serialized over IPC. IPC::ParamTraits<> | 6 // of WebKit types so that they can be serialized over IPC. IPC::ParamTraits<> |
7 // specializations for basic types (like int and std::string) and types in the | 7 // specializations for basic types (like int and std::string) and types in the |
8 // 'base' project can be found in ipc/ipc_message_utils.h. This file contains | 8 // 'base' project can be found in ipc/ipc_message_utils.h. This file contains |
9 // specializations for types that are used by the content code, and which need | 9 // specializations for types that are used by the content code, and which need |
10 // manual serialization code. This is usually because they're not structs with | 10 // manual serialization code. This is usually because they're not structs with |
11 // public members. | 11 // public members. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 NPIdentifier identifier; | 76 NPIdentifier identifier; |
77 }; | 77 }; |
78 | 78 |
79 namespace IPC { | 79 namespace IPC { |
80 | 80 |
81 template <> | 81 template <> |
82 struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> { | 82 struct ParamTraits<webkit_glue::ResourceLoadTimingInfo> { |
83 typedef webkit_glue::ResourceLoadTimingInfo param_type; | 83 typedef webkit_glue::ResourceLoadTimingInfo param_type; |
84 static void Write(Message* m, const param_type& p); | 84 static void Write(Message* m, const param_type& p); |
85 static bool Read(const Message* m, void** iter, param_type* r); | 85 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
86 static void Log(const param_type& p, std::string* l); | 86 static void Log(const param_type& p, std::string* l); |
87 }; | 87 }; |
88 | 88 |
89 template <> | 89 template <> |
90 struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { | 90 struct ParamTraits<scoped_refptr<webkit_glue::ResourceDevToolsInfo> > { |
91 typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type; | 91 typedef scoped_refptr<webkit_glue::ResourceDevToolsInfo> param_type; |
92 static void Write(Message* m, const param_type& p); | 92 static void Write(Message* m, const param_type& p); |
93 static bool Read(const Message* m, void** iter, param_type* r); | 93 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
94 static void Log(const param_type& p, std::string* l); | 94 static void Log(const param_type& p, std::string* l); |
95 }; | 95 }; |
96 | 96 |
97 template <> | 97 template <> |
98 struct ParamTraits<NPVariant_Param> { | 98 struct ParamTraits<NPVariant_Param> { |
99 typedef NPVariant_Param param_type; | 99 typedef NPVariant_Param param_type; |
100 static void Write(Message* m, const param_type& p); | 100 static void Write(Message* m, const param_type& p); |
101 static bool Read(const Message* m, void** iter, param_type* r); | 101 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
102 static void Log(const param_type& p, std::string* l); | 102 static void Log(const param_type& p, std::string* l); |
103 }; | 103 }; |
104 | 104 |
105 template <> | 105 template <> |
106 struct ParamTraits<NPIdentifier_Param> { | 106 struct ParamTraits<NPIdentifier_Param> { |
107 typedef NPIdentifier_Param param_type; | 107 typedef NPIdentifier_Param param_type; |
108 static void Write(Message* m, const param_type& p); | 108 static void Write(Message* m, const param_type& p); |
109 static bool Read(const Message* m, void** iter, param_type* r); | 109 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
110 static void Log(const param_type& p, std::string* l); | 110 static void Log(const param_type& p, std::string* l); |
111 }; | 111 }; |
112 | 112 |
113 template <> | 113 template <> |
114 struct ParamTraits<webkit::WebPluginMimeType> { | 114 struct ParamTraits<webkit::WebPluginMimeType> { |
115 typedef webkit::WebPluginMimeType param_type; | 115 typedef webkit::WebPluginMimeType param_type; |
116 static void Write(Message* m, const param_type& p); | 116 static void Write(Message* m, const param_type& p); |
117 static bool Read(const Message* m, void** iter, param_type* r); | 117 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
118 static void Log(const param_type& p, std::string* l); | 118 static void Log(const param_type& p, std::string* l); |
119 }; | 119 }; |
120 | 120 |
121 template <> | 121 template <> |
122 struct CONTENT_EXPORT ParamTraits<webkit::WebPluginInfo> { | 122 struct CONTENT_EXPORT ParamTraits<webkit::WebPluginInfo> { |
123 typedef webkit::WebPluginInfo param_type; | 123 typedef webkit::WebPluginInfo param_type; |
124 static void Write(Message* m, const param_type& p); | 124 static void Write(Message* m, const param_type& p); |
125 static bool Read(const Message* m, void** iter, param_type* r); | 125 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
126 static void Log(const param_type& p, std::string* l); | 126 static void Log(const param_type& p, std::string* l); |
127 }; | 127 }; |
128 | 128 |
129 template <> | 129 template <> |
130 struct ParamTraits<WebCursor> { | 130 struct ParamTraits<WebCursor> { |
131 typedef WebCursor param_type; | 131 typedef WebCursor param_type; |
132 static void Write(Message* m, const param_type& p) { | 132 static void Write(Message* m, const param_type& p) { |
133 p.Serialize(m); | 133 p.Serialize(m); |
134 } | 134 } |
135 static bool Read(const Message* m, void** iter, param_type* r) { | 135 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
136 return r->Deserialize(m, iter); | 136 return r->Deserialize(iter); |
137 } | 137 } |
138 static void Log(const param_type& p, std::string* l) { | 138 static void Log(const param_type& p, std::string* l) { |
139 l->append("<WebCursor>"); | 139 l->append("<WebCursor>"); |
140 } | 140 } |
141 }; | 141 }; |
142 | 142 |
143 template <> | 143 template <> |
144 struct ParamTraits<WebKit::WebInputEvent::Type> { | 144 struct ParamTraits<WebKit::WebInputEvent::Type> { |
145 typedef WebKit::WebInputEvent::Type param_type; | 145 typedef WebKit::WebInputEvent::Type param_type; |
146 static void Write(Message* m, const param_type& p) { | 146 static void Write(Message* m, const param_type& p) { |
147 m->WriteInt(p); | 147 m->WriteInt(p); |
148 } | 148 } |
149 static bool Read(const Message* m, void** iter, param_type* p) { | 149 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { |
150 int type; | 150 int type; |
151 if (!m->ReadInt(iter, &type)) | 151 if (!m->ReadInt(iter, &type)) |
152 return false; | 152 return false; |
153 *p = static_cast<WebKit::WebInputEvent::Type>(type); | 153 *p = static_cast<WebKit::WebInputEvent::Type>(type); |
154 return true; | 154 return true; |
155 } | 155 } |
156 static void Log(const param_type& p, std::string* l) { | 156 static void Log(const param_type& p, std::string* l) { |
157 const char* type; | 157 const char* type; |
158 switch (p) { | 158 switch (p) { |
159 case WebKit::WebInputEvent::MouseDown: | 159 case WebKit::WebInputEvent::MouseDown: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 }; | 192 }; |
193 | 193 |
194 typedef const WebKit::WebInputEvent* WebInputEventPointer; | 194 typedef const WebKit::WebInputEvent* WebInputEventPointer; |
195 template <> | 195 template <> |
196 struct ParamTraits<WebInputEventPointer> { | 196 struct ParamTraits<WebInputEventPointer> { |
197 typedef WebInputEventPointer param_type; | 197 typedef WebInputEventPointer param_type; |
198 static void Write(Message* m, const param_type& p) { | 198 static void Write(Message* m, const param_type& p) { |
199 m->WriteData(reinterpret_cast<const char*>(p), p->size); | 199 m->WriteData(reinterpret_cast<const char*>(p), p->size); |
200 } | 200 } |
201 // Note: upon read, the event has the lifetime of the message. | 201 // Note: upon read, the event has the lifetime of the message. |
202 static bool Read(const Message* m, void** iter, param_type* r) { | 202 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
203 const char* data; | 203 const char* data; |
204 int data_length; | 204 int data_length; |
205 if (!m->ReadData(iter, &data, &data_length)) { | 205 if (!m->ReadData(iter, &data, &data_length)) { |
206 NOTREACHED(); | 206 NOTREACHED(); |
207 return false; | 207 return false; |
208 } | 208 } |
209 if (data_length < static_cast<int>(sizeof(WebKit::WebInputEvent))) { | 209 if (data_length < static_cast<int>(sizeof(WebKit::WebInputEvent))) { |
210 NOTREACHED(); | 210 NOTREACHED(); |
211 return false; | 211 return false; |
212 } | 212 } |
(...skipping 25 matching lines...) Expand all Loading... |
238 | 238 |
239 template <> | 239 template <> |
240 struct SimilarTypeTraits<WindowOpenDisposition> { | 240 struct SimilarTypeTraits<WindowOpenDisposition> { |
241 typedef int Type; | 241 typedef int Type; |
242 }; | 242 }; |
243 | 243 |
244 template <> | 244 template <> |
245 struct CONTENT_EXPORT ParamTraits<webkit::forms::PasswordForm> { | 245 struct CONTENT_EXPORT ParamTraits<webkit::forms::PasswordForm> { |
246 typedef webkit::forms::PasswordForm param_type; | 246 typedef webkit::forms::PasswordForm param_type; |
247 static void Write(Message* m, const param_type& p); | 247 static void Write(Message* m, const param_type& p); |
248 static bool Read(const Message* m, void** iter, param_type* p); | 248 static bool Read(const Message* m, PickleIterator* iter, param_type* p); |
249 static void Log(const param_type& p, std::string* l); | 249 static void Log(const param_type& p, std::string* l); |
250 }; | 250 }; |
251 | 251 |
252 } // namespace IPC | 252 } // namespace IPC |
253 | 253 |
254 #endif // CONTENT_PUBLIC_COMMON_WEBKIT_PARAM_TRAITS_H_ | 254 #endif // CONTENT_PUBLIC_COMMON_WEBKIT_PARAM_TRAITS_H_ |
OLD | NEW |