| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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. | |
| 4 | |
| 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. | |
| 13 | |
| 14 #ifndef CONTENT_CHILD_PLUGIN_PARAM_TRAITS_H_ | |
| 15 #define CONTENT_CHILD_PLUGIN_PARAM_TRAITS_H_ | |
| 16 | |
| 17 #include <string> | |
| 18 | |
| 19 #include "content/child/npapi/npruntime_util.h" | |
| 20 #include "ipc/ipc_message.h" | |
| 21 #include "ipc/ipc_param_traits.h" | |
| 22 | |
| 23 namespace content { | |
| 24 | |
| 25 // Define the NPVariant_Param struct and its enum here since it needs manual | |
| 26 // serialization code. | |
| 27 enum NPVariant_ParamEnum { | |
| 28 NPVARIANT_PARAM_VOID, | |
| 29 NPVARIANT_PARAM_NULL, | |
| 30 NPVARIANT_PARAM_BOOL, | |
| 31 NPVARIANT_PARAM_INT, | |
| 32 NPVARIANT_PARAM_DOUBLE, | |
| 33 NPVARIANT_PARAM_STRING, | |
| 34 // Used when when the NPObject is running in the caller's process, so we | |
| 35 // create an NPObjectProxy in the other process. To support object ownership | |
| 36 // tracking the routing-Id of the NPObject's owning plugin instance is | |
| 37 // passed alongside that of the object itself. | |
| 38 NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID, | |
| 39 // Used when the NPObject we're sending is running in the callee's process | |
| 40 // (i.e. we have an NPObjectProxy for it). In that case we want the callee | |
| 41 // to just use the raw pointer. | |
| 42 NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID, | |
| 43 }; | |
| 44 | |
| 45 struct NPVariant_Param { | |
| 46 NPVariant_Param(); | |
| 47 ~NPVariant_Param(); | |
| 48 | |
| 49 NPVariant_ParamEnum type; | |
| 50 bool bool_value; | |
| 51 int int_value; | |
| 52 double double_value; | |
| 53 std::string string_value; | |
| 54 int npobject_routing_id; | |
| 55 int npobject_owner_id; | |
| 56 }; | |
| 57 | |
| 58 struct NPIdentifier_Param { | |
| 59 NPIdentifier_Param(); | |
| 60 ~NPIdentifier_Param(); | |
| 61 | |
| 62 NPIdentifier identifier; | |
| 63 }; | |
| 64 | |
| 65 } // namespace content | |
| 66 | |
| 67 namespace IPC { | |
| 68 | |
| 69 template <> | |
| 70 struct ParamTraits<content::NPVariant_Param> { | |
| 71 typedef content::NPVariant_Param param_type; | |
| 72 static void Write(base::Pickle* m, const param_type& p); | |
| 73 static bool Read(const base::Pickle* m, | |
| 74 base::PickleIterator* iter, | |
| 75 param_type* r); | |
| 76 static void Log(const param_type& p, std::string* l); | |
| 77 }; | |
| 78 | |
| 79 template <> | |
| 80 struct ParamTraits<content::NPIdentifier_Param> { | |
| 81 typedef content::NPIdentifier_Param param_type; | |
| 82 static void Write(base::Pickle* m, const param_type& p); | |
| 83 static bool Read(const base::Pickle* m, | |
| 84 base::PickleIterator* iter, | |
| 85 param_type* r); | |
| 86 static void Log(const param_type& p, std::string* l); | |
| 87 }; | |
| 88 | |
| 89 } // namespace IPC | |
| 90 | |
| 91 #endif // CONTENT_CHILD_PLUGIN_PARAM_TRAITS_H_ | |
| OLD | NEW |