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.
This commit is contained in:
Adam Barth 2015-06-22 21:32:48 -07:00
parent 900cb7feeb
commit 9c97ffd89c
3 changed files with 72 additions and 57 deletions

View File

@ -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 = [

View File

@ -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<mojo::asset_bundle::AssetUnpacker>(this);
}
Internals::~Internals() {
}
void Internals::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::asset_bundle::AssetUnpacker> request) {
new mojo::asset_bundle::AssetUnpackerImpl(request.Pass());
}
mojo::Handle Internals::TakeServicesProvidedByEmbedder() {
return service_provider_.PassInterface().PassHandle().release();
}

View File

@ -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<mojo::asset_bundle::AssetUnpacker> {
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<mojo::asset_bundle::AssetUnpacker>| implementation:
void Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::asset_bundle::AssetUnpacker>) override;
mojo::ServiceProviderPtr service_provider_;
mojo::ServiceProviderImpl service_provider_impl_;
mojo::ServiceProviderPtr platform_service_provider_;
MOJO_DISALLOW_COPY_AND_ASSIGN(Internals);
};