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,43 +11,22 @@ common_deps = [
"//mojo/edk/system", "//mojo/edk/system",
"//mojo/public/cpp/application", "//mojo/public/cpp/application",
"//mojo/public/interfaces/application", "//mojo/public/interfaces/application",
"//mojo/services/asset_bundle/public/interfaces",
"//mojo/services/navigation/public/interfaces", "//mojo/services/navigation/public/interfaces",
"//mojo/services/network/public/interfaces", "//mojo/services/network/public/interfaces",
"//services/asset_bundle:lib",
"//skia", "//skia",
"//sky/engine", "//sky/engine",
"//sky/engine/wtf",
"//sky/engine/tonic", "//sky/engine/tonic",
"//sky/engine/wtf",
"//sky/services/platform", "//sky/services/platform",
"//sky/services/viewport", "//sky/services/viewport",
"//ui/gfx/geometry", "//ui/gfx/geometry",
"//ui/gl", "//ui/gl",
] ]
if (is_android) { source_set("common") {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
generate_jni("jni_headers") {
sources = [ sources = [
"android/org/domokit/sky/shell/PlatformServiceProvider.java",
"android/org/domokit/sky/shell/PlatformViewAndroid.java",
"android/org/domokit/sky/shell/SkyMain.java",
"android/org/domokit/sky/shell/TracingController.java",
]
jni_package = "sky/shell"
}
shared_library("sky_shell") {
sources = [
"android/library_loader.cc",
"android/platform_service_provider_android.cc",
"android/platform_service_provider_android.h",
"android/platform_view_android.cc",
"android/platform_view_android.h",
"android/sky_main.cc",
"android/sky_main.h",
"android/tracing_controller.cc",
"android/tracing_controller.h",
"gpu/ganesh_context.cc", "gpu/ganesh_context.cc",
"gpu/ganesh_context.h", "gpu/ganesh_context.h",
"gpu/ganesh_surface.cc", "gpu/ganesh_surface.cc",
@ -75,9 +54,40 @@ if (is_android) {
"ui_delegate.h", "ui_delegate.h",
] ]
deps = common_deps
}
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
generate_jni("jni_headers") {
sources = [
"android/org/domokit/sky/shell/PlatformServiceProvider.java",
"android/org/domokit/sky/shell/PlatformViewAndroid.java",
"android/org/domokit/sky/shell/SkyMain.java",
"android/org/domokit/sky/shell/TracingController.java",
]
jni_package = "sky/shell"
}
shared_library("sky_shell") {
sources = [
"android/library_loader.cc",
"android/platform_service_provider_android.cc",
"android/platform_service_provider_android.h",
"android/platform_view_android.cc",
"android/platform_view_android.h",
"android/sky_main.cc",
"android/sky_main.h",
"android/tracing_controller.cc",
"android/tracing_controller.h",
]
deps = common_deps + [ deps = common_deps + [
"//mojo/android:libsystem_java", "//mojo/android:libsystem_java",
":jni_headers", ":jni_headers",
":common",
] ]
} }
@ -135,14 +145,6 @@ if (is_android) {
source_set(scaffolding_target) { source_set(scaffolding_target) {
sources = [ 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/main_ios.mm",
"ios/platform_service_provider_ios.cc", "ios/platform_service_provider_ios.cc",
"ios/platform_view_ios.h", "ios/platform_view_ios.h",
@ -154,26 +156,12 @@ if (is_android) {
"ios/sky_view_controller.h", "ios/sky_view_controller.h",
"ios/sky_view_controller.mm", "ios/sky_view_controller.mm",
"platform_view.cc", "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 + [
":common",
deps = common_deps + ios_deps "//sky/services/ns_net",
]
} }
deps = [ deps = [

View File

@ -7,6 +7,7 @@
#include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/application/connect.h"
#include "mojo/public/cpp/bindings/array.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_builtin.h"
#include "sky/engine/tonic/dart_converter.h" #include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_error.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))); CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer)));
} }
Internals::Internals(mojo::ServiceProviderPtr service_provider) Internals::Internals(mojo::ServiceProviderPtr platform_service_provider)
: service_provider_(service_provider.Pass()) { : 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() { 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() { mojo::Handle Internals::TakeServicesProvidedByEmbedder() {
return service_provider_.PassInterface().PassHandle().release(); return service_provider_.PassInterface().PassHandle().release();
} }

View File

@ -7,24 +7,40 @@
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "dart/runtime/include/dart_api.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/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 sky {
namespace shell { namespace shell {
class Internals : public base::SupportsUserData::Data { class Internals
: public base::SupportsUserData::Data,
public mojo::InterfaceFactory<mojo::asset_bundle::AssetUnpacker> {
public: public:
virtual ~Internals(); virtual ~Internals();
static void Create(Dart_Isolate isolate, static void Create(Dart_Isolate isolate,
mojo::ServiceProviderPtr service_provider); mojo::ServiceProviderPtr platform_service_provider);
mojo::Handle TakeServicesProvidedByEmbedder(); mojo::Handle TakeServicesProvidedByEmbedder();
private: 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::ServiceProviderPtr service_provider_;
mojo::ServiceProviderImpl service_provider_impl_;
mojo::ServiceProviderPtr platform_service_provider_;
MOJO_DISALLOW_COPY_AND_ASSIGN(Internals); MOJO_DISALLOW_COPY_AND_ASSIGN(Internals);
}; };