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

Unified Diff: components/mus/common/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: Remove erroneous ui/events dep on ipc; add missing components/mus/common dep on ipc and ui/events 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: components/mus/common/event_param_traits.h
diff --git a/components/mus/common/event_param_traits.h b/components/mus/common/event_param_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f2bb94017385165bae16a9384063fbba427b946
--- /dev/null
+++ b/components/mus/common/event_param_traits.h
@@ -0,0 +1,94 @@
+// 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 COMPONENTS_MUS_COMMON_EVENT_PARAM_TRAITS_H_
+#define COMPONENTS_MUS_COMMON_EVENT_PARAM_TRAITS_H_
+
+#include <string>
+
+#include "components/mus/common/event_param_traits_macros.h"
+#include "ui/events/event.h"
+#include "ui/events/gesture_event_details.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_;
+
+template <>
+struct 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 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 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 // COMPONENTS_MUS_COMMON_EVENT_PARAM_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698