Remove obsolete Channel ID expiration time from site data viewer.
[chromium-blink-merge.git] / content / common / content_param_traits.h
blob098f2fdea7763c338df57391bc49ccdbef66477b
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
3 // found in the LICENSE file.
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<>
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
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
11 // public members, or because the same type is being used in multiple
12 // *_messages.h headers.
14 #ifndef CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_
15 #define CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_
17 #include "content/common/content_param_traits_macros.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
19 #include "webkit/glue/npruntime_util.h"
20 #include "webkit/glue/webcursor.h"
22 namespace net {
23 class IPEndPoint;
26 namespace ui {
27 class Range;
30 namespace content {
32 // Define the NPVariant_Param struct and its enum here since it needs manual
33 // serialization code.
34 enum NPVariant_ParamEnum {
35 NPVARIANT_PARAM_VOID,
36 NPVARIANT_PARAM_NULL,
37 NPVARIANT_PARAM_BOOL,
38 NPVARIANT_PARAM_INT,
39 NPVARIANT_PARAM_DOUBLE,
40 NPVARIANT_PARAM_STRING,
41 // Used when when the NPObject is running in the caller's process, so we
42 // create an NPObjectProxy in the other process.
43 NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID,
44 // Used when the NPObject we're sending is running in the callee's process
45 // (i.e. we have an NPObjectProxy for it). In that case we want the callee
46 // to just use the raw pointer.
47 NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID,
50 struct NPVariant_Param {
51 NPVariant_Param();
52 ~NPVariant_Param();
54 NPVariant_ParamEnum type;
55 bool bool_value;
56 int int_value;
57 double double_value;
58 std::string string_value;
59 int npobject_routing_id;
62 struct NPIdentifier_Param {
63 NPIdentifier_Param();
64 ~NPIdentifier_Param();
66 NPIdentifier identifier;
69 } // namespace content
71 namespace IPC {
73 template <>
74 struct ParamTraits<net::IPEndPoint> {
75 typedef net::IPEndPoint param_type;
76 static void Write(Message* m, const param_type& p);
77 static bool Read(const Message* m, PickleIterator* iter, param_type* p);
78 static void Log(const param_type& p, std::string* l);
81 template <>
82 struct ParamTraits<content::NPVariant_Param> {
83 typedef content::NPVariant_Param param_type;
84 static void Write(Message* m, const param_type& p);
85 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
86 static void Log(const param_type& p, std::string* l);
89 template <>
90 struct ParamTraits<content::NPIdentifier_Param> {
91 typedef content::NPIdentifier_Param 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);
97 template <>
98 struct ParamTraits<ui::Range> {
99 typedef ui::Range 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);
105 template <>
106 struct ParamTraits<WebCursor> {
107 typedef WebCursor param_type;
108 static void Write(Message* m, const param_type& p) {
109 p.Serialize(m);
111 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
112 return r->Deserialize(iter);
114 static void Log(const param_type& p, std::string* l) {
115 l->append("<WebCursor>");
119 typedef const WebKit::WebInputEvent* WebInputEventPointer;
120 template <>
121 struct ParamTraits<WebInputEventPointer> {
122 typedef WebInputEventPointer param_type;
123 static void Write(Message* m, const param_type& p);
124 // Note: upon read, the event has the lifetime of the message.
125 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
126 static void Log(const param_type& p, std::string* l);
129 } // namespace IPC
131 #endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_