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

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: InputEvent with payload 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 class CONTENT_EXPORT InputEvent {
15 public:
16 class Payload {
17 public:
18 enum Type {
19 IPC_MESSAGE,
20 WEB_INPUT_EVENT,
21 };
22 virtual ~Payload() {}
23 virtual Type GetType() const = 0;
24 };
25
26 // |id| should be non-zero and |payload| should be non-NULL.
27 static scoped_ptr<InputEvent> Create(int64 id, scoped_ptr<Payload> payload);
28
29 template <typename PayloadType>
30 static scoped_ptr<InputEvent> Create(int64 id,
31 scoped_ptr<PayloadType> payload) {
32 return Create(id, payload.template PassAs<Payload>());
33 }
34
35 InputEvent();
36 virtual ~InputEvent();
37
38 void Initialize(int64 id, scoped_ptr<Payload> payload);
39
40 int64 id() const { return id_; }
41 const Payload* payload() const { return payload_.get(); }
42 bool valid() const { return id() && payload(); }
43
44 protected:
45 InputEvent(int64 id, scoped_ptr<Payload> payload);
46
47 private:
48 int64 id_;
49 scoped_ptr<Payload> payload_;
50
51 DISALLOW_COPY_AND_ASSIGN(InputEvent);
52 };
53
54 } // namespace content
55
56 #endif // CONTENT_COMMON_INPUT_INPUT_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698