OLD | NEW |
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 12 matching lines...) Expand all Loading... |
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 #pragma once | 25 #pragma once |
26 | 26 |
27 #include "ipc/ipc_message_utils.h" | 27 #include "ipc/ipc_message_utils.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" |
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult
.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult
.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" |
38 | 37 |
39 namespace WebKit { | 38 namespace WebKit { |
40 struct WebCompositionUnderline; | 39 struct WebCompositionUnderline; |
41 struct WebFindOptions; | 40 struct WebFindOptions; |
42 struct WebMediaPlayerAction; | 41 struct WebMediaPlayerAction; |
43 struct WebRect; | 42 struct WebRect; |
(...skipping 30 matching lines...) Expand all Loading... |
74 | 73 |
75 template <> | 74 template <> |
76 struct ParamTraits<WebKit::WebFindOptions> { | 75 struct ParamTraits<WebKit::WebFindOptions> { |
77 typedef WebKit::WebFindOptions param_type; | 76 typedef WebKit::WebFindOptions param_type; |
78 static void Write(Message* m, const param_type& p); | 77 static void Write(Message* m, const param_type& p); |
79 static bool Read(const Message* m, void** iter, param_type* p); | 78 static bool Read(const Message* m, void** iter, param_type* p); |
80 static void Log(const param_type& p, std::string* l); | 79 static void Log(const param_type& p, std::string* l); |
81 }; | 80 }; |
82 | 81 |
83 template <> | 82 template <> |
84 struct ParamTraits<WebKit::WebInputEvent::Type> { | |
85 typedef WebKit::WebInputEvent::Type param_type; | |
86 static void Write(Message* m, const param_type& p) { | |
87 m->WriteInt(p); | |
88 } | |
89 static bool Read(const Message* m, void** iter, param_type* p) { | |
90 int type; | |
91 if (!m->ReadInt(iter, &type)) | |
92 return false; | |
93 *p = static_cast<WebKit::WebInputEvent::Type>(type); | |
94 return true; | |
95 } | |
96 static void Log(const param_type& p, std::string* l) { | |
97 const char* type; | |
98 switch (p) { | |
99 case WebKit::WebInputEvent::MouseDown: | |
100 type = "MouseDown"; | |
101 break; | |
102 case WebKit::WebInputEvent::MouseUp: | |
103 type = "MouseUp"; | |
104 break; | |
105 case WebKit::WebInputEvent::MouseMove: | |
106 type = "MouseMove"; | |
107 break; | |
108 case WebKit::WebInputEvent::MouseLeave: | |
109 type = "MouseLeave"; | |
110 break; | |
111 case WebKit::WebInputEvent::MouseEnter: | |
112 type = "MouseEnter"; | |
113 break; | |
114 case WebKit::WebInputEvent::MouseWheel: | |
115 type = "MouseWheel"; | |
116 break; | |
117 case WebKit::WebInputEvent::RawKeyDown: | |
118 type = "RawKeyDown"; | |
119 break; | |
120 case WebKit::WebInputEvent::KeyDown: | |
121 type = "KeyDown"; | |
122 break; | |
123 case WebKit::WebInputEvent::KeyUp: | |
124 type = "KeyUp"; | |
125 break; | |
126 default: | |
127 type = "None"; | |
128 break; | |
129 } | |
130 LogParam(std::string(type), l); | |
131 } | |
132 }; | |
133 | |
134 template <> | |
135 struct ParamTraits<WebKit::WebCache::UsageStats> { | 83 struct ParamTraits<WebKit::WebCache::UsageStats> { |
136 typedef WebKit::WebCache::UsageStats param_type; | 84 typedef WebKit::WebCache::UsageStats param_type; |
137 static void Write(Message* m, const param_type& p) { | 85 static void Write(Message* m, const param_type& p) { |
138 WriteParam(m, p.minDeadCapacity); | 86 WriteParam(m, p.minDeadCapacity); |
139 WriteParam(m, p.maxDeadCapacity); | 87 WriteParam(m, p.maxDeadCapacity); |
140 WriteParam(m, p.capacity); | 88 WriteParam(m, p.capacity); |
141 WriteParam(m, p.liveSize); | 89 WriteParam(m, p.liveSize); |
142 WriteParam(m, p.deadSize); | 90 WriteParam(m, p.deadSize); |
143 } | 91 } |
144 static bool Read(const Message* m, void** iter, param_type* r) { | 92 static bool Read(const Message* m, void** iter, param_type* r) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 struct ParamTraits<WebKit::WebTextCheckingResult> { | 226 struct ParamTraits<WebKit::WebTextCheckingResult> { |
279 typedef WebKit::WebTextCheckingResult param_type; | 227 typedef WebKit::WebTextCheckingResult param_type; |
280 static void Write(Message* m, const param_type& p); | 228 static void Write(Message* m, const param_type& p); |
281 static bool Read(const Message* m, void** iter, param_type* r); | 229 static bool Read(const Message* m, void** iter, param_type* r); |
282 static void Log(const param_type& p, std::string* l); | 230 static void Log(const param_type& p, std::string* l); |
283 }; | 231 }; |
284 | 232 |
285 } // namespace IPC | 233 } // namespace IPC |
286 | 234 |
287 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ | 235 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ |
OLD | NEW |