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

Side by Side Diff: chrome/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
« no previous file with comments | « chrome/common/common_message_generator.h ('k') | chrome/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) 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 shared by more than one child process. 9 // specializations for types that are shared by more than one child process.
10 10
11 #ifndef CHROME_COMMON_COMMON_PARAM_TRAITS_H_ 11 #ifndef CHROME_COMMON_COMMON_PARAM_TRAITS_H_
12 #define CHROME_COMMON_COMMON_PARAM_TRAITS_H_ 12 #define CHROME_COMMON_COMMON_PARAM_TRAITS_H_
13 #pragma once 13 #pragma once
14 14
15 #include "app/surface/transport_dib.h" 15 #include "app/surface/transport_dib.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/ref_counted.h" 17 #include "base/ref_counted.h"
18 #include "chrome/common/content_settings.h" 18 #include "chrome/common/content_settings.h"
19 #include "chrome/common/page_zoom.h" 19 #include "chrome/common/page_zoom.h"
20 #include "ipc/ipc_message_utils.h" 20 #include "ipc/ipc_message_utils.h"
21 #include "printing/native_metafile.h" 21 #include "printing/native_metafile.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 // chrome/common/ for a mini-library that doesn't depend on webkit. 26 // chrome/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"
31 #include "webkit/glue/webcursor.h" 30 #include "webkit/glue/webcursor.h"
32 #include "webkit/glue/window_open_disposition.h" 31 #include "webkit/glue/window_open_disposition.h"
33 32
34 // Forward declarations. 33 // Forward declarations.
35 struct Geoposition; 34 struct Geoposition;
36 class SkBitmap; 35 class SkBitmap;
37 class DictionaryValue; 36 class DictionaryValue;
38 class ListValue; 37 class ListValue;
39 struct ThumbnailScore; 38 struct ThumbnailScore;
40 struct WebApplicationInfo; 39 struct WebApplicationInfo;
41 class WebCursor; 40 class WebCursor;
42 41
43 namespace gfx {
44 class Point;
45 class Rect;
46 class Size;
47 } // namespace gfx
48
49 namespace printing { 42 namespace printing {
50 struct PageRange; 43 struct PageRange;
51 struct PrinterCapsAndDefaults; 44 struct PrinterCapsAndDefaults;
52 } // namespace printing 45 } // namespace printing
53 46
54 namespace webkit_glue { 47 namespace webkit_glue {
55 struct PasswordForm; 48 struct PasswordForm;
56 } // namespace webkit_glue 49 } // namespace webkit_glue
57 50
58 namespace IPC { 51 namespace IPC {
59 52
60 template <> 53 template <>
61 struct ParamTraits<SkBitmap> { 54 struct ParamTraits<SkBitmap> {
62 typedef SkBitmap param_type; 55 typedef SkBitmap param_type;
63 static void Write(Message* m, const param_type& p); 56 static void Write(Message* m, const param_type& p);
64 57
65 // Note: This function expects parameter |r| to be of type &SkBitmap since 58 // Note: This function expects parameter |r| to be of type &SkBitmap since
66 // r->SetConfig() and r->SetPixels() are called. 59 // r->SetConfig() and r->SetPixels() are called.
67 static bool Read(const Message* m, void** iter, param_type* r); 60 static bool Read(const Message* m, void** iter, param_type* r);
68 61
69 static void Log(const param_type& p, std::string* l); 62 static void Log(const param_type& p, std::string* l);
70 }; 63 };
71 64
72 template <> 65 template <>
73 struct ParamTraits<gfx::Point> {
74 typedef gfx::Point param_type;
75 static void Write(Message* m, const param_type& p);
76 static bool Read(const Message* m, void** iter, param_type* r);
77 static void Log(const param_type& p, std::string* l);
78 };
79
80 template <>
81 struct ParamTraits<gfx::Rect> {
82 typedef gfx::Rect param_type;
83 static void Write(Message* m, const param_type& p);
84 static bool Read(const Message* m, void** iter, param_type* r);
85 static void Log(const param_type& p, std::string* l);
86 };
87
88 template <>
89 struct ParamTraits<gfx::Size> {
90 typedef gfx::Size param_type;
91 static void Write(Message* m, const param_type& p);
92 static bool Read(const Message* m, void** iter, param_type* r);
93 static void Log(const param_type& p, std::string* l);
94 };
95
96 template <>
97 struct ParamTraits<ContentSetting> { 66 struct ParamTraits<ContentSetting> {
98 typedef ContentSetting param_type; 67 typedef ContentSetting param_type;
99 static void Write(Message* m, const param_type& p); 68 static void Write(Message* m, const param_type& p);
100 static bool Read(const Message* m, void** iter, param_type* r); 69 static bool Read(const Message* m, void** iter, param_type* r);
101 static void Log(const param_type& p, std::string* l); 70 static void Log(const param_type& p, std::string* l);
102 }; 71 };
103 72
104 template <> 73 template <>
105 struct ParamTraits<ContentSettingsType> { 74 struct ParamTraits<ContentSettingsType> {
106 typedef ContentSettingsType param_type; 75 typedef ContentSettingsType param_type;
(...skipping 16 matching lines...) Expand all
123 92
124 template <> 93 template <>
125 struct ParamTraits<ContentSettings> { 94 struct ParamTraits<ContentSettings> {
126 typedef ContentSettings param_type; 95 typedef ContentSettings param_type;
127 static void Write(Message* m, const param_type& p); 96 static void Write(Message* m, const param_type& p);
128 static bool Read(const Message* m, void** iter, param_type* r); 97 static bool Read(const Message* m, void** iter, param_type* r);
129 static void Log(const param_type& p, std::string* l); 98 static void Log(const param_type& p, std::string* l);
130 }; 99 };
131 100
132 template <> 101 template <>
133 struct ParamTraits<gfx::NativeWindow> {
134 typedef gfx::NativeWindow param_type;
135 static void Write(Message* m, const param_type& p) {
136 #if defined(OS_WIN)
137 // HWNDs are always 32 bits on Windows, even on 64 bit systems.
138 m->WriteUInt32(reinterpret_cast<uint32>(p));
139 #else
140 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(p));
141 #endif
142 }
143 static bool Read(const Message* m, void** iter, param_type* r) {
144 #if defined(OS_WIN)
145 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r));
146 #else
147 const char *data;
148 int data_size = 0;
149 bool result = m->ReadData(iter, &data, &data_size);
150 if (result && data_size == sizeof(gfx::NativeWindow)) {
151 memcpy(r, data, sizeof(gfx::NativeWindow));
152 } else {
153 result = false;
154 NOTREACHED();
155 }
156 return result;
157 #endif
158 }
159 static void Log(const param_type& p, std::string* l) {
160 l->append("<gfx::NativeWindow>");
161 }
162 };
163
164 template <>
165 struct ParamTraits<PageZoom::Function> { 102 struct ParamTraits<PageZoom::Function> {
166 typedef PageZoom::Function param_type; 103 typedef PageZoom::Function param_type;
167 static void Write(Message* m, const param_type& p) { 104 static void Write(Message* m, const param_type& p) {
168 WriteParam(m, static_cast<int>(p)); 105 WriteParam(m, static_cast<int>(p));
169 } 106 }
170 static bool Read(const Message* m, void** iter, param_type* r) { 107 static bool Read(const Message* m, void** iter, param_type* r) {
171 int value; 108 int value;
172 if (!ReadParam(m, iter, &value)) 109 if (!ReadParam(m, iter, &value))
173 return false; 110 return false;
174 *r = static_cast<param_type>(value); 111 *r = static_cast<param_type>(value);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 struct ParamTraits<printing::PrinterCapsAndDefaults> { 226 struct ParamTraits<printing::PrinterCapsAndDefaults> {
290 typedef printing::PrinterCapsAndDefaults param_type; 227 typedef printing::PrinterCapsAndDefaults param_type;
291 static void Write(Message* m, const param_type& p); 228 static void Write(Message* m, const param_type& p);
292 static bool Read(const Message* m, void** iter, param_type* r); 229 static bool Read(const Message* m, void** iter, param_type* r);
293 static void Log(const param_type& p, std::string* l); 230 static void Log(const param_type& p, std::string* l);
294 }; 231 };
295 232
296 } // namespace IPC 233 } // namespace IPC
297 234
298 #endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_ 235 #endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « chrome/common/common_message_generator.h ('k') | chrome/common/common_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698