| OLD | NEW |
| 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 <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 21 #include "content/public/common/common_param_traits_macros.h" | 21 #include "content/public/common/common_param_traits_macros.h" |
| 22 #include "ipc/ipc_message_utils.h" | 22 #include "ipc/ipc_message_utils.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
| 24 #include "ui/surface/transport_dib.h" | 24 #include "ui/surface/transport_dib.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 #include "url/origin.h" | 26 #include "url/origin.h" |
| 27 | 27 |
| 28 class SkBitmap; | |
| 29 | |
| 30 namespace content { | 28 namespace content { |
| 31 class PageState; | 29 class PageState; |
| 32 } | 30 } |
| 33 | 31 |
| 34 namespace gfx { | |
| 35 class Point; | |
| 36 class Rect; | |
| 37 class RectF; | |
| 38 class Size; | |
| 39 class Vector2d; | |
| 40 } // namespace gfx | |
| 41 | |
| 42 namespace net { | 32 namespace net { |
| 43 class HostPortPair; | 33 class HostPortPair; |
| 44 class IPEndPoint; | 34 class IPEndPoint; |
| 45 } | 35 } |
| 46 | 36 |
| 47 namespace IPC { | 37 namespace IPC { |
| 48 | 38 |
| 49 template <> | 39 template <> |
| 50 struct CONTENT_EXPORT ParamTraits<GURL> { | 40 struct CONTENT_EXPORT ParamTraits<GURL> { |
| 51 typedef GURL param_type; | 41 typedef GURL param_type; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 | 70 |
| 81 template <> | 71 template <> |
| 82 struct CONTENT_EXPORT ParamTraits<content::PageState> { | 72 struct CONTENT_EXPORT ParamTraits<content::PageState> { |
| 83 typedef content::PageState param_type; | 73 typedef content::PageState param_type; |
| 84 static void Write(Message* m, const param_type& p); | 74 static void Write(Message* m, const param_type& p); |
| 85 static bool Read(const Message* m, PickleIterator* iter, param_type* p); | 75 static bool Read(const Message* m, PickleIterator* iter, param_type* p); |
| 86 static void Log(const param_type& p, std::string* l); | 76 static void Log(const param_type& p, std::string* l); |
| 87 }; | 77 }; |
| 88 | 78 |
| 89 template <> | 79 template <> |
| 90 struct CONTENT_EXPORT ParamTraits<gfx::Point> { | |
| 91 typedef gfx::Point param_type; | |
| 92 static void Write(Message* m, const param_type& p); | |
| 93 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 94 static void Log(const param_type& p, std::string* l); | |
| 95 }; | |
| 96 | |
| 97 template <> | |
| 98 struct CONTENT_EXPORT ParamTraits<gfx::PointF> { | |
| 99 typedef gfx::PointF param_type; | |
| 100 static void Write(Message* m, const param_type& p); | |
| 101 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 102 static void Log(const param_type& p, std::string* l); | |
| 103 }; | |
| 104 | |
| 105 template <> | |
| 106 struct CONTENT_EXPORT ParamTraits<gfx::Size> { | |
| 107 typedef gfx::Size param_type; | |
| 108 static void Write(Message* m, const param_type& p); | |
| 109 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 110 static void Log(const param_type& p, std::string* l); | |
| 111 }; | |
| 112 | |
| 113 template <> | |
| 114 struct CONTENT_EXPORT ParamTraits<gfx::SizeF> { | |
| 115 typedef gfx::SizeF param_type; | |
| 116 static void Write(Message* m, const param_type& p); | |
| 117 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 118 static void Log(const param_type& p, std::string* l); | |
| 119 }; | |
| 120 | |
| 121 template <> | |
| 122 struct CONTENT_EXPORT ParamTraits<gfx::Vector2d> { | |
| 123 typedef gfx::Vector2d param_type; | |
| 124 static void Write(Message* m, const param_type& p); | |
| 125 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 126 static void Log(const param_type& p, std::string* l); | |
| 127 }; | |
| 128 | |
| 129 template <> | |
| 130 struct CONTENT_EXPORT ParamTraits<gfx::Vector2dF> { | |
| 131 typedef gfx::Vector2dF param_type; | |
| 132 static void Write(Message* m, const param_type& p); | |
| 133 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 134 static void Log(const param_type& p, std::string* l); | |
| 135 }; | |
| 136 | |
| 137 template <> | |
| 138 struct CONTENT_EXPORT ParamTraits<gfx::Rect> { | |
| 139 typedef gfx::Rect param_type; | |
| 140 static void Write(Message* m, const param_type& p); | |
| 141 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 142 static void Log(const param_type& p, std::string* l); | |
| 143 }; | |
| 144 | |
| 145 template <> | |
| 146 struct CONTENT_EXPORT ParamTraits<gfx::RectF> { | |
| 147 typedef gfx::RectF param_type; | |
| 148 static void Write(Message* m, const param_type& p); | |
| 149 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 150 static void Log(const param_type& p, std::string* l); | |
| 151 }; | |
| 152 | |
| 153 template <> | |
| 154 struct ParamTraits<gfx::NativeWindow> { | 80 struct ParamTraits<gfx::NativeWindow> { |
| 155 typedef gfx::NativeWindow param_type; | 81 typedef gfx::NativeWindow param_type; |
| 156 static void Write(Message* m, const param_type& p) { | 82 static void Write(Message* m, const param_type& p) { |
| 157 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 158 // HWNDs are always 32 bits on Windows, even on 64 bit systems. | 84 // HWNDs are always 32 bits on Windows, even on 64 bit systems. |
| 159 m->WriteUInt32(reinterpret_cast<uint32>(p)); | 85 m->WriteUInt32(reinterpret_cast<uint32>(p)); |
| 160 #else | 86 #else |
| 161 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(p)); | 87 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(p)); |
| 162 #endif | 88 #endif |
| 163 } | 89 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 static void Log(const param_type& p, std::string* l) { | 123 static void Log(const param_type& p, std::string* l) { |
| 198 l->append("TransportDIB("); | 124 l->append("TransportDIB("); |
| 199 LogParam(p.handle, l); | 125 LogParam(p.handle, l); |
| 200 l->append(", "); | 126 l->append(", "); |
| 201 LogParam(p.sequence_num, l); | 127 LogParam(p.sequence_num, l); |
| 202 l->append(")"); | 128 l->append(")"); |
| 203 } | 129 } |
| 204 }; | 130 }; |
| 205 #endif | 131 #endif |
| 206 | 132 |
| 207 template <> | |
| 208 struct CONTENT_EXPORT ParamTraits<SkBitmap> { | |
| 209 typedef SkBitmap param_type; | |
| 210 static void Write(Message* m, const param_type& p); | |
| 211 | |
| 212 // Note: This function expects parameter |r| to be of type &SkBitmap since | |
| 213 // r->SetConfig() and r->SetPixels() are called. | |
| 214 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | |
| 215 | |
| 216 static void Log(const param_type& p, std::string* l); | |
| 217 }; | |
| 218 | |
| 219 } // namespace IPC | 133 } // namespace IPC |
| 220 | 134 |
| 221 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ | 135 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ |
| OLD | NEW |