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

Unified Diff: third_party/WebKit/Source/platform/mojo/TimeStructTraits.h

Issue 2887353004: WIP mojo typemaps for WTF time types (Closed)
Patch Set: Created 3 years, 7 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: third_party/WebKit/Source/platform/mojo/TimeStructTraits.h
diff --git a/third_party/WebKit/Source/platform/mojo/TimeStructTraits.h b/third_party/WebKit/Source/platform/mojo/TimeStructTraits.h
new file mode 100644
index 0000000000000000000000000000000000000000..150329e7c6251ecf45fdd49c6189369269718189
--- /dev/null
+++ b/third_party/WebKit/Source/platform/mojo/TimeStructTraits.h
@@ -0,0 +1,57 @@
+// Copyright 2017 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 TimeStructTraits_h
+#define TimeStructTraits_h
+
+#include "ipc/ipc_message_utils.h"
+#include "platform/wtf/Time.h"
+
+namespace IPC {
+
+template <>
+struct ParamTraits<WTF::Time> {
+ typedef WTF::Time param_type;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p) {
+ ParamTraits<base::Time>::GetSize(sizer, base::Time::FromInternalValue(p.ToInternalValueForTesting()));
+ }
+ static void Write(base::Pickle* m, const param_type& p) {
+ ParamTraits<base::Time>::Write(m, base::Time::FromInternalValue(p.ToInternalValueForTesting()));
+ }
+ static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) {
+ base::Time t;
+ bool result = ParamTraits<base::Time>::Read(m, iter, &t);
+ if (!result) return false;
+ *r = WTF::Time::FromSeconds(t.ToDoubleT());
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ ParamTraits<base::Time>::Log(base::Time::FromInternalValue(p.ToInternalValueForTesting()), l);
+ }
+};
+
+template <>
+struct ParamTraits<WTF::TimeTicks> {
+ typedef WTF::TimeTicks param_type;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p) {
+ ParamTraits<base::TimeTicks>::GetSize(sizer, base::TimeTicks::FromInternalValue(p.ToInternalValueForTesting()));
+ }
+ static void Write(base::Pickle* m, const param_type& p) {
+ ParamTraits<base::TimeTicks>::Write(m, base::TimeTicks::FromInternalValue(p.ToInternalValueForTesting()));
+ }
+ static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) {
+ base::TimeTicks t;
+ bool result = ParamTraits<base::TimeTicks>::Read(m, iter, &t);
+ if (!result) return false;
+ *r = WTF::TimeTicks::FromSeconds((t - base::TimeTicks()).InSecondsF());
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ ParamTraits<base::TimeTicks>::Log(base::TimeTicks::FromInternalValue(p.ToInternalValueForTesting()), l);
+ }
+};
+
+} // namespace IPC
+
+#endif // TimeStructTraits_h
« no previous file with comments | « third_party/WebKit/Source/platform/mojo/Time.typemap ('k') | third_party/WebKit/Source/platform/mojo/blink_typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698