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

Side by Side Diff: sky/engine/tonic/mojo_converter.h

Issue 1173703002: Move image loading out of C++ into Dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rename fetchMojo to fetchUrl Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/loader/ImageLoaderCallback.idl ('k') | sky/examples/stocks/lib/stock_data.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SKY_ENGINE_TONIC_MOJO_CONVERTER_H_ 5 #ifndef SKY_ENGINE_TONIC_MOJO_CONVERTER_H_
6 #define SKY_ENGINE_TONIC_MOJO_CONVERTER_H_ 6 #define SKY_ENGINE_TONIC_MOJO_CONVERTER_H_
7 7
8 #include "mojo/public/cpp/system/handle.h" 8 #include "mojo/public/cpp/system/handle.h"
9 #include "sky/engine/tonic/dart_converter.h" 9 #include "sky/engine/tonic/dart_converter.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 template <typename HandleType> 13 template <typename HandleType>
14 struct DartConverter<mojo::ScopedHandleBase<HandleType>> { 14 struct DartConverter<mojo::ScopedHandleBase<HandleType>> {
15 static mojo::ScopedHandleBase<HandleType> FromDart(Dart_Handle handle) { 15 static mojo::ScopedHandleBase<HandleType> FromDart(Dart_Handle handle) {
16 uint64_t mojo_handle64 = 0; 16 uint64_t mojo_handle64 = 0;
17 Dart_Handle result = Dart_IntegerToUint64(handle, &mojo_handle64); 17 Dart_Handle result = Dart_IntegerToUint64(handle, &mojo_handle64);
18 if (Dart_IsError(result) || !mojo_handle64) 18 if (Dart_IsError(result) || !mojo_handle64)
19 return mojo::ScopedHandleBase<HandleType>(); 19 return mojo::ScopedHandleBase<HandleType>();
20 20
21 HandleType mojo_handle(static_cast<MojoHandle>(mojo_handle64)); 21 HandleType mojo_handle(static_cast<MojoHandle>(mojo_handle64));
22 return mojo::MakeScopedHandle(mojo_handle); 22 return mojo::MakeScopedHandle(mojo_handle);
23 } 23 }
24 24
25 static Dart_Handle ToDart(mojo::ScopedHandleBase<HandleType> mojo_handle) { 25 static Dart_Handle ToDart(mojo::ScopedHandleBase<HandleType> mojo_handle) {
26 return Dart_NewInteger(static_cast<int64_t>(mojo_handle.release().value())); 26 return Dart_NewInteger(static_cast<int64_t>(mojo_handle.release().value()));
27 } 27 }
28
29 static mojo::ScopedHandleBase<HandleType> FromArgumentsWithNullCheck(
30 Dart_NativeArguments args,
31 int index,
32 Dart_Handle& exception,
33 bool auto_scope = true) {
34 int64_t mojo_handle64 = 0;
35 Dart_Handle result = Dart_GetNativeIntegerArgument(args, index, &mojo_handle 64);
36 if (Dart_IsError(result) || !mojo_handle64)
37 return mojo::ScopedHandleBase<HandleType>();
38
39 HandleType mojo_handle(static_cast<MojoHandle>(mojo_handle64));
40 return mojo::MakeScopedHandle(mojo_handle);
41 }
28 }; 42 };
29 43
30 } // namespace blink 44 } // namespace blink
31 45
32 #endif // SKY_ENGINE_TONIC_MOJO_CONVERTER_H_ 46 #endif // SKY_ENGINE_TONIC_MOJO_CONVERTER_H_
OLDNEW
« no previous file with comments | « sky/engine/core/loader/ImageLoaderCallback.idl ('k') | sky/examples/stocks/lib/stock_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698