Chromium Code Reviews| Index: sky/engine/tonic/dart_converter.h |
| diff --git a/sky/engine/tonic/dart_converter.h b/sky/engine/tonic/dart_converter.h |
| index c40fe5383dc69a0dd30bdf9df9d937c742430342..52deadcd5670dba3ad5f51bafaa7e087cb9bdece 100644 |
| --- a/sky/engine/tonic/dart_converter.h |
| +++ b/sky/engine/tonic/dart_converter.h |
| @@ -6,6 +6,7 @@ |
| #define SKY_ENGINE_TONIC_DART_CONVERTER_H_ |
| #include <string> |
| +#include "mojo/public/cpp/system/handle.h" |
| #include "sky/engine/tonic/dart_state.h" |
| #include "sky/engine/tonic/dart_string.h" |
| #include "sky/engine/tonic/dart_string_cache.h" |
| @@ -266,6 +267,26 @@ struct DartConverter<Vector<T>> { |
| }; |
| //////////////////////////////////////////////////////////////////////////////// |
| +// mojo types |
| + |
| +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())); |
| + } |
| +}; |
|
abarth-chromium
2015/02/23 22:29:37
Please move this declaration to a separate header
|
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| // DartValue |
| template <> |