From 9c97ffd89c65fa11d5d2bc9c68edeed83aa073b5 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 22 Jun 2015 21:32:48 -0700 Subject: [PATCH] Expose the asset_bundle service in SkyShell The plan is to use this service for game assets and offline assets. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1193763004. --- engine/src/flutter/shell/BUILD.gn | 92 +++++++++++------------- engine/src/flutter/shell/ui/internals.cc | 15 +++- engine/src/flutter/shell/ui/internals.h | 22 +++++- 3 files changed, 72 insertions(+), 57 deletions(-) diff --git a/engine/src/flutter/shell/BUILD.gn b/engine/src/flutter/shell/BUILD.gn index 64b88ddd26..0299d77428 100644 --- a/engine/src/flutter/shell/BUILD.gn +++ b/engine/src/flutter/shell/BUILD.gn @@ -11,18 +11,52 @@ common_deps = [ "//mojo/edk/system", "//mojo/public/cpp/application", "//mojo/public/interfaces/application", + "//mojo/services/asset_bundle/public/interfaces", "//mojo/services/navigation/public/interfaces", "//mojo/services/network/public/interfaces", + "//services/asset_bundle:lib", "//skia", "//sky/engine", - "//sky/engine/wtf", "//sky/engine/tonic", + "//sky/engine/wtf", "//sky/services/platform", "//sky/services/viewport", "//ui/gfx/geometry", "//ui/gl", ] +source_set("common") { + sources = [ + "gpu/ganesh_context.cc", + "gpu/ganesh_context.h", + "gpu/ganesh_surface.cc", + "gpu/ganesh_surface.h", + "gpu/rasterizer.cc", + "gpu/rasterizer.h", + "gpu_delegate.cc", + "gpu_delegate.h", + "platform_view.cc", + "platform_view.h", + "service_provider.h", + "shell.cc", + "shell.h", + "shell_view.cc", + "shell_view.h", + "ui/animator.cc", + "ui/animator.h", + "ui/engine.cc", + "ui/engine.h", + "ui/input_event_converter.cc", + "ui/input_event_converter.h", + "ui/internals.cc", + "ui/internals.h", + "ui_delegate.cc", + "ui_delegate.h", + ] + + deps = common_deps +} + if (is_android) { import("//build/config/android/config.gni") import("//build/config/android/rules.gni") @@ -48,36 +82,12 @@ if (is_android) { "android/sky_main.h", "android/tracing_controller.cc", "android/tracing_controller.h", - "gpu/ganesh_context.cc", - "gpu/ganesh_context.h", - "gpu/ganesh_surface.cc", - "gpu/ganesh_surface.h", - "gpu/rasterizer.cc", - "gpu/rasterizer.h", - "gpu_delegate.cc", - "gpu_delegate.h", - "platform_view.cc", - "platform_view.h", - "service_provider.h", - "shell.cc", - "shell.h", - "shell_view.cc", - "shell_view.h", - "ui/animator.cc", - "ui/animator.h", - "ui/engine.cc", - "ui/engine.h", - "ui/input_event_converter.cc", - "ui/input_event_converter.h", - "ui/internals.cc", - "ui/internals.h", - "ui_delegate.cc", - "ui_delegate.h", ] deps = common_deps + [ "//mojo/android:libsystem_java", ":jni_headers", + ":common", ] } @@ -135,14 +145,6 @@ if (is_android) { source_set(scaffolding_target) { sources = [ - "gpu/ganesh_context.cc", - "gpu/ganesh_context.h", - "gpu/ganesh_surface.cc", - "gpu/ganesh_surface.h", - "gpu/rasterizer.cc", - "gpu/rasterizer.h", - "gpu_delegate.cc", - "gpu_delegate.h", "ios/main_ios.mm", "ios/platform_service_provider_ios.cc", "ios/platform_view_ios.h", @@ -154,26 +156,12 @@ if (is_android) { "ios/sky_view_controller.h", "ios/sky_view_controller.mm", "platform_view.cc", - "platform_view.h", - "shell.cc", - "shell.h", - "shell_view.cc", - "shell_view.h", - "ui/animator.cc", - "ui/animator.h", - "ui/engine.cc", - "ui/engine.h", - "ui/input_event_converter.cc", - "ui/input_event_converter.h", - "ui/internals.cc", - "ui/internals.h", - "ui_delegate.cc", - "ui_delegate.h", ] - ios_deps = [ "//sky/services/ns_net" ] - - deps = common_deps + ios_deps + deps = common_deps + [ + ":common", + "//sky/services/ns_net", + ] } deps = [ diff --git a/engine/src/flutter/shell/ui/internals.cc b/engine/src/flutter/shell/ui/internals.cc index f6049e672a..676f3521ba 100644 --- a/engine/src/flutter/shell/ui/internals.cc +++ b/engine/src/flutter/shell/ui/internals.cc @@ -7,6 +7,7 @@ #include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/bindings/array.h" +#include "services/asset_bundle/asset_unpacker_impl.h" #include "sky/engine/tonic/dart_builtin.h" #include "sky/engine/tonic/dart_converter.h" #include "sky/engine/tonic/dart_error.h" @@ -69,13 +70,23 @@ void Internals::Create(Dart_Isolate isolate, CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer))); } -Internals::Internals(mojo::ServiceProviderPtr service_provider) - : service_provider_(service_provider.Pass()) { +Internals::Internals(mojo::ServiceProviderPtr platform_service_provider) + : service_provider_impl_(GetProxy(&service_provider_)), + platform_service_provider_(platform_service_provider.Pass()) { + service_provider_impl_.set_fallback_service_provider( + platform_service_provider_.get()); + service_provider_impl_.AddService(this); } Internals::~Internals() { } +void Internals::Create( + mojo::ApplicationConnection* connection, + mojo::InterfaceRequest request) { + new mojo::asset_bundle::AssetUnpackerImpl(request.Pass()); +} + mojo::Handle Internals::TakeServicesProvidedByEmbedder() { return service_provider_.PassInterface().PassHandle().release(); } diff --git a/engine/src/flutter/shell/ui/internals.h b/engine/src/flutter/shell/ui/internals.h index c0efac913a..7077e3e28b 100644 --- a/engine/src/flutter/shell/ui/internals.h +++ b/engine/src/flutter/shell/ui/internals.h @@ -7,24 +7,40 @@ #include "base/supports_user_data.h" #include "dart/runtime/include/dart_api.h" +#include "mojo/public/cpp/application/interface_factory.h" +#include "mojo/public/cpp/application/service_provider_impl.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" +#include "mojo/services/asset_bundle/public/interfaces/asset_bundle.mojom.h" + +namespace mojo { +class ApplicationConnection; +} namespace sky { namespace shell { -class Internals : public base::SupportsUserData::Data { +class Internals + : public base::SupportsUserData::Data, + public mojo::InterfaceFactory { public: virtual ~Internals(); static void Create(Dart_Isolate isolate, - mojo::ServiceProviderPtr service_provider); + mojo::ServiceProviderPtr platform_service_provider); mojo::Handle TakeServicesProvidedByEmbedder(); private: - explicit Internals(mojo::ServiceProviderPtr service_provider); + explicit Internals(mojo::ServiceProviderPtr platform_service_provider); + + // |mojo::InterfaceFactory| implementation: + void Create( + mojo::ApplicationConnection* connection, + mojo::InterfaceRequest) override; mojo::ServiceProviderPtr service_provider_; + mojo::ServiceProviderImpl service_provider_impl_; + mojo::ServiceProviderPtr platform_service_provider_; MOJO_DISALLOW_COPY_AND_ASSIGN(Internals); };