OLD | NEW |
---|---|
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 "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
17 #include "chrome/common/content_settings.h" | 17 #include "chrome/common/content_settings.h" |
18 #include "ipc/ipc_message_utils.h" | 18 #include "ipc/ipc_message_utils.h" |
19 #include "printing/native_metafile.h" | 19 #include "printing/native_metafile.h" |
20 // !!! WARNING: DO NOT ADD NEW WEBKIT DEPENDENCIES !!! | |
21 // | |
22 // That means don't add #includes to any file in 'webkit/' or | |
23 // 'third_party/WebKit/'. Chrome Frame and NACL build parts of base/ and | |
24 // chrome/common/ for a mini-library that doesn't depend on webkit. | |
25 // | |
26 // TODO(erg): The following headers are historical and only work because | |
Tom Sepez
2011/03/23 17:32:53
Does the warning still apply? Don't add ANY webki
jam
2011/03/23 18:21:02
not anymore, since this file isn't used by the nac
| |
27 // their definitions are inlined, which also needs to be fixed. | |
28 #include "webkit/glue/window_open_disposition.h" | |
29 | 20 |
30 // Forward declarations. | 21 // Forward declarations. |
31 class DictionaryValue; | 22 class DictionaryValue; |
32 class ListValue; | 23 class ListValue; |
33 struct ThumbnailScore; | 24 struct ThumbnailScore; |
34 struct WebApplicationInfo; | 25 struct WebApplicationInfo; |
35 | 26 |
36 namespace printing { | 27 namespace printing { |
37 struct PageRange; | 28 struct PageRange; |
38 struct PrinterCapsAndDefaults; | 29 struct PrinterCapsAndDefaults; |
39 } // namespace printing | 30 } // namespace printing |
40 | 31 |
41 namespace webkit_glue { | |
42 struct PasswordForm; | |
43 } // namespace webkit_glue | |
44 | |
45 namespace IPC { | 32 namespace IPC { |
46 | 33 |
47 template <> | 34 template <> |
48 struct ParamTraits<ContentSetting> { | 35 struct ParamTraits<ContentSetting> { |
49 typedef ContentSetting param_type; | 36 typedef ContentSetting param_type; |
50 static void Write(Message* m, const param_type& p); | 37 static void Write(Message* m, const param_type& p); |
51 static bool Read(const Message* m, void** iter, param_type* r); | 38 static bool Read(const Message* m, void** iter, param_type* r); |
52 static void Log(const param_type& p, std::string* l); | 39 static void Log(const param_type& p, std::string* l); |
53 }; | 40 }; |
54 | 41 |
(...skipping 19 matching lines...) Expand all Loading... | |
74 | 61 |
75 template <> | 62 template <> |
76 struct ParamTraits<ContentSettings> { | 63 struct ParamTraits<ContentSettings> { |
77 typedef ContentSettings param_type; | 64 typedef ContentSettings param_type; |
78 static void Write(Message* m, const param_type& p); | 65 static void Write(Message* m, const param_type& p); |
79 static bool Read(const Message* m, void** iter, param_type* r); | 66 static bool Read(const Message* m, void** iter, param_type* r); |
80 static void Log(const param_type& p, std::string* l); | 67 static void Log(const param_type& p, std::string* l); |
81 }; | 68 }; |
82 | 69 |
83 template <> | 70 template <> |
84 struct ParamTraits<WindowOpenDisposition> { | |
85 typedef WindowOpenDisposition param_type; | |
86 static void Write(Message* m, const param_type& p) { | |
87 WriteParam(m, static_cast<int>(p)); | |
88 } | |
89 static bool Read(const Message* m, void** iter, param_type* r) { | |
90 int value; | |
91 if (!ReadParam(m, iter, &value)) | |
92 return false; | |
93 *r = static_cast<param_type>(value); | |
94 return true; | |
95 } | |
96 static void Log(const param_type& p, std::string* l) { | |
97 LogParam(static_cast<int>(p), l); | |
98 } | |
99 }; | |
100 | |
101 template <> | |
102 struct ParamTraits<WebApplicationInfo> { | 71 struct ParamTraits<WebApplicationInfo> { |
103 typedef WebApplicationInfo param_type; | 72 typedef WebApplicationInfo param_type; |
104 static void Write(Message* m, const param_type& p); | 73 static void Write(Message* m, const param_type& p); |
105 static bool Read(const Message* m, void** iter, param_type* r); | 74 static bool Read(const Message* m, void** iter, param_type* r); |
106 static void Log(const param_type& p, std::string* l); | 75 static void Log(const param_type& p, std::string* l); |
107 }; | 76 }; |
108 | 77 |
109 template<> | 78 template<> |
110 struct ParamTraits<ThumbnailScore> { | 79 struct ParamTraits<ThumbnailScore> { |
111 typedef ThumbnailScore param_type; | 80 typedef ThumbnailScore param_type; |
112 static void Write(Message* m, const param_type& p); | 81 static void Write(Message* m, const param_type& p); |
113 static bool Read(const Message* m, void** iter, param_type* r); | 82 static bool Read(const Message* m, void** iter, param_type* r); |
114 static void Log(const param_type& p, std::string* l); | 83 static void Log(const param_type& p, std::string* l); |
115 }; | 84 }; |
116 | 85 |
117 template <> | 86 template <> |
118 struct ParamTraits<webkit_glue::PasswordForm> { | |
119 typedef webkit_glue::PasswordForm param_type; | |
120 static void Write(Message* m, const param_type& p); | |
121 static bool Read(const Message* m, void** iter, param_type* p); | |
122 static void Log(const param_type& p, std::string* l); | |
123 }; | |
124 | |
125 template <> | |
126 struct ParamTraits<printing::PageRange> { | 87 struct ParamTraits<printing::PageRange> { |
127 typedef printing::PageRange param_type; | 88 typedef printing::PageRange param_type; |
128 static void Write(Message* m, const param_type& p); | 89 static void Write(Message* m, const param_type& p); |
129 static bool Read(const Message* m, void** iter, param_type* r); | 90 static bool Read(const Message* m, void** iter, param_type* r); |
130 static void Log(const param_type& p, std::string* l); | 91 static void Log(const param_type& p, std::string* l); |
131 }; | 92 }; |
132 | 93 |
133 template <> | 94 template <> |
134 struct ParamTraits<printing::NativeMetafile> { | 95 struct ParamTraits<printing::NativeMetafile> { |
135 typedef printing::NativeMetafile param_type; | 96 typedef printing::NativeMetafile param_type; |
136 static void Write(Message* m, const param_type& p); | 97 static void Write(Message* m, const param_type& p); |
137 static bool Read(const Message* m, void** iter, param_type* r); | 98 static bool Read(const Message* m, void** iter, param_type* r); |
138 static void Log(const param_type& p, std::string* l); | 99 static void Log(const param_type& p, std::string* l); |
139 }; | 100 }; |
140 | 101 |
141 template <> | 102 template <> |
142 struct ParamTraits<printing::PrinterCapsAndDefaults> { | 103 struct ParamTraits<printing::PrinterCapsAndDefaults> { |
143 typedef printing::PrinterCapsAndDefaults param_type; | 104 typedef printing::PrinterCapsAndDefaults param_type; |
144 static void Write(Message* m, const param_type& p); | 105 static void Write(Message* m, const param_type& p); |
145 static bool Read(const Message* m, void** iter, param_type* r); | 106 static bool Read(const Message* m, void** iter, param_type* r); |
146 static void Log(const param_type& p, std::string* l); | 107 static void Log(const param_type& p, std::string* l); |
147 }; | 108 }; |
148 | 109 |
149 } // namespace IPC | 110 } // namespace IPC |
150 | 111 |
151 #endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_ | 112 #endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_ |
OLD | NEW |