Make PlatformViewport and NativeViewportImpl use Shell* instead of ApplicationImpl*.
Even Shell* probably isn't entirely ideal (since then you have to worry
about lifetime), but it'll do for now.
This will be needed to move the native viewport service away from using
ApplicationDelegate, etc.
R=vardhan@google.com
Review URL: https://codereview.chromium.org/2011053003 .
diff --git a/services/native_viewport/app_delegate.cc b/services/native_viewport/app_delegate.cc
index f1f53fc..e0aeda1 100644
--- a/services/native_viewport/app_delegate.cc
+++ b/services/native_viewport/app_delegate.cc
@@ -66,7 +66,7 @@
mojo::InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
if (!gpu_state_.get())
gpu_state_ = new gles2::GpuState();
- new NativeViewportImpl(application_, is_headless_, gpu_state_,
+ new NativeViewportImpl(application_->shell(), is_headless_, gpu_state_,
native_viewport_request.Pass());
});
diff --git a/services/native_viewport/native_viewport_impl.cc b/services/native_viewport/native_viewport_impl.cc
index 46961ba..9349647 100644
--- a/services/native_viewport/native_viewport_impl.cc
+++ b/services/native_viewport/native_viewport_impl.cc
@@ -11,7 +11,6 @@
#include "base/time/time.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/native_viewport/surface_configuration_type_converters.h"
-#include "mojo/public/cpp/application/application_impl.h"
#include "services/gles2/gpu_state.h"
#include "services/native_viewport/platform_viewport_headless.h"
#include "ui/events/event.h"
@@ -20,11 +19,11 @@
namespace native_viewport {
NativeViewportImpl::NativeViewportImpl(
- mojo::ApplicationImpl* application,
+ mojo::Shell* shell,
bool is_headless,
const scoped_refptr<gles2::GpuState>& gpu_state,
mojo::InterfaceRequest<mojo::NativeViewport> request)
- : application_(application),
+ : shell_(shell),
is_headless_(is_headless),
context_provider_(gpu_state),
sent_metrics_(false),
@@ -52,7 +51,7 @@
if (is_headless_)
platform_viewport_ = PlatformViewportHeadless::Create(this);
else
- platform_viewport_ = PlatformViewport::Create(application_, this);
+ platform_viewport_ = PlatformViewport::Create(shell_, this);
platform_viewport_->Init(gfx::Rect(size.To<gfx::Size>()));
}
diff --git a/services/native_viewport/native_viewport_impl.h b/services/native_viewport/native_viewport_impl.h
index bad5f2a..d1652db 100644
--- a/services/native_viewport/native_viewport_impl.h
+++ b/services/native_viewport/native_viewport_impl.h
@@ -21,7 +21,7 @@
}
namespace mojo {
-class ApplicationImpl;
+class Shell;
}
namespace ui {
@@ -37,7 +37,9 @@
class NativeViewportImpl : public mojo::NativeViewport,
public PlatformViewport::Delegate {
public:
- NativeViewportImpl(mojo::ApplicationImpl* application,
+ // TODO(vtl): Maybe this should take an
+ // |InterfaceHandle<ApplicationConnector>| instead of a |Shell*|.
+ NativeViewportImpl(mojo::Shell* shell,
bool is_headless,
const scoped_refptr<gles2::GpuState>& gpu_state,
mojo::InterfaceRequest<mojo::NativeViewport> request);
@@ -71,8 +73,8 @@
// with.
void AckEvent(int32 pointer_id);
- mojo::ApplicationImpl* application_;
- bool is_headless_;
+ mojo::Shell* const shell_;
+ const bool is_headless_;
scoped_ptr<PlatformViewport> platform_viewport_;
OnscreenContextProvider context_provider_;
bool sent_metrics_;
diff --git a/services/native_viewport/ozone/platform_viewport_ozone.cc b/services/native_viewport/ozone/platform_viewport_ozone.cc
index cbed659..03ca845 100644
--- a/services/native_viewport/ozone/platform_viewport_ozone.cc
+++ b/services/native_viewport/ozone/platform_viewport_ozone.cc
@@ -124,9 +124,8 @@
};
// static
-scoped_ptr<PlatformViewport> PlatformViewport::Create(
- mojo::ApplicationImpl* application_,
- Delegate* delegate) {
+scoped_ptr<PlatformViewport> PlatformViewport::Create(mojo::Shell* shell,
+ Delegate* delegate) {
return scoped_ptr<PlatformViewport>(new PlatformViewportOzone(delegate))
.Pass();
}
diff --git a/services/native_viewport/platform_viewport.h b/services/native_viewport/platform_viewport.h
index 5192654..4d23c73 100644
--- a/services/native_viewport/platform_viewport.h
+++ b/services/native_viewport/platform_viewport.h
@@ -16,7 +16,7 @@
}
namespace mojo {
-class ApplicationImpl;
+class Shell;
}
namespace native_viewport {
@@ -45,7 +45,9 @@
virtual gfx::Size GetSize() = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
- static scoped_ptr<PlatformViewport> Create(mojo::ApplicationImpl* application,
+ // TODO(vtl): Maybe this should take an
+ // |InterfaceHandle<ApplicationConnector>| instead of a |Shell*|.
+ static scoped_ptr<PlatformViewport> Create(mojo::Shell* shell,
Delegate* delegate);
};
diff --git a/services/native_viewport/platform_viewport_android.cc b/services/native_viewport/platform_viewport_android.cc
index 7ce2f34..625c8fa 100644
--- a/services/native_viewport/platform_viewport_android.cc
+++ b/services/native_viewport/platform_viewport_android.cc
@@ -12,7 +12,6 @@
#include "jni/PlatformViewportAndroid_jni.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/input_events/input_events_type_converters.h"
-#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/connect.h"
#include "services/native_viewport/native_viewport_support.mojom.h"
#include "ui/events/event.h"
@@ -55,10 +54,9 @@
return RegisterNativesImpl(env);
}
-PlatformViewportAndroid::PlatformViewportAndroid(
- mojo::ApplicationImpl* application,
- Delegate* delegate)
- : application_(application),
+PlatformViewportAndroid::PlatformViewportAndroid(mojo::Shell* shell,
+ Delegate* delegate)
+ : shell_(shell),
delegate_(delegate),
window_(NULL),
id_generator_(0),
@@ -167,7 +165,7 @@
Java_PlatformViewportAndroid_createRequest(env,
reinterpret_cast<intptr_t>(this));
- mojo::ConnectToService(application_->shell(), "mojo:native_viewport_support",
+ mojo::ConnectToService(shell_, "mojo:native_viewport_support",
GetProxy(&support_service_));
support_service_->CreateNewNativeWindow(
base::Bind(&PlatformViewportAndroid::Close, weak_factory_.GetWeakPtr()));
@@ -208,11 +206,10 @@
// PlatformViewport, public:
// static
-scoped_ptr<PlatformViewport> PlatformViewport::Create(
- mojo::ApplicationImpl* application_,
- Delegate* delegate) {
+scoped_ptr<PlatformViewport> PlatformViewport::Create(mojo::Shell* shell,
+ Delegate* delegate) {
return scoped_ptr<PlatformViewport>(
- new PlatformViewportAndroid(application_, delegate))
+ new PlatformViewportAndroid(shell, delegate))
.Pass();
}
diff --git a/services/native_viewport/platform_viewport_android.h b/services/native_viewport/platform_viewport_android.h
index 4a21c89..0f3d816 100644
--- a/services/native_viewport/platform_viewport_android.h
+++ b/services/native_viewport/platform_viewport_android.h
@@ -20,7 +20,7 @@
}
namespace mojo {
-class ApplicationImpl;
+class Shell;
}
struct ANativeWindow;
@@ -31,8 +31,7 @@
public:
static bool Register(JNIEnv* env);
- explicit PlatformViewportAndroid(mojo::ApplicationImpl* application,
- Delegate* delegate);
+ explicit PlatformViewportAndroid(mojo::Shell* shell, Delegate* delegate);
virtual ~PlatformViewportAndroid();
void Destroy(JNIEnv* env, jobject obj);
@@ -69,7 +68,7 @@
void ReleaseWindow();
- mojo::ApplicationImpl* application_;
+ mojo::Shell* const shell_;
NativeViewportSupportServicePtr support_service_;
Delegate* const delegate_;
JavaObjectWeakGlobalRef java_platform_viewport_android_;
diff --git a/services/native_viewport/platform_viewport_stub.cc b/services/native_viewport/platform_viewport_stub.cc
index 081074b..947d0b6 100644
--- a/services/native_viewport/platform_viewport_stub.cc
+++ b/services/native_viewport/platform_viewport_stub.cc
@@ -7,9 +7,8 @@
namespace mojo {
// static
-scoped_ptr<PlatformViewport> PlatformViewport::Create(
- mojo::ApplicationImpl* application_,
- Delegate* delegate) {
+scoped_ptr<PlatformViewport> PlatformViewport::Create(mojo::Shell* shell,
+ Delegate* delegate) {
return PlatformViewportHeadless::Create(delegate);
}
diff --git a/services/native_viewport/platform_viewport_x11.cc b/services/native_viewport/platform_viewport_x11.cc
index c77f413..46131eb 100644
--- a/services/native_viewport/platform_viewport_x11.cc
+++ b/services/native_viewport/platform_viewport_x11.cc
@@ -162,9 +162,8 @@
};
// static
-scoped_ptr<PlatformViewport> PlatformViewport::Create(
- mojo::ApplicationImpl* application_,
- Delegate* delegate) {
+scoped_ptr<PlatformViewport> PlatformViewport::Create(mojo::Shell* shell,
+ Delegate* delegate) {
return make_scoped_ptr(new PlatformViewportX11(delegate));
}
diff --git a/shell/android/native_viewport_application_loader.cc b/shell/android/native_viewport_application_loader.cc
index 35103c1..646b9df 100644
--- a/shell/android/native_viewport_application_loader.cc
+++ b/shell/android/native_viewport_application_loader.cc
@@ -33,8 +33,8 @@
InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
if (!gpu_state_)
gpu_state_ = new gles2::GpuState();
- new native_viewport::NativeViewportImpl(app_.get(), false, gpu_state_,
- native_viewport_request.Pass());
+ new native_viewport::NativeViewportImpl(
+ app_->shell(), false, gpu_state_, native_viewport_request.Pass());
});
service_provider_impl->AddService<mojo::Gpu>(
[this](const ConnectionContext& connection_context,