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

Side by Side Diff: sky/shell/ui/internals.cc

Issue 1200953007: Move internals.dart out of Sky SDK (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: _____ 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "sky/engine/config.h" 5 #include "sky/engine/config.h"
6 #include "sky/shell/ui/internals.h" 6 #include "sky/shell/ui/internals.h"
7 7
8 #include "mojo/public/cpp/application/connect.h" 8 #include "mojo/public/cpp/application/connect.h"
9 #include "mojo/public/cpp/bindings/array.h" 9 #include "mojo/public/cpp/bindings/array.h"
10 #include "services/asset_bundle/asset_unpacker_impl.h" 10 #include "services/asset_bundle/asset_unpacker_impl.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 int argument_count, 45 int argument_count,
46 bool* auto_setup_scope) { 46 bool* auto_setup_scope) {
47 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope); 47 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope);
48 } 48 }
49 49
50 const uint8_t* Symbolizer(Dart_NativeFunction native_function) { 50 const uint8_t* Symbolizer(Dart_NativeFunction native_function) {
51 return GetBuiltin().Symbolizer(native_function); 51 return GetBuiltin().Symbolizer(native_function);
52 } 52 }
53 53
54 const char kLibraryName[] = "dart:sky.internals"; 54 const char kLibraryName[] = "dart:sky.internals";
55 const char kLibrarySource[] = R"DART(
56 int takeServicesProvidedByEmbedder() native "takeServicesProvidedByEmbedder";
57 )DART";
58 55
59 } // namespace 56 } // namespace
60 57
61 void Internals::Create(Dart_Isolate isolate, 58 void Internals::Create(Dart_Isolate isolate,
62 mojo::ServiceProviderPtr service_provider) { 59 mojo::ServiceProviderPtr service_provider) {
63 DartState* state = DartState::From(isolate); 60 DartState* state = DartState::From(isolate);
64 state->SetUserData(&kInternalsKey, new Internals(service_provider.Pass())); 61 state->SetUserData(&kInternalsKey, new Internals(service_provider.Pass()));
65 Dart_Handle library = 62 Dart_Handle library =
66 Dart_LoadLibrary(Dart_NewStringFromCString(kLibraryName), 63 Dart_LookupLibrary(Dart_NewStringFromCString(kLibraryName));
67 Dart_NewStringFromCString(kLibrarySource), 0, 0);
68 CHECK(!LogIfError(library)); 64 CHECK(!LogIfError(library));
69 CHECK(!LogIfError(Dart_FinalizeLoading(true)));
70 CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer))); 65 CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer)));
71 } 66 }
72 67
73 Internals::Internals(mojo::ServiceProviderPtr platform_service_provider) 68 Internals::Internals(mojo::ServiceProviderPtr platform_service_provider)
74 : service_provider_impl_(GetProxy(&service_provider_)), 69 : service_provider_impl_(GetProxy(&service_provider_)),
75 platform_service_provider_(platform_service_provider.Pass()) { 70 platform_service_provider_(platform_service_provider.Pass()) {
76 service_provider_impl_.set_fallback_service_provider( 71 service_provider_impl_.set_fallback_service_provider(
77 platform_service_provider_.get()); 72 platform_service_provider_.get());
78 service_provider_impl_.AddService<mojo::asset_bundle::AssetUnpacker>(this); 73 service_provider_impl_.AddService<mojo::asset_bundle::AssetUnpacker>(this);
79 } 74 }
80 75
81 Internals::~Internals() { 76 Internals::~Internals() {
82 } 77 }
83 78
84 void Internals::Create( 79 void Internals::Create(
85 mojo::ApplicationConnection* connection, 80 mojo::ApplicationConnection* connection,
86 mojo::InterfaceRequest<mojo::asset_bundle::AssetUnpacker> request) { 81 mojo::InterfaceRequest<mojo::asset_bundle::AssetUnpacker> request) {
87 new mojo::asset_bundle::AssetUnpackerImpl(request.Pass()); 82 new mojo::asset_bundle::AssetUnpackerImpl(request.Pass());
88 } 83 }
89 84
90 mojo::Handle Internals::TakeServicesProvidedByEmbedder() { 85 mojo::Handle Internals::TakeServicesProvidedByEmbedder() {
91 return service_provider_.PassInterface().PassHandle().release(); 86 return service_provider_.PassInterface().PassHandle().release();
92 } 87 }
93 88
94 } // namespace shell 89 } // namespace shell
95 } // namespace sky 90 } // namespace sky
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698