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

Side by Side Diff: content/common/input/input_event.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: Code review 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 #ifndef CONTENT_COMMON_INPUT_INPUT_EVENT_H_
6 #define CONTENT_COMMON_INPUT_INPUT_EVENT_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h"
11
12 namespace content {
13
14 // An id'ed event that carries a specific input payload.
15 class CONTENT_EXPORT InputEvent {
16 public:
17 // Input data carried by the InputEvent.
18 class Payload {
19 public:
20 enum Type {
21 IPC_MESSAGE,
22 WEB_INPUT_EVENT,
23 };
24 virtual ~Payload() {}
25 virtual Type GetType() const = 0;
26 };
27
28 // |id| should be non-zero and |payload| should be non-NULL.
palmer 2013/09/03 23:12:47 But the implementation doesn't enforce this. If it
jdduke (slow) 2013/09/04 17:53:24 Well, it's enforced via DCHECK, though I suppose i
palmer 2013/09/05 01:20:15 Yeah, DCHECK is not really enforcement. But on a c
jdduke (slow) 2013/09/05 19:31:48 Done.
29 static scoped_ptr<InputEvent> Create(int64 id, scoped_ptr<Payload> payload);
30
31 template <typename PayloadType>
32 static scoped_ptr<InputEvent> Create(int64 id,
33 scoped_ptr<PayloadType> payload) {
34 return Create(id, payload.template PassAs<Payload>());
35 }
36
37 InputEvent();
38 virtual ~InputEvent();
39
40 // Used for deserialization.
41 void Initialize(int64 id, scoped_ptr<Payload> payload);
42
43 int64 id() const { return id_; }
44 const Payload* payload() const { return payload_.get(); }
45 bool valid() const { return id() && payload(); }
46
47 protected:
48 InputEvent(int64 id, scoped_ptr<Payload> payload);
49
50 private:
51 int64 id_;
52 scoped_ptr<Payload> payload_;
53
54 DISALLOW_COPY_AND_ASSIGN(InputEvent);
55 };
56
57 } // namespace content
58
59 #endif // CONTENT_COMMON_INPUT_INPUT_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698