Chromium Code Reviews| Index: content/common/input/input_event.h |
| diff --git a/content/common/input/input_event.h b/content/common/input/input_event.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4e6feb3f9b8c9c208bf2111bdb9e06f1ef68c885 |
| --- /dev/null |
| +++ b/content/common/input/input_event.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_COMMON_INPUT_INPUT_EVENT_H_ |
| +#define CONTENT_COMMON_INPUT_INPUT_EVENT_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +// An id'ed event that carries a specific input payload. |
| +class CONTENT_EXPORT InputEvent { |
| + public: |
| + // Input data carried by the InputEvent. |
| + class Payload { |
| + public: |
| + enum Type { |
| + IPC_MESSAGE, |
| + WEB_INPUT_EVENT, |
| + }; |
| + virtual ~Payload() {} |
| + virtual Type GetType() const = 0; |
| + }; |
| + |
| + // |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.
|
| + static scoped_ptr<InputEvent> Create(int64 id, scoped_ptr<Payload> payload); |
| + |
| + template <typename PayloadType> |
| + static scoped_ptr<InputEvent> Create(int64 id, |
| + scoped_ptr<PayloadType> payload) { |
| + return Create(id, payload.template PassAs<Payload>()); |
| + } |
| + |
| + InputEvent(); |
| + virtual ~InputEvent(); |
| + |
| + // Used for deserialization. |
| + void Initialize(int64 id, scoped_ptr<Payload> payload); |
| + |
| + int64 id() const { return id_; } |
| + const Payload* payload() const { return payload_.get(); } |
| + bool valid() const { return id() && payload(); } |
| + |
| + protected: |
| + InputEvent(int64 id, scoped_ptr<Payload> payload); |
| + |
| + private: |
| + int64 id_; |
| + scoped_ptr<Payload> payload_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InputEvent); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_COMMON_INPUT_INPUT_EVENT_H_ |