Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: sky/shell/android/platform_view_android.cc

Issue 1187503003: Refactor SkyShell to allow multiple SkyViews (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: s/instance/sky_shell/ Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/shell/android/platform_view_android.h ('k') | sky/shell/ios/platform_view_ios.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7b47d40d6260c3b750df77177ff0ffed15009fed 100644
--- a/sky/shell/android/platform_view_android.cc
+++ b/sky/shell/android/platform_view_android.cc
@@ -12,16 +12,19 @@
#include "base/location.h"
#include "jni/PlatformViewAndroid_jni.h"
#include "sky/shell/shell.h"
+#include "sky/shell/shell_view.h"
namespace sky {
namespace shell {
static jlong Attach(JNIEnv* env, jclass clazz, jint viewportObserverHandle) {
- PlatformView* view = Shell::Shared().view();
+ ShellView* shell_view = new ShellView(Shell::Shared());
+ auto view = static_cast<PlatformViewAndroid*>(shell_view->view());
+ view->SetShellView(make_scoped_ptr(shell_view));
view->ConnectToViewportObserver(
mojo::MakeRequest<ViewportObserver>(mojo::ScopedMessagePipeHandle(
mojo::MessagePipeHandle(viewportObserverHandle))));
- return reinterpret_cast<jlong>(view);
+ return reinterpret_cast<jlong>(shell_view->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_);
+ shell_view_.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::SetShellView(scoped_ptr<ShellView> shell_view) {
+ DCHECK(!shell_view_);
+ shell_view_ = shell_view.Pass();
+}
+
void PlatformViewAndroid::ReleaseWindow() {
ANativeWindow_release(window_);
window_ = nullptr;
« no previous file with comments | « sky/shell/android/platform_view_android.h ('k') | sky/shell/ios/platform_view_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698