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.
5 // This file defines IPC::ParamTraits<> specializations for several
6 // input-related types that require manual serialiation code.
8 #ifndef CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
9 #define CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_param_traits_macros.h"
13 #include "content/common/input/event_packet.h"
14 #include "content/common/input/input_event.h"
15 #include "content/common/input/web_input_event_payload.h"
19 // TODO(jdduke): There should be a common copy of this utility somewhere...
20 // Move or remove appropriately.
22 struct ParamTraits
<scoped_ptr
<P
> > {
23 typedef scoped_ptr
<P
> param_type
;
24 static void Write(Message
* m
, const param_type
& p
) {
30 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
32 if (!ReadParam(m
, iter
, &valid
))
40 param_type
temp(new P());
41 if (!ReadParam(m
, iter
, temp
.get()))
47 static void Log(const param_type
& p
, std::string
* l
) {
56 struct CONTENT_EXPORT ParamTraits
<content::EventPacket
> {
57 typedef content::EventPacket param_type
;
58 static void Write(Message
* m
, const param_type
& p
);
59 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* r
);
60 static void Log(const param_type
& p
, std::string
* l
);
64 struct CONTENT_EXPORT ParamTraits
<content::InputEvent
> {
65 typedef content::InputEvent param_type
;
66 static void Write(Message
* m
, const param_type
& p
);
67 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* r
);
68 static void Log(const param_type
& p
, std::string
* l
);
72 struct CONTENT_EXPORT ParamTraits
<content::WebInputEventPayload
> {
73 typedef content::WebInputEventPayload param_type
;
74 static void Write(Message
* m
, const param_type
& p
);
75 static bool Read(const Message
* m
, PickleIterator
* iter
, param_type
* r
);
76 static void Log(const param_type
& p
, std::string
* l
);
81 #endif // CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_