OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SKY_ENGINE_TONIC_MOJO_CONVERTER_H_ |
| 6 #define SKY_ENGINE_TONIC_MOJO_CONVERTER_H_ |
| 7 |
| 8 #include "mojo/public/cpp/system/handle.h" |
| 9 #include "sky/engine/tonic/dart_converter.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 template <typename HandleType> |
| 14 struct DartConverter<mojo::ScopedHandleBase<HandleType>> { |
| 15 static mojo::ScopedHandleBase<HandleType> FromDart(Dart_Handle handle) { |
| 16 uint64_t mojo_handle64 = 0; |
| 17 Dart_Handle result = Dart_IntegerToUint64(handle, &mojo_handle64); |
| 18 if (Dart_IsError(result) || !mojo_handle64) |
| 19 return mojo::ScopedHandleBase<HandleType>(); |
| 20 |
| 21 HandleType mojo_handle(static_cast<MojoHandle>(mojo_handle64)); |
| 22 return mojo::MakeScopedHandle(mojo_handle); |
| 23 } |
| 24 |
| 25 static Dart_Handle ToDart(mojo::ScopedHandleBase<HandleType> mojo_handle) { |
| 26 return Dart_NewInteger(static_cast<int64_t>(mojo_handle.release().value())); |
| 27 } |
| 28 }; |
| 29 |
| 30 } // namespace blink |
| 31 |
| 32 #endif // SKY_ENGINE_TONIC_MOJO_CONVERTER_H_ |
OLD | NEW |