提交 04391cf9 编写于 作者: A Adam Barth

Add a basic sky_shell.mojo

Currently sky_shell.mojo can't load any Flutter apps or draw to the screen, but
that will come in later patches.
上级 036cd470
......@@ -13,6 +13,10 @@ group("sky") {
"//sky/tools/sky_snapshot($host_toolchain)",
]
if (is_linux || is_android) {
deps += [ "//sky/shell/platform/mojo" ]
}
if (is_android) {
deps += [ "//sky/services/activity" ]
}
......
......@@ -8,7 +8,6 @@ common_deps = [
"//build/config/sanitizers:deps",
"//dart/runtime:libdart",
"//mojo/data_pipe_utils",
"//mojo/edk/system",
"//mojo/message_pump",
"//mojo/public/cpp/application",
"//mojo/public/interfaces/application",
......@@ -110,6 +109,7 @@ if (is_android) {
deps = common_deps + [
"//mojo/android:libsystem_java",
"//mojo/edk/system",
":jni_headers",
":common",
]
......@@ -216,6 +216,7 @@ if (is_android) {
deps = common_deps + [
":common",
"//mojo/edk/system",
"//sky/services/keyboard",
"//sky/services/media",
"//sky/services/ns_net",
......@@ -238,6 +239,7 @@ if (is_android) {
deps = common_deps + [
":common",
"//mojo/edk/system",
"//mojo/common",
]
}
......@@ -263,6 +265,7 @@ if (is_android) {
deps = common_deps + [
":common",
"//mojo/common",
"//mojo/edk/system",
"//sky/services/ns_net",
]
}
......
......@@ -19,6 +19,8 @@
#include "base/run_loop.h"
#include "base/threading/simple_thread.h"
#include "jni/SkyMain_jni.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/simple_platform_support.h"
#include "sky/shell/service_provider.h"
#include "sky/shell/shell.h"
......@@ -73,6 +75,9 @@ static void Init(JNIEnv* env,
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
base::MessageLoopForUI::current()->Start();
mojo::embedder::Init(std::unique_ptr<mojo::embedder::PlatformSupport>(
new mojo::embedder::SimplePlatformSupport()));
Shell::Init(make_scoped_ptr(new ServiceProviderContext(
g_java_message_loop.Get()->task_runner())));
......
......@@ -8,6 +8,8 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/simple_platform_support.h"
#include "sky/shell/service_provider.h"
#include "sky/shell/shell.h"
#include "sky/shell/switches.h"
......@@ -26,6 +28,9 @@ int main(int argc, const char* argv[]) {
base::MessageLoop message_loop;
mojo::embedder::Init(std::unique_ptr<mojo::embedder::PlatformSupport>(
new mojo::embedder::SimplePlatformSupport()));
sky::shell::Shell::Init(make_scoped_ptr(
new sky::shell::ServiceProviderContext(message_loop.task_runner())));
......
......@@ -6,16 +6,18 @@
#include <asl.h>
#include "base/at_exit.h"
#include "base/logging.h"
#include "base/i18n/icu_util.h"
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "ui/gl/gl_surface.h"
#include "sky/shell/shell.h"
#include "base/message_loop/message_loop.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/simple_platform_support.h"
#include "sky/shell/service_provider.h"
#include "sky/shell/shell.h"
#include "sky/shell/ui_delegate.h"
#include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h"
#include "ui/gl/gl_surface.h"
static void InitializeLogging() {
logging::LoggingSettings settings;
......@@ -60,6 +62,9 @@ int PlatformMacMain(int argc,
message_loop->Attach();
#endif
mojo::embedder::Init(std::unique_ptr<mojo::embedder::PlatformSupport>(
new mojo::embedder::SimplePlatformSupport()));
sky::shell::Shell::Init(make_scoped_ptr(
new sky::shell::ServiceProviderContext(message_loop->task_runner())));
......
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/public/mojo_application.gni")
import("//mojo/public/tools/bindings/mojom.gni")
mojo_native_application("mojo") {
output_name = "sky_shell"
sources = [
"main_mojo.cc",
"platform_service_provider_mojo.cc",
"platform_view_mojo.cc",
"platform_view_mojo.h",
]
deps = [
"//mojo/application",
"//mojo/common",
"//mojo/common:tracing_impl",
"//mojo/converters/geometry",
"//mojo/converters/input_events",
"//mojo/icu",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//mojo/public/cpp/utility",
"//mojo/public/interfaces/application",
"//mojo/services/content_handler/interfaces",
"//mojo/services/gpu/interfaces",
"//mojo/services/input_events/interfaces",
"//mojo/services/navigation/interfaces",
"//mojo/services/network/interfaces",
"//mojo/services/service_registry/interfaces",
"//mojo/services/surfaces/interfaces",
"//mojo/services/view_manager/cpp",
"//mojo/services/view_manager/interfaces",
"//services/asset_bundle:lib",
"//services/sky/compositor",
"//skia",
"//sky/engine/public/sky",
"//sky/engine/tonic",
"//sky/engine/web",
"//sky/shell:common",
"//third_party/icu",
"//ui/events",
"//url",
]
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/common/tracing_impl.h"
#include "mojo/icu/icu.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/interface_factory_impl.h"
#include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
#include "sky/shell/shell.h"
#include "sky/shell/service_provider.h"
namespace sky {
namespace shell {
class MojoApp : public mojo::ApplicationDelegate,
public mojo::InterfaceFactory<mojo::ContentHandler> {
public:
MojoApp() {}
~MojoApp() override { }
private:
// Overridden from ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override {
mojo::icu::Initialize(app);
tracing_.Initialize(app);
Shell::Init(make_scoped_ptr(
new ServiceProviderContext(base::MessageLoop::current()->task_runner())));
}
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override {
connection->AddService<mojo::ContentHandler>(this);
return true;
}
// Overridden from InterfaceFactory<ContentHandler>
void Create(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::ContentHandler> request) override {
}
mojo::TracingImpl tracing_;
DISALLOW_COPY_AND_ASSIGN(MojoApp);
};
} // namespace shell
} // namespace sky
MojoResult MojoMain(MojoHandle application_request) {
mojo::ApplicationRunnerChromium runner(new sky::shell::MojoApp);
return runner.Run(application_request);
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "sky/shell/service_provider.h"
namespace sky {
namespace shell {
namespace {
class PlatformServiceProvider : public mojo::ServiceProvider {
public:
PlatformServiceProvider(mojo::InterfaceRequest<mojo::ServiceProvider> request)
: binding_(this, request.Pass()) {}
void ConnectToService(const mojo::String& service_name,
mojo::ScopedMessagePipeHandle client_handle) override {
}
private:
mojo::StrongBinding<mojo::ServiceProvider> binding_;
};
static void CreatePlatformServiceProvider(
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
new PlatformServiceProvider(request.Pass());
}
} // namespace
mojo::ServiceProviderPtr CreateServiceProvider(
ServiceProviderContext* context) {
DCHECK(context);
mojo::MessagePipe pipe;
auto request = mojo::MakeRequest<mojo::ServiceProvider>(pipe.handle1.Pass());
context->platform_task_runner->PostTask(
FROM_HERE, base::Bind(CreatePlatformServiceProvider, base::Passed(&request)));
return mojo::MakeProxy(
mojo::InterfacePtrInfo<mojo::ServiceProvider>(pipe.handle0.Pass(), 0u));
}
} // namespace shell
} // namespace sky
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/shell/platform/mojo/platform_view_mojo.h"
namespace sky {
namespace shell {
PlatformView* PlatformView::Create(const Config& config) {
return new PlatformViewMojo(config);
}
PlatformViewMojo::PlatformViewMojo(const Config& config) : PlatformView(config) {}
PlatformViewMojo::~PlatformViewMojo() {}
} // namespace shell
} // namespace sky
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_
#define SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_
#include "sky/shell/platform_view.h"
namespace sky {
namespace shell {
class PlatformViewMojo : public PlatformView {
public:
explicit PlatformViewMojo(const Config& config);
~PlatformViewMojo() override;
private:
DISALLOW_COPY_AND_ASSIGN(PlatformViewMojo);
};
} // namespace shell
} // namespace sky
#endif // SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_
......@@ -13,8 +13,6 @@
#include "base/memory/discardable_memory_allocator.h"
#include "base/single_thread_task_runner.h"
#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/simple_platform_support.h"
#include "sky/shell/ui/engine.h"
#include "ui/gl/gl_surface.h"
......@@ -54,8 +52,6 @@ base::LazyInstance<NonDiscardableMemoryAllocator> g_discardable;
Shell::Shell(scoped_ptr<ServiceProviderContext> service_provider_context)
: service_provider_context_(service_provider_context.Pass()) {
DCHECK(!g_shell);
mojo::embedder::Init(std::unique_ptr<mojo::embedder::PlatformSupport>(
new mojo::embedder::SimplePlatformSupport()));
base::Thread::Options options;
options.message_pump_factory = base::Bind(&CreateMessagePumpMojo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册