| Index: sky/shell/android/platform_view_android.cc
|
| diff --git a/sky/shell/android/platform_view_android.cc b/sky/shell/android/platform_view_android.cc
|
| index a27246743eec20c8bc7d562f87de0e208ce1a056..8696f28b7fd480bbf20e6040ece5e098e64c3f7d 100644
|
| --- a/sky/shell/android/platform_view_android.cc
|
| +++ b/sky/shell/android/platform_view_android.cc
|
| @@ -11,17 +11,20 @@
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| #include "jni/PlatformViewAndroid_jni.h"
|
| +#include "sky/shell/instance.h"
|
| #include "sky/shell/shell.h"
|
|
|
| namespace sky {
|
| namespace shell {
|
|
|
| static jlong Attach(JNIEnv* env, jclass clazz, jint viewportObserverHandle) {
|
| - PlatformView* view = Shell::Shared().view();
|
| + Instance* instance = new Instance(Shell::Shared());
|
| + auto view = static_cast<PlatformViewAndroid*>(instance->view());
|
| + view->SetInstance(make_scoped_ptr(instance));
|
| view->ConnectToViewportObserver(
|
| mojo::MakeRequest<ViewportObserver>(mojo::ScopedMessagePipeHandle(
|
| mojo::MessagePipeHandle(viewportObserverHandle))));
|
| - return reinterpret_cast<jlong>(view);
|
| + return reinterpret_cast<jlong>(instance->view());
|
| }
|
|
|
| // static
|
| @@ -29,6 +32,14 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
|
| return RegisterNativesImpl(env);
|
| }
|
|
|
| +PlatformView* PlatformView::Create(const Config& config) {
|
| + return new PlatformViewAndroid(config);
|
| +}
|
| +
|
| +PlatformViewAndroid::PlatformViewAndroid(const Config& config)
|
| + : PlatformView(config) {
|
| +}
|
| +
|
| PlatformViewAndroid::~PlatformViewAndroid() {
|
| if (window_)
|
| ReleaseWindow();
|
| @@ -36,6 +47,8 @@ PlatformViewAndroid::~PlatformViewAndroid() {
|
|
|
| void PlatformViewAndroid::Detach(JNIEnv* env, jobject obj) {
|
| DCHECK(!window_);
|
| + instance_.reset();
|
| + // Note: |this| has been destroyed at this point.
|
| }
|
|
|
| void PlatformViewAndroid::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
|
| @@ -56,6 +69,11 @@ void PlatformViewAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) {
|
| ReleaseWindow();
|
| }
|
|
|
| +void PlatformViewAndroid::SetInstance(scoped_ptr<Instance> instance) {
|
| + DCHECK(!instance_);
|
| + instance_ = instance.Pass();
|
| +}
|
| +
|
| void PlatformViewAndroid::ReleaseWindow() {
|
| ANativeWindow_release(window_);
|
| window_ = nullptr;
|
|
|