Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: chrome/common/webkit_param_traits.h

Issue 3333008: Clean up webkit_param_traits.h to use SimilarTypeTraits for enums that don't... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file contains ParamTraits templates to support serialization of WebKit 5 // This file contains ParamTraits templates to support serialization of WebKit
6 // data types over IPC. 6 // data types over IPC.
7 // 7 //
8 // NOTE: IT IS IMPORTANT THAT ONLY POD (plain old data) TYPES ARE SERIALIZED. 8 // NOTE: IT IS IMPORTANT THAT ONLY POD (plain old data) TYPES ARE SERIALIZED.
9 // 9 //
10 // There are several reasons for this restrictions: 10 // There are several reasons for this restrictions:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 template <> 56 template <>
57 struct ParamTraits<WebKit::WebScreenInfo> { 57 struct ParamTraits<WebKit::WebScreenInfo> {
58 typedef WebKit::WebScreenInfo param_type; 58 typedef WebKit::WebScreenInfo param_type;
59 static void Write(Message* m, const param_type& p); 59 static void Write(Message* m, const param_type& p);
60 static bool Read(const Message* m, void** iter, param_type* p); 60 static bool Read(const Message* m, void** iter, param_type* p);
61 static void Log(const param_type& p, std::string* l); 61 static void Log(const param_type& p, std::string* l);
62 }; 62 };
63 63
64 template <> 64 template <>
65 struct ParamTraits<WebKit::WebConsoleMessage::Level> { 65 struct SimilarTypeTraits<WebKit::WebConsoleMessage::Level> {
66 typedef WebKit::WebConsoleMessage::Level param_type; 66 typedef int Type;
67 static void Write(Message* m, const param_type& p) {
68 WriteParam(m, static_cast<int>(p));
69 }
70 static bool Read(const Message* m, void** iter, param_type* r) {
71 int value;
72 if (!ReadParam(m, iter, &value))
73 return false;
74 *r = static_cast<param_type>(value);
75 return true;
76 }
77 static void Log(const param_type& p, std::string* l) {
78 LogParam(static_cast<int>(p), l);
79 }
80 }; 67 };
81 68
82 template <> 69 template <>
83 struct ParamTraits<WebKit::WebPopupType> { 70 struct SimilarTypeTraits<WebKit::WebPopupType> {
84 typedef WebKit::WebPopupType param_type; 71 typedef int Type;
85 static void Write(Message* m, const param_type& p) {
86 WriteParam(m, static_cast<int>(p));
87 }
88 static bool Read(const Message* m, void** iter, param_type* r) {
89 int value;
90 if (!ReadParam(m, iter, &value))
91 return false;
92 *r = static_cast<param_type>(value);
93 return true;
94 }
95 static void Log(const param_type& p, std::string* l) {
96 LogParam(static_cast<int>(p), l);
97 }
98 }; 72 };
99 73
100 template <> 74 template <>
101 struct ParamTraits<WebKit::WebFindOptions> { 75 struct ParamTraits<WebKit::WebFindOptions> {
102 typedef WebKit::WebFindOptions param_type; 76 typedef WebKit::WebFindOptions param_type;
103 static void Write(Message* m, const param_type& p); 77 static void Write(Message* m, const param_type& p);
104 static bool Read(const Message* m, void** iter, param_type* p); 78 static bool Read(const Message* m, void** iter, param_type* p);
105 static void Log(const param_type& p, std::string* l); 79 static void Log(const param_type& p, std::string* l);
106 }; 80 };
107 81
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 LogParam(p.images, l); 197 LogParam(p.images, l);
224 LogParam(p.cssStyleSheets, l); 198 LogParam(p.cssStyleSheets, l);
225 LogParam(p.scripts, l); 199 LogParam(p.scripts, l);
226 LogParam(p.xslStyleSheets, l); 200 LogParam(p.xslStyleSheets, l);
227 LogParam(p.fonts, l); 201 LogParam(p.fonts, l);
228 l->append("</WebCoreStats>"); 202 l->append("</WebCoreStats>");
229 } 203 }
230 }; 204 };
231 205
232 template <> 206 template <>
233 struct ParamTraits<WebKit::WebTextDirection> { 207 struct SimilarTypeTraits<WebKit::WebTextDirection> {
234 typedef WebKit::WebTextDirection param_type; 208 typedef int Type;
235 static void Write(Message* m, const param_type& p) {
236 WriteParam(m, static_cast<int>(p));
237 }
238 static bool Read(const Message* m, void** iter, param_type* r) {
239 int value;
240 if (!ReadParam(m, iter, &value))
241 return false;
242 *r = static_cast<param_type>(value);
243 return true;
244 }
245 static void Log(const param_type& p, std::string* l) {
246 LogParam(static_cast<int>(p), l);
247 }
248 }; 209 };
249 210
250 template <> 211 template <>
251 struct ParamTraits<WebKit::WebDragOperation> { 212 struct SimilarTypeTraits<WebKit::WebDragOperation> {
252 typedef WebKit::WebDragOperation param_type; 213 typedef int Type;
253 static void Write(Message* m, const param_type& p) {
254 m->WriteInt(p);
255 }
256 static bool Read(const Message* m, void** iter, param_type* r) {
257 int temp;
258 bool res = m->ReadInt(iter, &temp);
259 *r = static_cast<param_type>(temp);
260 return res;
261 }
262 static void Log(const param_type& p, std::string* l) {
263 l->append(StringPrintf("%d", p));
264 }
265 }; 214 };
266 215
267 template <> 216 template <>
268 struct ParamTraits<WebKit::WebMediaPlayerAction> { 217 struct ParamTraits<WebKit::WebMediaPlayerAction> {
269 typedef WebKit::WebMediaPlayerAction param_type; 218 typedef WebKit::WebMediaPlayerAction param_type;
270 static void Write(Message* m, const param_type& p); 219 static void Write(Message* m, const param_type& p);
271 static bool Read(const Message* m, void** iter, param_type* r); 220 static bool Read(const Message* m, void** iter, param_type* r);
272 static void Log(const param_type& p, std::string* l); 221 static void Log(const param_type& p, std::string* l);
273 }; 222 };
274 223
275 template <> 224 template <>
276 struct ParamTraits<WebKit::WebContextMenuData::MediaType> { 225 struct SimilarTypeTraits<WebKit::WebContextMenuData::MediaType> {
277 typedef WebKit::WebContextMenuData::MediaType param_type; 226 typedef int Type;
278 static void Write(Message* m, const param_type& p) {
279 m->WriteInt(p);
280 }
281 static bool Read(const Message* m, void** iter, param_type* r) {
282 int temp;
283 bool res = m->ReadInt(iter, &temp);
284 *r = static_cast<param_type>(temp);
285 return res;
286 }
287 }; 227 };
288 228
289 template <> 229 template <>
290 struct ParamTraits<WebKit::WebCompositionUnderline> { 230 struct ParamTraits<WebKit::WebCompositionUnderline> {
291 typedef WebKit::WebCompositionUnderline param_type; 231 typedef WebKit::WebCompositionUnderline param_type;
292 static void Write(Message* m, const param_type& p); 232 static void Write(Message* m, const param_type& p);
293 static bool Read(const Message* m, void** iter, param_type* p); 233 static bool Read(const Message* m, void** iter, param_type* p);
294 static void Log(const param_type& p, std::string* l); 234 static void Log(const param_type& p, std::string* l);
295 }; 235 };
296 236
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 }; 269 };
330 270
331 template <> 271 template <>
332 struct SimilarTypeTraits<WebKit::WebFileSystem::Type> { 272 struct SimilarTypeTraits<WebKit::WebFileSystem::Type> {
333 typedef int Type; 273 typedef int Type;
334 }; 274 };
335 275
336 } // namespace IPC 276 } // namespace IPC
337 277
338 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ 278 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698