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

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

Issue 149620: Use WebWidget from the WebKit API. This change also makes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/print_web_view_helper.h » ('j') | 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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // 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:
11 // 11 //
12 // o We don't want inclusion of this file to imply linking to WebKit code. 12 // o We don't want inclusion of this file to imply linking to WebKit code.
13 // 13 //
14 // o Many WebKit structures are not thread-safe. WebString, for example, 14 // o Many WebKit structures are not thread-safe. WebString, for example,
15 // contains a reference counted buffer, which does not use thread-safe 15 // contains a reference counted buffer, which does not use thread-safe
16 // reference counting. If we allowed serializing WebString, then we may ru n 16 // reference counting. If we allowed serializing WebString, then we may ru n
17 // the risk of introducing subtle thread-safety bugs if people passed a 17 // the risk of introducing subtle thread-safety bugs if people passed a
18 // WebString across threads via PostTask(NewRunnableMethod(...)). 18 // WebString across threads via PostTask(NewRunnableMethod(...)).
19 // 19 //
20 // o The WebKit API has redundant types for strings, and we should avoid usin g 20 // o The WebKit API has redundant types for strings, and we should avoid usin g
21 // those beyond code that interfaces with the WebKit API. 21 // those beyond code that interfaces with the WebKit API.
22 22
23 #ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ 23 #ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
24 #define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ 24 #define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
25 25
26 #include "chrome/common/ipc_message_utils.h" 26 #include "chrome/common/ipc_message_utils.h"
27 #include "webkit/api/public/WebCache.h" 27 #include "webkit/api/public/WebCache.h"
28 #include "webkit/api/public/WebCompositionCommand.h"
28 #include "webkit/api/public/WebConsoleMessage.h" 29 #include "webkit/api/public/WebConsoleMessage.h"
29 #include "webkit/api/public/WebFindOptions.h" 30 #include "webkit/api/public/WebFindOptions.h"
30 #include "webkit/api/public/WebInputEvent.h" 31 #include "webkit/api/public/WebInputEvent.h"
31 #include "webkit/api/public/WebScreenInfo.h" 32 #include "webkit/api/public/WebScreenInfo.h"
33 #include "webkit/api/public/WebTextDirection.h"
32 34
33 namespace IPC { 35 namespace IPC {
34 36
35 template <> 37 template <>
36 struct ParamTraits<WebKit::WebRect> { 38 struct ParamTraits<WebKit::WebRect> {
37 typedef WebKit::WebRect param_type; 39 typedef WebKit::WebRect param_type;
38 static void Write(Message* m, const param_type& p) { 40 static void Write(Message* m, const param_type& p) {
39 WriteParam(m, p.x); 41 WriteParam(m, p.x);
40 WriteParam(m, p.y); 42 WriteParam(m, p.y);
41 WriteParam(m, p.width); 43 WriteParam(m, p.width);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 LogParam(p.isMonochrome, l); 90 LogParam(p.isMonochrome, l);
89 l->append(L", "); 91 l->append(L", ");
90 LogParam(p.rect, l); 92 LogParam(p.rect, l);
91 l->append(L", "); 93 l->append(L", ");
92 LogParam(p.availableRect, l); 94 LogParam(p.availableRect, l);
93 l->append(L")"); 95 l->append(L")");
94 } 96 }
95 }; 97 };
96 98
97 template <> 99 template <>
100 struct ParamTraits<WebKit::WebCompositionCommand> {
101 typedef WebKit::WebCompositionCommand param_type;
102 static void Write(Message* m, const param_type& p) {
103 WriteParam(m, static_cast<int>(p));
104 }
105 static bool Read(const Message* m, void** iter, param_type* r) {
106 int value;
107 if (!ReadParam(m, iter, &value))
108 return false;
109 *r = static_cast<param_type>(value);
110 return true;
111 }
112 static void Log(const param_type& p, std::wstring* l) {
113 LogParam(static_cast<int>(p), l);
114 }
115 };
116
117 template <>
98 struct ParamTraits<WebKit::WebConsoleMessage::Level> { 118 struct ParamTraits<WebKit::WebConsoleMessage::Level> {
99 typedef WebKit::WebConsoleMessage::Level param_type; 119 typedef WebKit::WebConsoleMessage::Level param_type;
100 static void Write(Message* m, const param_type& p) { 120 static void Write(Message* m, const param_type& p) {
101 WriteParam(m, static_cast<int>(p)); 121 WriteParam(m, static_cast<int>(p));
102 } 122 }
103 static bool Read(const Message* m, void** iter, param_type* r) { 123 static bool Read(const Message* m, void** iter, param_type* r) {
104 int value; 124 int value;
105 if (!ReadParam(m, iter, &value)) 125 if (!ReadParam(m, iter, &value))
106 return false; 126 return false;
107 *r = static_cast<param_type>(value); 127 *r = static_cast<param_type>(value);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 l->append(L"<WebCoreStats>"); 277 l->append(L"<WebCoreStats>");
258 LogParam(p.images, l); 278 LogParam(p.images, l);
259 LogParam(p.cssStyleSheets, l); 279 LogParam(p.cssStyleSheets, l);
260 LogParam(p.scripts, l); 280 LogParam(p.scripts, l);
261 LogParam(p.xslStyleSheets, l); 281 LogParam(p.xslStyleSheets, l);
262 LogParam(p.fonts, l); 282 LogParam(p.fonts, l);
263 l->append(L"</WebCoreStats>"); 283 l->append(L"</WebCoreStats>");
264 } 284 }
265 }; 285 };
266 286
287 template <>
288 struct ParamTraits<WebKit::WebTextDirection> {
289 typedef WebKit::WebTextDirection param_type;
290 static void Write(Message* m, const param_type& p) {
291 WriteParam(m, static_cast<int>(p));
292 }
293 static bool Read(const Message* m, void** iter, param_type* r) {
294 int value;
295 if (!ReadParam(m, iter, &value))
296 return false;
297 *r = static_cast<param_type>(value);
298 return true;
299 }
300 static void Log(const param_type& p, std::wstring* l) {
301 LogParam(static_cast<int>(p), l);
302 }
303 };
304
267 } // namespace IPC 305 } // namespace IPC
268 306
269 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ 307 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/print_web_view_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698