mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Wire in Mojo services to sky_shell.mojo
After this patch, code running in sky_shell.mojo has access to Mojo services.
This commit is contained in:
parent
b0d8e5c565
commit
77f873c1a4
@ -7,6 +7,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "mojo/public/cpp/application/connect.h"
|
||||
#include "sky/shell/gpu/mojo/rasterizer_mojo.h"
|
||||
|
||||
namespace sky {
|
||||
@ -23,8 +24,9 @@ PlatformViewMojo::PlatformViewMojo(const Config& config)
|
||||
PlatformViewMojo::~PlatformViewMojo() {
|
||||
}
|
||||
|
||||
void PlatformViewMojo::Init(mojo::ApplicationImpl* app) {
|
||||
app->ConnectToService("mojo:native_viewport_service", &viewport_);
|
||||
void PlatformViewMojo::Init(mojo::ShellPtr shell) {
|
||||
mojo::ConnectToService(
|
||||
shell.get(), "mojo:native_viewport_service", &viewport_);
|
||||
|
||||
mojo::NativeViewportEventDispatcherPtr ptr;
|
||||
dispatcher_binding_.Bind(GetProxy(&ptr));
|
||||
@ -53,11 +55,16 @@ void PlatformViewMojo::Init(mojo::ApplicationImpl* app) {
|
||||
config_.ui_delegate,
|
||||
base::Bind(&RasterizerMojo::OnContextProviderAvailable,
|
||||
rasterizer->GetWeakPtr(), base::Passed(&context_provider_info))));
|
||||
|
||||
ConnectToEngine(mojo::GetProxy(&sky_engine_));
|
||||
|
||||
ServicesDataPtr services = ServicesData::New();
|
||||
services->shell = shell.Pass();
|
||||
sky_engine_->SetServices(services.Pass());
|
||||
}
|
||||
|
||||
void PlatformViewMojo::Run(const mojo::String& url,
|
||||
mojo::asset_bundle::AssetBundlePtr bundle) {
|
||||
ConnectToEngine(mojo::GetProxy(&sky_engine_));
|
||||
sky_engine_->RunFromAssetBundle(url, bundle.Pass());
|
||||
}
|
||||
|
||||
|
||||
@ -5,8 +5,9 @@
|
||||
#ifndef SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_
|
||||
#define SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_
|
||||
|
||||
#include "mojo/public/cpp/application/application_impl.h"
|
||||
#include "mojo/public/cpp/bindings/binding.h"
|
||||
#include "mojo/public/interfaces/application/service_provider.mojom.h"
|
||||
#include "mojo/public/interfaces/application/shell.mojom.h"
|
||||
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
|
||||
#include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h"
|
||||
#include "sky/shell/platform_view.h"
|
||||
@ -20,7 +21,7 @@ class PlatformViewMojo : public PlatformView,
|
||||
explicit PlatformViewMojo(const Config& config);
|
||||
~PlatformViewMojo() override;
|
||||
|
||||
void Init(mojo::ApplicationImpl* app);
|
||||
void Init(mojo::ShellPtr shell);
|
||||
|
||||
void Run(const mojo::String& url,
|
||||
mojo::asset_bundle::AssetBundlePtr bundle);
|
||||
|
||||
@ -14,32 +14,39 @@ namespace shell {
|
||||
SkyApplicationImpl::SkyApplicationImpl(
|
||||
mojo::InterfaceRequest<mojo::Application> application,
|
||||
mojo::URLResponsePtr response)
|
||||
: app_(this, application.Pass()),
|
||||
: binding_(this, application.Pass()),
|
||||
initial_response_(response.Pass()) {
|
||||
}
|
||||
|
||||
SkyApplicationImpl::~SkyApplicationImpl() {
|
||||
}
|
||||
|
||||
void SkyApplicationImpl::Initialize(mojo::ApplicationImpl* app) {
|
||||
void SkyApplicationImpl::Initialize(mojo::ShellPtr shell,
|
||||
mojo::Array<mojo::String> args,
|
||||
const mojo::String& url) {
|
||||
DCHECK(initial_response_);
|
||||
UnpackInitialResponse();
|
||||
UnpackInitialResponse(shell.get());
|
||||
shell_view_.reset(new ShellView(Shell::Shared()));
|
||||
PlatformViewMojo* view = platform_view();
|
||||
view->Init(app);
|
||||
view->Run(app_.url(), bundle_.Pass());
|
||||
view->Init(shell.Pass());
|
||||
view->Run(url, bundle_.Pass());
|
||||
}
|
||||
|
||||
bool SkyApplicationImpl::ConfigureIncomingConnection(
|
||||
mojo::ApplicationConnection* connection) {
|
||||
return true;
|
||||
void SkyApplicationImpl::AcceptConnection(
|
||||
const mojo::String& requestor_url,
|
||||
mojo::InterfaceRequest<mojo::ServiceProvider> services,
|
||||
mojo::ServiceProviderPtr exposed_services,
|
||||
const mojo::String& resolved_url) {
|
||||
}
|
||||
|
||||
void SkyApplicationImpl::UnpackInitialResponse() {
|
||||
void SkyApplicationImpl::RequestQuit() {
|
||||
}
|
||||
|
||||
void SkyApplicationImpl::UnpackInitialResponse(mojo::Shell* shell) {
|
||||
DCHECK(initial_response_);
|
||||
DCHECK(!bundle_);
|
||||
mojo::asset_bundle::AssetUnpackerPtr unpacker;
|
||||
app_.ConnectToService("mojo:asset_bundle", &unpacker);
|
||||
mojo::ConnectToService(shell, "mojo:asset_bundle", &unpacker);
|
||||
unpacker->UnpackZipStream(initial_response_->body.Pass(),
|
||||
mojo::GetProxy(&bundle_));
|
||||
initial_response_ = nullptr;
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
#define SKY_SHELL_PLATFORM_MOJO_SKY_APPLICATION_IMPL_H_
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "mojo/public/cpp/application/application_impl.h"
|
||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||
#include "mojo/public/interfaces/application/application.mojom.h"
|
||||
#include "mojo/public/interfaces/application/shell.mojom.h"
|
||||
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
|
||||
#include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
|
||||
@ -17,25 +17,30 @@
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
class SkyApplicationImpl : public mojo::ApplicationDelegate {
|
||||
class SkyApplicationImpl : public mojo::Application {
|
||||
public:
|
||||
SkyApplicationImpl(mojo::InterfaceRequest<mojo::Application> application,
|
||||
mojo::URLResponsePtr response);
|
||||
~SkyApplicationImpl() override;
|
||||
|
||||
private:
|
||||
// mojo::ApplicationDelegate
|
||||
void Initialize(mojo::ApplicationImpl* app) override;
|
||||
bool ConfigureIncomingConnection(
|
||||
mojo::ApplicationConnection* connection) override;
|
||||
// mojo::Application
|
||||
void Initialize(mojo::ShellPtr shell,
|
||||
mojo::Array<mojo::String> args,
|
||||
const mojo::String& url) override;
|
||||
void AcceptConnection(const mojo::String& requestor_url,
|
||||
mojo::InterfaceRequest<mojo::ServiceProvider> services,
|
||||
mojo::ServiceProviderPtr exposed_services,
|
||||
const mojo::String& resolved_url) override;
|
||||
void RequestQuit() override;
|
||||
|
||||
PlatformViewMojo* platform_view() {
|
||||
return static_cast<PlatformViewMojo*>(shell_view_->view());
|
||||
}
|
||||
|
||||
void UnpackInitialResponse();
|
||||
void UnpackInitialResponse(mojo::Shell* shell);
|
||||
|
||||
mojo::ApplicationImpl app_;
|
||||
mojo::StrongBinding<mojo::Application> binding_;
|
||||
mojo::URLResponsePtr initial_response_;
|
||||
mojo::asset_bundle::AssetBundlePtr bundle_;
|
||||
scoped_ptr<ShellView> shell_view_;
|
||||
|
||||
@ -32,7 +32,8 @@ void TakeRootBundleHandle(Dart_NativeArguments args) {
|
||||
}
|
||||
|
||||
void TakeShellProxyHandle(Dart_NativeArguments args) {
|
||||
Dart_SetIntegerReturnValue(args, 0);
|
||||
Dart_SetIntegerReturnValue(
|
||||
args, GetInternals()->TakeShellProxy().value());
|
||||
}
|
||||
|
||||
void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) {
|
||||
@ -117,6 +118,10 @@ void Internals::Create(
|
||||
request.Pass(), base::WorkerPool::GetTaskRunner(true));
|
||||
}
|
||||
|
||||
mojo::Handle Internals::TakeShellProxy() {
|
||||
return services_ ? services_->shell.PassInterface().PassHandle().release() : mojo::Handle();
|
||||
}
|
||||
|
||||
mojo::Handle Internals::TakeServicesProvidedByEmbedder() {
|
||||
return service_provider_.PassInterface().PassHandle().release();
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ class Internals
|
||||
ServicesDataPtr services,
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle);
|
||||
|
||||
mojo::Handle TakeShellProxy();
|
||||
mojo::Handle TakeServicesProvidedByEmbedder();
|
||||
mojo::Handle TakeRootBundleHandle();
|
||||
mojo::Handle TakeServicesProvidedToEmbedder();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user