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

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

Issue 6713084: Move the rest of the renderer->browser messages that belong in content. Also do a bunch of cleanup: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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/utility_messages.h ('k') | chrome/common/webkit_param_traits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file contains ParamTraits templates to support serialization of WebKit
6 // data types over IPC.
7 //
8 // NOTE: IT IS IMPORTANT THAT ONLY POD (plain old data) TYPES ARE SERIALIZED.
9 //
10 // There are several reasons for this restrictions:
11 //
12 // o We don't want inclusion of this file to imply linking to WebKit code.
13 //
14 // o Many WebKit structures are not thread-safe. WebString, for example,
15 // contains a reference counted buffer, which does not use thread-safe
16 // reference counting. If we allowed serializing WebString, then we may
17 // run the risk of introducing subtle thread-safety bugs if people passed a
18 // WebString across threads via PostTask(NewRunnableMethod(...)).
19 //
20 // o The WebKit API has redundant types for strings, and we should avoid
21 // using those beyond code that interfaces with the WebKit API.
22
23 #ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
24 #define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
25 #pragma once
26
27 #include "ipc/ipc_message_utils.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult .h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h"
34
35 namespace WebKit {
36 struct WebRect;
37 }
38
39 namespace IPC {
40
41 template <>
42 struct SimilarTypeTraits<WebKit::WebConsoleMessage::Level> {
43 typedef int Type;
44 };
45
46 template <>
47 struct ParamTraits<WebKit::WebCache::UsageStats> {
48 typedef WebKit::WebCache::UsageStats param_type;
49 static void Write(Message* m, const param_type& p) {
50 WriteParam(m, p.minDeadCapacity);
51 WriteParam(m, p.maxDeadCapacity);
52 WriteParam(m, p.capacity);
53 WriteParam(m, p.liveSize);
54 WriteParam(m, p.deadSize);
55 }
56 static bool Read(const Message* m, void** iter, param_type* r) {
57 return
58 ReadParam(m, iter, &r->minDeadCapacity) &&
59 ReadParam(m, iter, &r->maxDeadCapacity) &&
60 ReadParam(m, iter, &r->capacity) &&
61 ReadParam(m, iter, &r->liveSize) &&
62 ReadParam(m, iter, &r->deadSize);
63 }
64 static void Log(const param_type& p, std::string* l) {
65 l->append("<WebCache::UsageStats>");
66 }
67 };
68
69 template <>
70 struct ParamTraits<WebKit::WebCache::ResourceTypeStat> {
71 typedef WebKit::WebCache::ResourceTypeStat param_type;
72 static void Write(Message* m, const param_type& p) {
73 WriteParam(m, p.count);
74 WriteParam(m, p.size);
75 WriteParam(m, p.liveSize);
76 WriteParam(m, p.decodedSize);
77 }
78 static bool Read(const Message* m, void** iter, param_type* r) {
79 bool result =
80 ReadParam(m, iter, &r->count) &&
81 ReadParam(m, iter, &r->size) &&
82 ReadParam(m, iter, &r->liveSize) &&
83 ReadParam(m, iter, &r->decodedSize);
84 return result;
85 }
86 static void Log(const param_type& p, std::string* l);
87 };
88
89 template <>
90 struct ParamTraits<WebKit::WebCache::ResourceTypeStats> {
91 typedef WebKit::WebCache::ResourceTypeStats param_type;
92 static void Write(Message* m, const param_type& p) {
93 WriteParam(m, p.images);
94 WriteParam(m, p.cssStyleSheets);
95 WriteParam(m, p.scripts);
96 WriteParam(m, p.xslStyleSheets);
97 WriteParam(m, p.fonts);
98 }
99 static bool Read(const Message* m, void** iter, param_type* r) {
100 bool result =
101 ReadParam(m, iter, &r->images) &&
102 ReadParam(m, iter, &r->cssStyleSheets) &&
103 ReadParam(m, iter, &r->scripts) &&
104 ReadParam(m, iter, &r->xslStyleSheets) &&
105 ReadParam(m, iter, &r->fonts);
106 return result;
107 }
108 static void Log(const param_type& p, std::string* l) {
109 l->append("<WebCoreStats>");
110 LogParam(p.images, l);
111 LogParam(p.cssStyleSheets, l);
112 LogParam(p.scripts, l);
113 LogParam(p.xslStyleSheets, l);
114 LogParam(p.fonts, l);
115 l->append("</WebCoreStats>");
116 }
117 };
118
119 template <>
120 struct ParamTraits<WebKit::WebTextInputType> {
121 typedef WebKit::WebTextInputType param_type;
122 static void Write(Message* m, const param_type& p) {
123 m->WriteInt(p);
124 }
125 static bool Read(const Message* m, void** iter, param_type* p) {
126 int type;
127 if (!m->ReadInt(iter, &type))
128 return false;
129 *p = static_cast<param_type>(type);
130 return true;
131 }
132 static void Log(const param_type& p, std::string* l) {
133 std::string control;
134 switch (p) {
135 case WebKit::WebTextInputTypeNone:
136 control = "WebKit::WebTextInputTypeNone";
137 break;
138 case WebKit::WebTextInputTypeText:
139 control = "WebKit::WebTextInputTypeText";
140 break;
141 case WebKit::WebTextInputTypePassword:
142 control = "WebKit::WebTextInputTypePassword";
143 break;
144 default:
145 NOTIMPLEMENTED();
146 control = "UNKNOWN";
147 break;
148 }
149 LogParam(control, l);
150 }
151 };
152
153 template <>
154 struct SimilarTypeTraits<WebKit::WebFileError> {
155 typedef int Type;
156 };
157
158 template <>
159 struct ParamTraits<WebKit::WebTextCheckingResult> {
160 typedef WebKit::WebTextCheckingResult param_type;
161 static void Write(Message* m, const param_type& p);
162 static bool Read(const Message* m, void** iter, param_type* r);
163 static void Log(const param_type& p, std::string* l);
164 };
165
166 } // namespace IPC
167
168 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « chrome/common/utility_messages.h ('k') | chrome/common/webkit_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698