Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Side by Side Diff: content/common/input/input_param_traits.h

Issue 19624005: Add InputEvent and EventPacket types for batched input delivery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate InputEvent types for events based on WebKit::WebInputEvent Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
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_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
15 #define CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
16
17 #include "base/memory/scoped_ptr.h"
18 #include "content/common/input/event_packet.h"
19 #include "content/common/input/input_param_traits_macros.h"
20 #include "content/common/input/web_event.h"
21
22 namespace IPC {
23
24 // TODO(jdduke): There should be a common copy of this utility somewhere... Move
25 // or remove appropriately.
26 template<class P>
27 struct ParamTraits<scoped_ptr<P> > {
28 typedef scoped_ptr<P> param_type;
29 static void Write(Message* m, const param_type& p) {
30 bool valid = !!p;
31 WriteParam(m, valid);
32 if (valid)
33 WriteParam(m, *p);
34 }
35 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
36 bool valid = false;
37 if (!ReadParam(m, iter, &valid))
38 return false;
39
40 if (!valid) {
41 r->reset();
42 return true;
43 }
44
45 param_type temp(new P());
46 if (!ReadParam(m, iter, temp.get()))
47 return false;
48
49 r->swap(temp);
50 return true;
51 }
52 static void Log(const param_type& p, std::string* l) {
53 if (p)
54 LogParam(*p, l);
55 }
56 };
57
58 template <>
59 struct CONTENT_EXPORT ParamTraits<content::EventPacket> {
60 typedef content::EventPacket param_type;
61 static void Write(Message* m, const param_type& p);
62 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
63 static void Log(const param_type& p, std::string* l);
64 };
65
66 template <>
67 struct CONTENT_EXPORT ParamTraits<content::WebEvent> {
68 typedef content::WebEvent param_type;
69 static void Write(Message* m, const param_type& p);
70 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
71 static void Log(const param_type& p, std::string* l);
72 };
73
74 } // namespace IPC
75
76 #endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698