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

Unified Diff: ui/events/ipc/event_param_traits.h

Issue 1695783002: IPC::ParamTraits for ui::Event (towards ui::Events over mojo IPC) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix improper use of base::PickleIterator::ReadBytes() Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/ipc/event_param_traits.h
diff --git a/ui/events/ipc/event_param_traits.h b/ui/events/ipc/event_param_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..d936fc49d9924accfe49734af14439bb02d550ed
--- /dev/null
+++ b/ui/events/ipc/event_param_traits.h
@@ -0,0 +1,95 @@
+// Copyright (c) 2016 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 UI_EVENTS_IPC_EVENT_PARAM_TRAITS_H_
+#define UI_EVENTS_IPC_EVENT_PARAM_TRAITS_H_
+
+#include <string>
+
+#include "ui/events/event.h"
+#include "ui/events/gesture_event_details.h"
+#include "ui/events/ipc/event_param_traits_macros.h"
+#include "ui/events/ipc/events_ipc_export.h"
+
+namespace base {
+class Pickle;
+class PickleIterator;
+}
+
+namespace ui {
+class Event;
+}
+
+namespace IPC {
+
+// Non-serialized data:
+//
+// Some event data only makes sense and/or is needed in the context where the
+// raw event came from. As such, some data are explicitly NOT
+// serialized. These data are as follows:
+// base::NativeEvent native_event_;
+// LatencyInfo* latency_;
+// int source_device_id_;
sadrul 2016/02/17 21:05:31 I think we want to send source_device_id_ and late
Mark Dittmer 2016/02/18 14:51:05 Acknowledged.
+
+template <>
+struct EVENTS_IPC_EXPORT ParamTraits<ui::ScopedEvent> {
+ typedef ui::ScopedEvent param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
+ static void Log(const param_type& p, std::string* l);
+
+ static void SizeEvent(ui::EventType type,
+ base::TimeDelta time_stamp,
+ int flags,
+ base::PickleSizer* s,
+ const ui::ScopedEvent& p);
+ static void WriteEvent(ui::EventType type,
+ base::TimeDelta time_stamp,
+ int flags,
+ base::Pickle* m,
+ const ui::ScopedEvent& p);
+ static bool ReadEvent(ui::EventType type,
+ base::TimeDelta time_stamp,
+ int flags,
+ const base::Pickle* m,
+ base::PickleIterator* iter,
+ ui::ScopedEvent* p);
+ static void LogEvent(ui::EventType type,
+ base::TimeDelta time_stamp,
+ int flags,
+ const ui::ScopedEvent& p,
+ std::string* l);
+};
+
+// Manually implements no-op implementation for ui::CancelModeEvent because IPC
+// BEGIN/END macros with no MEMBER or PARENT in between cause compiler
+// errors.
+template <>
+struct EVENTS_IPC_EXPORT ParamTraits<ui::CancelModeEvent> {
+ typedef ui::CancelModeEvent param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template <>
+struct EVENTS_IPC_EXPORT ParamTraits<ui::GestureEventDetails::Details> {
+ typedef ui::GestureEventDetails::Details param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+} // namespace IPC
+
+#endif // UI_EVENTS_IPC_EVENT_PARAM_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698