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

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: Win export fix Created 7 years, 3 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) 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 defines IPC::ParamTraits<> specializations for several
6 // input-related types that require manual serialiation code.
7
8 #ifndef CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
9 #define CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
10
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"
16
17 namespace IPC {
18
19 // TODO(jdduke): There should be a common copy of this utility somewhere...
20 // Move or remove appropriately.
21 template <class P>
22 struct ParamTraits<scoped_ptr<P> > {
23 typedef scoped_ptr<P> param_type;
24 static void Write(Message* m, const param_type& p) {
25 bool valid = !!p;
26 WriteParam(m, valid);
27 if (valid)
28 WriteParam(m, *p);
29 }
30 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
31 bool valid = false;
32 if (!ReadParam(m, iter, &valid))
33 return false;
34
35 if (!valid) {
36 r->reset();
37 return true;
38 }
39
40 param_type temp(new P());
41 if (!ReadParam(m, iter, temp.get()))
42 return false;
43
44 r->swap(temp);
45 return true;
46 }
47 static void Log(const param_type& p, std::string* l) {
48 if (p)
49 LogParam(*p, l);
50 else
51 l->append("NULL");
52 }
53 };
54
55 template <>
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);
61 };
62
63 template <>
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);
69 };
70
71 template <>
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);
77 };
78
79 } // namespace IPC
80
81 #endif // CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « content/common/input/input_event_disposition.cc ('k') | content/common/input/input_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698