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

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

Issue 6673003: Move GPU messages to content. I've also switched the IPC structs to use the ... (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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.. 11 // public members..
12 12
13 #ifndef CONTENT_COMMON_COMMON_PARAM_TRAITS_H_ 13 #ifndef CONTENT_COMMON_COMMON_PARAM_TRAITS_H_
14 #define CONTENT_COMMON_COMMON_PARAM_TRAITS_H_ 14 #define CONTENT_COMMON_COMMON_PARAM_TRAITS_H_
15 #pragma once 15 #pragma once
16 16
17 #include "base/platform_file.h" 17 #include "base/platform_file.h"
18 #include "base/ref_counted.h" 18 #include "base/ref_counted.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "ipc/ipc_message_utils.h" 20 #include "ipc/ipc_message_utils.h"
21 #include "net/url_request/url_request_status.h" 21 #include "net/url_request/url_request_status.h"
22 // !!! WARNING: DO NOT ADD NEW WEBKIT DEPENDENCIES !!! 22 // !!! WARNING: DO NOT ADD NEW WEBKIT DEPENDENCIES !!!
23 // 23 //
24 // That means don't add #includes to any file in 'webkit/' or 24 // That means don't add #includes to any file in 'webkit/' or
25 // 'third_party/WebKit/'. Chrome Frame and NACL build parts of base/ and 25 // 'third_party/WebKit/'. Chrome Frame and NACL build parts of base/ and
26 // content/common/ for a mini-library that doesn't depend on webkit. 26 // content/common/ for a mini-library that doesn't depend on webkit.
27 27
28 // TODO(erg): The following headers are historical and only work because 28 // TODO(erg): The following headers are historical and only work because
29 // their definitions are inlined, which also needs to be fixed. 29 // their definitions are inlined, which also needs to be fixed.
30 #include "ui/gfx/native_widget_types.h"
30 #include "webkit/glue/resource_type.h" 31 #include "webkit/glue/resource_type.h"
31 32
32 // Forward declarations. 33 // Forward declarations.
33 class GURL; 34 class GURL;
34 35
36 namespace gfx {
37 class Point;
38 class Rect;
39 class Size;
40 } // namespace gfx
41
35 namespace net { 42 namespace net {
36 class HttpResponseHeaders; 43 class HttpResponseHeaders;
37 class HostPortPair; 44 class HostPortPair;
38 class UploadData; 45 class UploadData;
39 } 46 }
40 47
41 namespace webkit_glue { 48 namespace webkit_glue {
42 struct ResourceDevToolsInfo; 49 struct ResourceDevToolsInfo;
43 struct ResourceLoadTimingInfo; 50 struct ResourceLoadTimingInfo;
44 } 51 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 static void Write(Message* m, const param_type& p); 122 static void Write(Message* m, const param_type& p);
116 static bool Read(const Message* m, void** iter, param_type* r); 123 static bool Read(const Message* m, void** iter, param_type* r);
117 static void Log(const param_type& p, std::string* l); 124 static void Log(const param_type& p, std::string* l);
118 }; 125 };
119 126
120 template <> 127 template <>
121 struct SimilarTypeTraits<base::PlatformFileError> { 128 struct SimilarTypeTraits<base::PlatformFileError> {
122 typedef int Type; 129 typedef int Type;
123 }; 130 };
124 131
132 template <>
133 struct ParamTraits<gfx::Point> {
134 typedef gfx::Point param_type;
135 static void Write(Message* m, const param_type& p);
136 static bool Read(const Message* m, void** iter, param_type* r);
137 static void Log(const param_type& p, std::string* l);
138 };
139
140 template <>
141 struct ParamTraits<gfx::Size> {
142 typedef gfx::Size param_type;
143 static void Write(Message* m, const param_type& p);
144 static bool Read(const Message* m, void** iter, param_type* r);
145 static void Log(const param_type& p, std::string* l);
146 };
147
148 template <>
149 struct ParamTraits<gfx::Rect> {
150 typedef gfx::Rect param_type;
151 static void Write(Message* m, const param_type& p);
152 static bool Read(const Message* m, void** iter, param_type* r);
153 static void Log(const param_type& p, std::string* l);
154 };
155
156 template <>
157 struct ParamTraits<gfx::NativeWindow> {
158 typedef gfx::NativeWindow param_type;
159 static void Write(Message* m, const param_type& p) {
160 #if defined(OS_WIN)
161 // HWNDs are always 32 bits on Windows, even on 64 bit systems.
162 m->WriteUInt32(reinterpret_cast<uint32>(p));
163 #else
164 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(p));
165 #endif
166 }
167 static bool Read(const Message* m, void** iter, param_type* r) {
168 #if defined(OS_WIN)
169 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r));
170 #else
171 const char *data;
172 int data_size = 0;
173 bool result = m->ReadData(iter, &data, &data_size);
174 if (result && data_size == sizeof(gfx::NativeWindow)) {
175 memcpy(r, data, sizeof(gfx::NativeWindow));
176 } else {
177 result = false;
178 NOTREACHED();
179 }
180 return result;
181 #endif
182 }
183 static void Log(const param_type& p, std::string* l) {
184 l->append("<gfx::NativeWindow>");
185 }
186 };
187
125 } // namespace IPC 188 } // namespace IPC
126 189
127 #endif // CONTENT_COMMON_COMMON_PARAM_TRAITS_H_ 190 #endif // CONTENT_COMMON_COMMON_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/gpu_message_filter.cc ('k') | content/common/common_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698