mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make android directory for Android-specific bits of SkyShell
This CL prepares us to create an iOS version of SkyShell by moving the Android-specific bits into an android directory. R=chinmaygarde@google.com Review URL: https://codereview.chromium.org/1139873004
This commit is contained in:
parent
cd069f2a21
commit
67b59fadb9
@ -9,16 +9,25 @@ import("//build/config/android/rules.gni")
|
||||
|
||||
generate_jni("jni_headers") {
|
||||
sources = [
|
||||
"org/domokit/sky/shell/JavaServiceProvider.java",
|
||||
"org/domokit/sky/shell/PlatformView.java",
|
||||
"org/domokit/sky/shell/SkyMain.java",
|
||||
"org/domokit/sky/shell/TracingController.java",
|
||||
"android/org/domokit/sky/shell/PlatformServiceProvider.java",
|
||||
"android/org/domokit/sky/shell/PlatformView.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.cc",
|
||||
"android/platform_service_provider.h",
|
||||
"android/platform_view.cc",
|
||||
"android/platform_view.h",
|
||||
"android/sky_main.cc",
|
||||
"android/sky_main.h",
|
||||
"android/tracing_controller.cc",
|
||||
"android/tracing_controller.h",
|
||||
"gpu/ganesh_context.cc",
|
||||
"gpu/ganesh_context.h",
|
||||
"gpu/ganesh_surface.cc",
|
||||
@ -27,17 +36,9 @@ shared_library("sky_shell") {
|
||||
"gpu/rasterizer.h",
|
||||
"gpu_delegate.cc",
|
||||
"gpu_delegate.h",
|
||||
"java_service_provider.cc",
|
||||
"java_service_provider.h",
|
||||
"library_loader.cc",
|
||||
"platform_view.cc",
|
||||
"platform_view.h",
|
||||
"service_provider.h",
|
||||
"shell.cc",
|
||||
"shell.h",
|
||||
"sky_main.cc",
|
||||
"sky_main.h",
|
||||
"tracing_controller.cc",
|
||||
"tracing_controller.h",
|
||||
"ui/animator.cc",
|
||||
"ui/animator.h",
|
||||
"ui/engine.cc",
|
||||
@ -75,15 +76,15 @@ shared_library("sky_shell") {
|
||||
|
||||
android_library("java") {
|
||||
java_files = [
|
||||
"org/domokit/sky/shell/GestureProvider.java",
|
||||
"org/domokit/sky/shell/JavaServiceProvider.java",
|
||||
"org/domokit/sky/shell/PlatformView.java",
|
||||
"org/domokit/sky/shell/ServiceFactory.java",
|
||||
"org/domokit/sky/shell/ServiceRegistry.java",
|
||||
"org/domokit/sky/shell/SkyActivity.java",
|
||||
"org/domokit/sky/shell/SkyApplication.java",
|
||||
"org/domokit/sky/shell/SkyMain.java",
|
||||
"org/domokit/sky/shell/TracingController.java",
|
||||
"android/org/domokit/sky/shell/GestureProvider.java",
|
||||
"android/org/domokit/sky/shell/PlatformServiceProvider.java",
|
||||
"android/org/domokit/sky/shell/PlatformView.java",
|
||||
"android/org/domokit/sky/shell/ServiceFactory.java",
|
||||
"android/org/domokit/sky/shell/ServiceRegistry.java",
|
||||
"android/org/domokit/sky/shell/SkyActivity.java",
|
||||
"android/org/domokit/sky/shell/SkyApplication.java",
|
||||
"android/org/domokit/sky/shell/SkyMain.java",
|
||||
"android/org/domokit/sky/shell/TracingController.java",
|
||||
]
|
||||
|
||||
deps = [
|
||||
|
||||
@ -10,16 +10,16 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "mojo/android/system/core_impl.h"
|
||||
#include "sky/shell/java_service_provider.h"
|
||||
#include "sky/shell/platform_view.h"
|
||||
#include "sky/shell/sky_main.h"
|
||||
#include "sky/shell/tracing_controller.h"
|
||||
#include "sky/shell/android/platform_service_provider.h"
|
||||
#include "sky/shell/android/platform_view.h"
|
||||
#include "sky/shell/android/sky_main.h"
|
||||
#include "sky/shell/android/tracing_controller.h"
|
||||
|
||||
namespace {
|
||||
|
||||
base::android::RegistrationMethod kSkyRegisteredMethods[] = {
|
||||
{"CoreImpl", mojo::android::RegisterCoreImpl},
|
||||
{"JavaServiceProvider", sky::shell::RegisterJavaServiceProvider},
|
||||
{"PlatformServiceProvider", sky::shell::RegisterPlatformServiceProvider},
|
||||
{"PlatformView", sky::shell::PlatformView::Register},
|
||||
{"SkyMain", sky::shell::RegisterSkyMain},
|
||||
{"TracingController", sky::shell::RegisterTracingController},
|
||||
@ -18,7 +18,7 @@ import org.chromium.mojom.mojo.ServiceProvider;
|
||||
* A collection of services implemented in Java.
|
||||
**/
|
||||
@JNINamespace("sky::shell")
|
||||
public class JavaServiceProvider implements ServiceProvider {
|
||||
public class PlatformServiceProvider implements ServiceProvider {
|
||||
private Core mCore;
|
||||
private Context mContext;
|
||||
|
||||
@ -27,10 +27,10 @@ public class JavaServiceProvider implements ServiceProvider {
|
||||
public static void create(Context context, int nativeHandle) {
|
||||
Core core = CoreImpl.getInstance();
|
||||
MessagePipeHandle pipe = core.acquireNativeHandle(nativeHandle).toMessagePipeHandle();
|
||||
ServiceProvider.MANAGER.bind(new JavaServiceProvider(core, context), pipe);
|
||||
ServiceProvider.MANAGER.bind(new PlatformServiceProvider(core, context), pipe);
|
||||
}
|
||||
|
||||
public JavaServiceProvider(Core core, Context context) {
|
||||
public PlatformServiceProvider(Core core, Context context) {
|
||||
assert core != null;
|
||||
assert context != null;
|
||||
mCore = core;
|
||||
45
shell/android/platform_service_provider.cc
Normal file
45
shell/android/platform_service_provider.cc
Normal file
@ -0,0 +1,45 @@
|
||||
// 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/android/platform_service_provider.h"
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "jni/PlatformServiceProvider_jni.h"
|
||||
#include "mojo/public/cpp/bindings/interface_request.h"
|
||||
#include "sky/shell/service_provider.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
namespace {
|
||||
|
||||
void CreatePlatformServiceProvider(
|
||||
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
|
||||
Java_PlatformServiceProvider_create(
|
||||
base::android::AttachCurrentThread(),
|
||||
base::android::GetApplicationContext(),
|
||||
request.PassMessagePipe().release().value());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool RegisterPlatformServiceProvider(JNIEnv* env) {
|
||||
return RegisterNativesImpl(env);
|
||||
}
|
||||
|
||||
mojo::ServiceProviderPtr CreateServiceProvider(
|
||||
ServiceProviderContext* context) {
|
||||
mojo::MessagePipe pipe;
|
||||
context->java_task_runner->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(CreatePlatformServiceProvider,
|
||||
base::Passed(mojo::MakeRequest<mojo::ServiceProvider>(
|
||||
pipe.handle1.Pass()))));
|
||||
return mojo::MakeProxy(
|
||||
mojo::InterfacePtrInfo<mojo::ServiceProvider>(pipe.handle0.Pass(), 0u));
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
18
shell/android/platform_service_provider.h
Normal file
18
shell/android/platform_service_provider.h
Normal file
@ -0,0 +1,18 @@
|
||||
// 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_ANDROID_PLATFORM_SERVICE_PROVIDER_H_
|
||||
#define SKY_SHELL_ANDROID_PLATFORM_SERVICE_PROVIDER_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
bool RegisterPlatformServiceProvider(JNIEnv* env);
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_ANDROID_PLATFORM_SERVICE_PROVIDER_H_
|
||||
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "sky/shell/platform_view.h"
|
||||
#include "sky/shell/android/platform_view.h"
|
||||
|
||||
#include <android/input.h>
|
||||
#include <android/native_window_jni.h>
|
||||
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "sky/shell/sky_main.h"
|
||||
#include "sky/shell/android/sky_main.h"
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/android/jni_array.h"
|
||||
@ -18,6 +18,7 @@
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/simple_thread.h"
|
||||
#include "jni/SkyMain_jni.h"
|
||||
#include "sky/shell/service_provider.h"
|
||||
#include "sky/shell/shell.h"
|
||||
#include "ui/gl/gl_surface_egl.h"
|
||||
|
||||
@ -57,7 +58,8 @@ static void Init(JNIEnv* env, jclass clazz, jobject context) {
|
||||
base::i18n::InitializeICU();
|
||||
gfx::GLSurface::InitializeOneOff();
|
||||
|
||||
Shell::Init(g_java_message_loop.Get()->task_runner());
|
||||
Shell::Init(make_scoped_ptr(new ServiceProviderContext(
|
||||
g_java_message_loop.Get()->task_runner())));
|
||||
}
|
||||
|
||||
bool RegisterSkyMain(JNIEnv* env) {
|
||||
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "sky/shell/tracing_controller.h"
|
||||
#include "sky/shell/android/tracing_controller.h"
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/android/jni_string.h"
|
||||
@ -1,27 +0,0 @@
|
||||
// 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/java_service_provider.h"
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "jni/JavaServiceProvider_jni.h"
|
||||
#include "mojo/public/cpp/bindings/interface_request.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
bool RegisterJavaServiceProvider(JNIEnv* env) {
|
||||
return RegisterNativesImpl(env);
|
||||
}
|
||||
|
||||
void CreateJavaServiceProvider(
|
||||
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
|
||||
Java_JavaServiceProvider_create(
|
||||
base::android::AttachCurrentThread(),
|
||||
base::android::GetApplicationContext(),
|
||||
request.PassMessagePipe().release().value());
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
@ -1,21 +0,0 @@
|
||||
// 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_SERVICE_PROVIDER_IMPL_H_
|
||||
#define SKY_SHELL_SERVICE_PROVIDER_IMPL_H_
|
||||
|
||||
#include <jni.h>
|
||||
#include "mojo/public/cpp/system/core.h"
|
||||
#include "mojo/public/interfaces/application/service_provider.mojom.h"
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
bool RegisterJavaServiceProvider(JNIEnv* env);
|
||||
void CreateJavaServiceProvider(mojo::InterfaceRequest<mojo::ServiceProvider>);
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_SERVICE_PROVIDER_IMPL_H_
|
||||
36
shell/service_provider.h
Normal file
36
shell/service_provider.h
Normal file
@ -0,0 +1,36 @@
|
||||
// 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_SERVICE_PROVIDER_H_
|
||||
#define SKY_SHELL_SERVICE_PROVIDER_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "mojo/public/cpp/system/core.h"
|
||||
#include "mojo/public/interfaces/application/service_provider.mojom.h"
|
||||
|
||||
namespace base {
|
||||
class SingleThreadTaskRunner;
|
||||
}
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
|
||||
class ServiceProviderContext {
|
||||
public:
|
||||
#if defined(OS_ANDROID)
|
||||
ServiceProviderContext(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> runner)
|
||||
: java_task_runner(runner.Pass()) {}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Implemented in platform_service_provider.cc for each platform.
|
||||
mojo::ServiceProviderPtr CreateServiceProvider(ServiceProviderContext* context);
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
||||
#endif // SKY_SHELL_SERVICE_PROVIDER_H_
|
||||
@ -9,9 +9,9 @@
|
||||
#include "mojo/common/message_pump_mojo.h"
|
||||
#include "mojo/edk/embedder/embedder.h"
|
||||
#include "mojo/edk/embedder/simple_platform_support.h"
|
||||
#include "sky/shell/android/platform_service_provider.h"
|
||||
#include "sky/shell/android/platform_view.h"
|
||||
#include "sky/shell/gpu/rasterizer.h"
|
||||
#include "sky/shell/java_service_provider.h"
|
||||
#include "sky/shell/platform_view.h"
|
||||
#include "sky/shell/ui/engine.h"
|
||||
|
||||
namespace sky {
|
||||
@ -26,8 +26,8 @@ scoped_ptr<base::MessagePump> CreateMessagePumpMojo() {
|
||||
|
||||
} // namespace
|
||||
|
||||
Shell::Shell(scoped_refptr<base::SingleThreadTaskRunner> java_task_runner)
|
||||
: java_task_runner_(java_task_runner) {
|
||||
Shell::Shell(scoped_ptr<ServiceProviderContext> service_provider_context)
|
||||
: service_provider_context_(service_provider_context.Pass()) {
|
||||
DCHECK(!g_shell);
|
||||
mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
|
||||
new mojo::embedder::SimplePlatformSupport()));
|
||||
@ -43,8 +43,8 @@ Shell::Shell(scoped_refptr<base::SingleThreadTaskRunner> java_task_runner)
|
||||
Shell::~Shell() {
|
||||
}
|
||||
|
||||
void Shell::Init(scoped_refptr<base::SingleThreadTaskRunner> java_task_runner) {
|
||||
g_shell = new Shell(java_task_runner);
|
||||
void Shell::Init(scoped_ptr<ServiceProviderContext> service_provider_context) {
|
||||
g_shell = new Shell(service_provider_context.Pass());
|
||||
}
|
||||
|
||||
Shell& Shell::Shared() {
|
||||
@ -64,7 +64,7 @@ void Shell::InitUI(const base::Thread::Options& options) {
|
||||
ui_thread_->StartWithOptions(options);
|
||||
|
||||
Engine::Config config;
|
||||
config.java_task_runner = java_task_runner_;
|
||||
config.service_provider_context = service_provider_context_.get();
|
||||
config.gpu_task_runner = gpu_thread_->message_loop()->task_runner();
|
||||
config.gpu_delegate = rasterizer_->GetWeakPtr();
|
||||
engine_.reset(new Engine(config));
|
||||
|
||||
@ -10,34 +10,30 @@
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/threading/thread.h"
|
||||
|
||||
namespace base {
|
||||
class SingleThreadTaskRunner;
|
||||
}
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
class Engine;
|
||||
class Rasterizer;
|
||||
class PlatformView;
|
||||
class Rasterizer;
|
||||
class ServiceProviderContext;
|
||||
|
||||
class Shell {
|
||||
public:
|
||||
~Shell();
|
||||
|
||||
static void Init(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner);
|
||||
scoped_ptr<ServiceProviderContext> service_provider_context);
|
||||
static Shell& Shared();
|
||||
|
||||
PlatformView* view() const { return view_.get(); }
|
||||
|
||||
private:
|
||||
explicit Shell(scoped_refptr<base::SingleThreadTaskRunner> java_task_runner);
|
||||
explicit Shell(scoped_ptr<ServiceProviderContext> service_provider_context);
|
||||
|
||||
void InitGPU(const base::Thread::Options& options);
|
||||
void InitUI(const base::Thread::Options& options);
|
||||
void InitView();
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner_;
|
||||
scoped_ptr<base::Thread> gpu_thread_;
|
||||
scoped_ptr<base::Thread> ui_thread_;
|
||||
|
||||
@ -45,6 +41,8 @@ class Shell {
|
||||
scoped_ptr<Rasterizer> rasterizer_;
|
||||
scoped_ptr<Engine> engine_;
|
||||
|
||||
scoped_ptr<ServiceProviderContext> service_provider_context_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Shell);
|
||||
};
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "sky/engine/public/web/WebSettings.h"
|
||||
#include "sky/engine/public/web/WebView.h"
|
||||
#include "sky/services/platform/platform_impl.h"
|
||||
#include "sky/shell/java_service_provider.h"
|
||||
#include "sky/shell/service_provider.h"
|
||||
#include "sky/shell/ui/animator.h"
|
||||
#include "sky/shell/ui/input_event_converter.h"
|
||||
#include "sky/shell/ui/internals.h"
|
||||
@ -51,21 +51,10 @@ base::WeakPtr<Engine> Engine::GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
mojo::ServiceProviderPtr Engine::CreateServiceProvider() {
|
||||
mojo::MessagePipe pipe;
|
||||
config_.java_task_runner->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(CreateJavaServiceProvider,
|
||||
base::Passed(mojo::MakeRequest<mojo::ServiceProvider>(
|
||||
pipe.handle1.Pass()))));
|
||||
return mojo::MakeProxy(
|
||||
mojo::InterfacePtrInfo<mojo::ServiceProvider>(pipe.handle0.Pass(), 0u));
|
||||
}
|
||||
|
||||
void Engine::Init() {
|
||||
TRACE_EVENT0("sky", "Engine::Init");
|
||||
|
||||
service_provider_ = CreateServiceProvider();
|
||||
service_provider_ = CreateServiceProvider(config_.service_provider_context);
|
||||
mojo::NetworkServicePtr network_service;
|
||||
mojo::ConnectToService(service_provider_.get(), &network_service);
|
||||
platform_impl_.reset(new PlatformImpl(network_service.Pass()));
|
||||
@ -178,7 +167,8 @@ void Engine::scheduleVisualUpdate() {
|
||||
|
||||
void Engine::didCreateIsolate(blink::WebLocalFrame* frame,
|
||||
Dart_Isolate isolate) {
|
||||
Internals::Create(isolate, CreateServiceProvider());
|
||||
Internals::Create(isolate,
|
||||
CreateServiceProvider(config_.service_provider_context));
|
||||
}
|
||||
|
||||
blink::ServiceProvider* Engine::services() {
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "sky/engine/public/web/WebViewClient.h"
|
||||
#include "sky/shell/gpu_delegate.h"
|
||||
#include "sky/shell/ui_delegate.h"
|
||||
#include "sky/shell/service_provider.h"
|
||||
#include "third_party/skia/include/core/SkPicture.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
@ -35,7 +36,7 @@ class Engine : public UIDelegate,
|
||||
public blink::WebViewClient {
|
||||
public:
|
||||
struct Config {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner;
|
||||
ServiceProviderContext* service_provider_context;
|
||||
|
||||
base::WeakPtr<GPUDelegate> gpu_delegate;
|
||||
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner;
|
||||
@ -82,7 +83,6 @@ class Engine : public UIDelegate,
|
||||
void DidNavigateLocally(const mojo::String& url) override;
|
||||
void RequestNavigateHistory(int32_t delta) override;
|
||||
|
||||
mojo::ServiceProviderPtr CreateServiceProvider();
|
||||
void UpdateWebViewSize();
|
||||
|
||||
Config config_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user