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

Side by Side Diff: content/public/common/common_param_traits.h

Issue 10980010: Cleanup the IPC param traits structure (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix android Created 8 years, 2 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 | « content/content_common.gypi ('k') | content/public/common/common_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
1 // Copyright (c) 2012 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 types so that they can be serialized over IPC. IPC::ParamTraits<> 6 // of 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, or because the same type is being used in multiple 11 // public members, or because the same type is being used in multiple
12 // *_messages.h headers. 12 // *_messages.h headers.
13 13
14 #ifndef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ 14 #ifndef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_
15 #define CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ 15 #define CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_
16 16
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/public/common/common_param_traits_macros.h" 19 #include "content/public/common/common_param_traits_macros.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "ipc/ipc_message_utils.h" 21 #include "ipc/ipc_message_utils.h"
22 #include "net/base/ip_endpoint.h"
23 #include "net/url_request/url_request_status.h"
24 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
25 #include "ui/surface/transport_dib.h" 23 #include "ui/surface/transport_dib.h"
26 #include "webkit/base/data_element.h"
27 24
28 class SkBitmap; 25 class SkBitmap;
29 26
30 namespace content { 27 namespace content {
31 struct Referrer; 28 struct Referrer;
32 } 29 }
33 30
34 namespace gfx { 31 namespace gfx {
35 class Point; 32 class Point;
36 class Rect; 33 class Rect;
37 class RectF; 34 class RectF;
38 class Size; 35 class Size;
39 } // namespace gfx 36 } // namespace gfx
40 37
41 namespace net { 38 namespace net {
42 class HttpResponseHeaders;
43 class HostPortPair; 39 class HostPortPair;
44 class UploadData;
45 }
46
47 namespace ui {
48 class Range;
49 }
50
51 namespace webkit_glue {
52 class ResourceRequestBody;
53 } 40 }
54 41
55 namespace IPC { 42 namespace IPC {
56 43
57 template <> 44 template <>
58 struct CONTENT_EXPORT ParamTraits<GURL> { 45 struct CONTENT_EXPORT ParamTraits<GURL> {
59 typedef GURL param_type; 46 typedef GURL param_type;
60 static void Write(Message* m, const param_type& p); 47 static void Write(Message* m, const param_type& p);
61 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 48 static bool Read(const Message* m, PickleIterator* iter, param_type* p);
62 static void Log(const param_type& p, std::string* l); 49 static void Log(const param_type& p, std::string* l);
63 }; 50 };
64 51
65 template <>
66 struct CONTENT_EXPORT ParamTraits<net::URLRequestStatus> {
67 typedef net::URLRequestStatus param_type;
68 static void Write(Message* m, const param_type& p);
69 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
70 static void Log(const param_type& p, std::string* l);
71 };
72
73 template <>
74 struct CONTENT_EXPORT ParamTraits<scoped_refptr<net::UploadData> > {
75 typedef scoped_refptr<net::UploadData> param_type;
76 static void Write(Message* m, const param_type& p);
77 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
78 static void Log(const param_type& p, std::string* l);
79 };
80
81 template <>
82 struct CONTENT_EXPORT ParamTraits<scoped_refptr<
83 webkit_glue::ResourceRequestBody> > {
84 typedef scoped_refptr<webkit_glue::ResourceRequestBody> param_type;
85 static void Write(Message* m, const param_type& p);
86 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
87 static void Log(const param_type& p, std::string* l);
88 };
89
90 template <>
91 struct CONTENT_EXPORT ParamTraits<webkit_base::DataElement> {
92 typedef webkit_base::DataElement param_type;
93 static void Write(Message* m, const param_type& p);
94 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
95 static void Log(const param_type& p, std::string* l);
96 };
97
98 template<> 52 template<>
99 struct CONTENT_EXPORT ParamTraits<net::HostPortPair> { 53 struct CONTENT_EXPORT ParamTraits<net::HostPortPair> {
100 typedef net::HostPortPair param_type; 54 typedef net::HostPortPair param_type;
101 static void Write(Message* m, const param_type& p); 55 static void Write(Message* m, const param_type& p);
102 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 56 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
103 static void Log(const param_type& p, std::string* l); 57 static void Log(const param_type& p, std::string* l);
104 }; 58 };
105 59
106 template <> 60 template <>
107 struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
108 typedef scoped_refptr<net::HttpResponseHeaders> param_type;
109 static void Write(Message* m, const param_type& p);
110 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
111 static void Log(const param_type& p, std::string* l);
112 };
113
114 template <>
115 struct ParamTraits<net::IPEndPoint> {
116 typedef net::IPEndPoint param_type;
117 static void Write(Message* m, const param_type& p);
118 static bool Read(const Message* m, PickleIterator* iter, param_type* p);
119 static void Log(const param_type& p, std::string* l);
120 };
121
122 template <>
123 struct CONTENT_EXPORT ParamTraits<content::Referrer> { 61 struct CONTENT_EXPORT ParamTraits<content::Referrer> {
124 typedef content::Referrer param_type; 62 typedef content::Referrer param_type;
125 static void Write(Message* m, const param_type& p); 63 static void Write(Message* m, const param_type& p);
126 static bool Read(const Message* m, PickleIterator* iter, param_type* p); 64 static bool Read(const Message* m, PickleIterator* iter, param_type* p);
127 static void Log(const param_type& p, std::string* l); 65 static void Log(const param_type& p, std::string* l);
128 }; 66 };
129 67
130 template <> 68 template <>
131 struct CONTENT_EXPORT ParamTraits<gfx::Point> { 69 struct CONTENT_EXPORT ParamTraits<gfx::Point> {
132 typedef gfx::Point param_type; 70 typedef gfx::Point param_type;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 NOTREACHED(); 122 NOTREACHED();
185 } 123 }
186 return result; 124 return result;
187 #endif 125 #endif
188 } 126 }
189 static void Log(const param_type& p, std::string* l) { 127 static void Log(const param_type& p, std::string* l) {
190 l->append("<gfx::NativeWindow>"); 128 l->append("<gfx::NativeWindow>");
191 } 129 }
192 }; 130 };
193 131
194 template <>
195 struct CONTENT_EXPORT ParamTraits<ui::Range> {
196 typedef ui::Range param_type;
197 static void Write(Message* m, const param_type& p);
198 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
199 static void Log(const param_type& p, std::string* l);
200 };
201
202 #if defined(OS_WIN) 132 #if defined(OS_WIN)
203 template<> 133 template<>
204 struct ParamTraits<TransportDIB::Id> { 134 struct ParamTraits<TransportDIB::Id> {
205 typedef TransportDIB::Id param_type; 135 typedef TransportDIB::Id param_type;
206 static void Write(Message* m, const param_type& p) { 136 static void Write(Message* m, const param_type& p) {
207 WriteParam(m, p.handle); 137 WriteParam(m, p.handle);
208 WriteParam(m, p.sequence_num); 138 WriteParam(m, p.sequence_num);
209 } 139 }
210 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { 140 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
211 return (ReadParam(m, iter, &r->handle) && 141 return (ReadParam(m, iter, &r->handle) &&
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // Note: This function expects parameter |r| to be of type &SkBitmap since 177 // Note: This function expects parameter |r| to be of type &SkBitmap since
248 // r->SetConfig() and r->SetPixels() are called. 178 // r->SetConfig() and r->SetPixels() are called.
249 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 179 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
250 180
251 static void Log(const param_type& p, std::string* l); 181 static void Log(const param_type& p, std::string* l);
252 }; 182 };
253 183
254 } // namespace IPC 184 } // namespace IPC
255 185
256 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ 186 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « content/content_common.gypi ('k') | content/public/common/common_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698