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

Unified Diff: tonic/mojo_converter.h

Issue 1244493002: Wholesale move sky/engine/tonic to tonic (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « tonic/float32_list.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tonic/mojo_converter.h
diff --git a/tonic/mojo_converter.h b/tonic/mojo_converter.h
new file mode 100644
index 0000000000000000000000000000000000000000..1019662a4270723ef01908589e74df2d27ec62c1
--- /dev/null
+++ b/tonic/mojo_converter.h
@@ -0,0 +1,46 @@
+// Copyright 2015 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 SKY_ENGINE_TONIC_MOJO_CONVERTER_H_
+#define SKY_ENGINE_TONIC_MOJO_CONVERTER_H_
+
+#include "mojo/public/cpp/system/handle.h"
+#include "tonic/dart_converter.h"
+
+namespace blink {
+
+template <typename HandleType>
+struct DartConverter<mojo::ScopedHandleBase<HandleType>> {
+ static mojo::ScopedHandleBase<HandleType> FromDart(Dart_Handle handle) {
+ uint64_t mojo_handle64 = 0;
+ Dart_Handle result = Dart_IntegerToUint64(handle, &mojo_handle64);
+ if (Dart_IsError(result) || !mojo_handle64)
+ return mojo::ScopedHandleBase<HandleType>();
+
+ HandleType mojo_handle(static_cast<MojoHandle>(mojo_handle64));
+ return mojo::MakeScopedHandle(mojo_handle);
+ }
+
+ static Dart_Handle ToDart(mojo::ScopedHandleBase<HandleType> mojo_handle) {
+ return Dart_NewInteger(static_cast<int64_t>(mojo_handle.release().value()));
+ }
+
+ static mojo::ScopedHandleBase<HandleType> FromArgumentsWithNullCheck(
+ Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception,
+ bool auto_scope = true) {
+ int64_t mojo_handle64 = 0;
+ Dart_Handle result = Dart_GetNativeIntegerArgument(args, index, &mojo_handle64);
+ if (Dart_IsError(result) || !mojo_handle64)
+ return mojo::ScopedHandleBase<HandleType>();
+
+ HandleType mojo_handle(static_cast<MojoHandle>(mojo_handle64));
+ return mojo::MakeScopedHandle(mojo_handle);
+ }
+};
+
+} // namespace blink
+
+#endif // SKY_ENGINE_TONIC_MOJO_CONVERTER_H_
« no previous file with comments | « tonic/float32_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698