diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-22 10:39:40 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-22 10:39:40 +0000 |
commit | 61812b0dee52b2fe29c73e58c6c69edc1c1a9a77 (patch) | |
tree | 90ce8adbaca67fcbe9ebc89b531c064180bbd05f | |
parent | 1334c961aa59b9b60fce6380ce6ed4386d1d9445 (diff) | |
download | chromium_src-61812b0dee52b2fe29c73e58c6c69edc1c1a9a77.zip chromium_src-61812b0dee52b2fe29c73e58c6c69edc1c1a9a77.tar.gz chromium_src-61812b0dee52b2fe29c73e58c6c69edc1c1a9a77.tar.bz2 |
Break dependency of native_viewport_service on mojo::shell::Context
BUG=
Review URL: https://codereview.chromium.org/404913002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284660 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | mojo/services/native_viewport/native_viewport.h | 8 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_android.cc | 15 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_android.h | 4 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_mac.mm | 1 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_ozone.cc | 1 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_service.cc | 31 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_service.h | 9 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_stub.cc | 1 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_win.cc | 1 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_x11.cc | 1 | ||||
-rw-r--r-- | mojo/shell/android/mojo_main.cc | 1 | ||||
-rw-r--r-- | mojo/shell/context.cc | 9 | ||||
-rw-r--r-- | mojo/shell/context.h | 3 |
13 files changed, 31 insertions, 54 deletions
diff --git a/mojo/services/native_viewport/native_viewport.h b/mojo/services/native_viewport/native_viewport.h index d33f33f..ae2b061 100644 --- a/mojo/services/native_viewport/native_viewport.h +++ b/mojo/services/native_viewport/native_viewport.h @@ -19,10 +19,6 @@ class Event; } namespace mojo { -namespace shell { -class Context; -} - namespace services { class NativeViewportDelegate { @@ -52,9 +48,7 @@ class NativeViewport { virtual void SetCapture() = 0; virtual void ReleaseCapture() = 0; - // |context| is NULL when loaded into separate process. - static scoped_ptr<NativeViewport> Create(shell::Context* context, - NativeViewportDelegate* delegate); + static scoped_ptr<NativeViewport> Create(NativeViewportDelegate* delegate); }; } // namespace services diff --git a/mojo/services/native_viewport/native_viewport_android.cc b/mojo/services/native_viewport/native_viewport_android.cc index 1763f17..b9d9baa 100644 --- a/mojo/services/native_viewport/native_viewport_android.cc +++ b/mojo/services/native_viewport/native_viewport_android.cc @@ -9,7 +9,6 @@ #include "base/android/jni_android.h" #include "jni/NativeViewportAndroid_jni.h" -#include "mojo/shell/context.h" #include "ui/events/event.h" #include "ui/gfx/point.h" @@ -38,10 +37,8 @@ bool NativeViewportAndroid::Register(JNIEnv* env) { return RegisterNativesImpl(env); } -NativeViewportAndroid::NativeViewportAndroid(shell::Context* context, - NativeViewportDelegate* delegate) +NativeViewportAndroid::NativeViewportAndroid(NativeViewportDelegate* delegate) : delegate_(delegate), - context_(context), window_(NULL), id_generator_(0), weak_factory_(this) { @@ -103,8 +100,10 @@ bool NativeViewportAndroid::TouchEvent(JNIEnv* env, jobject obj, void NativeViewportAndroid::Init(const gfx::Rect& bounds) { JNIEnv* env = base::android::AttachCurrentThread(); - Java_NativeViewportAndroid_createForActivity(env, context_->activity(), - reinterpret_cast<jlong>(this)); + Java_NativeViewportAndroid_createForActivity( + env, + base::android::GetApplicationContext(), + reinterpret_cast<jlong>(this)); } void NativeViewportAndroid::Show() { @@ -151,10 +150,8 @@ void NativeViewportAndroid::ReleaseWindow() { // static scoped_ptr<NativeViewport> NativeViewport::Create( - shell::Context* context, NativeViewportDelegate* delegate) { - return scoped_ptr<NativeViewport>( - new NativeViewportAndroid(context, delegate)).Pass(); + return scoped_ptr<NativeViewport>(new NativeViewportAndroid(delegate)).Pass(); } } // namespace services diff --git a/mojo/services/native_viewport/native_viewport_android.h b/mojo/services/native_viewport/native_viewport_android.h index c24e38e..e9c86773 100644 --- a/mojo/services/native_viewport/native_viewport_android.h +++ b/mojo/services/native_viewport/native_viewport_android.h @@ -29,8 +29,7 @@ class MOJO_NATIVE_VIEWPORT_EXPORT NativeViewportAndroid public: static MOJO_NATIVE_VIEWPORT_EXPORT bool Register(JNIEnv* env); - explicit NativeViewportAndroid(shell::Context* context, - NativeViewportDelegate* delegate); + explicit NativeViewportAndroid(NativeViewportDelegate* delegate); virtual ~NativeViewportAndroid(); void Destroy(JNIEnv* env, jobject obj); @@ -54,7 +53,6 @@ class MOJO_NATIVE_VIEWPORT_EXPORT NativeViewportAndroid void ReleaseWindow(); NativeViewportDelegate* delegate_; - shell::Context* context_; ANativeWindow* window_; gfx::Rect bounds_; ui::SequentialIDGenerator id_generator_; diff --git a/mojo/services/native_viewport/native_viewport_mac.mm b/mojo/services/native_viewport/native_viewport_mac.mm index 9d7301f..4d4a55f 100644 --- a/mojo/services/native_viewport/native_viewport_mac.mm +++ b/mojo/services/native_viewport/native_viewport_mac.mm @@ -79,7 +79,6 @@ class NativeViewportMac : public NativeViewport { // static scoped_ptr<NativeViewport> NativeViewport::Create( - shell::Context* context, NativeViewportDelegate* delegate) { return scoped_ptr<NativeViewport>(new NativeViewportMac(delegate)).Pass(); } diff --git a/mojo/services/native_viewport/native_viewport_ozone.cc b/mojo/services/native_viewport/native_viewport_ozone.cc index 31e02fe..4b62b96 100644 --- a/mojo/services/native_viewport/native_viewport_ozone.cc +++ b/mojo/services/native_viewport/native_viewport_ozone.cc @@ -89,7 +89,6 @@ class NativeViewportOzone : public NativeViewport, // static scoped_ptr<NativeViewport> NativeViewport::Create( - shell::Context* context, NativeViewportDelegate* delegate) { return scoped_ptr<NativeViewport>(new NativeViewportOzone(delegate)).Pass(); } diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc index 203ec10..bcde3aa 100644 --- a/mojo/services/native_viewport/native_viewport_service.cc +++ b/mojo/services/native_viewport/native_viewport_service.cc @@ -33,10 +33,8 @@ class NativeViewportImpl : public InterfaceImpl<mojo::NativeViewport>, public NativeViewportDelegate { public: - NativeViewportImpl(ApplicationConnection* connection, - shell::Context* context) - : context_(context), - widget_(gfx::kNullAcceleratedWidget), + explicit NativeViewportImpl(ApplicationConnection* connection) + : widget_(gfx::kNullAcceleratedWidget), waiting_for_event_ack_(false), weak_factory_(this) {} virtual ~NativeViewportImpl() { @@ -46,8 +44,7 @@ class NativeViewportImpl } virtual void Create(RectPtr bounds) OVERRIDE { - native_viewport_ = - services::NativeViewport::Create(context_, this); + native_viewport_ = services::NativeViewport::Create(this); native_viewport_->Init(bounds.To<gfx::Rect>()); client()->OnCreated(); OnBoundsChanged(bounds.To<gfx::Rect>()); @@ -146,7 +143,6 @@ class NativeViewportImpl command_buffer_.reset(); } - shell::Context* context_; gfx::AcceleratedWidget widget_; scoped_ptr<services::NativeViewport> native_viewport_; InterfaceRequest<CommandBuffer> command_buffer_request_; @@ -157,27 +153,24 @@ class NativeViewportImpl class NVSDelegate : public ApplicationDelegate { public: - NVSDelegate(shell::Context* context) : context_(context) {} + NVSDelegate() {} virtual ~NVSDelegate() {} virtual bool ConfigureIncomingConnection( mojo::ApplicationConnection* connection) MOJO_OVERRIDE { - connection->AddService<NativeViewportImpl>(context_); + connection->AddService<NativeViewportImpl>(); return true; } - - private: - mojo::shell::Context* context_; }; -} // namespace services -} // namespace mojo - MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* CreateNativeViewportService( - mojo::shell::Context* context, - mojo::ScopedMessagePipeHandle service_provider_handle) { - mojo::ApplicationImpl* app = new mojo::ApplicationImpl( - new mojo::services::NVSDelegate(context), service_provider_handle.Pass()); + ScopedMessagePipeHandle service_provider_handle) { + ApplicationImpl* app = new ApplicationImpl( + new NVSDelegate(), service_provider_handle.Pass()); return app; } + +} // namespace services +} // namespace mojo + diff --git a/mojo/services/native_viewport/native_viewport_service.h b/mojo/services/native_viewport/native_viewport_service.h index 1e6cde8..7613011 100644 --- a/mojo/services/native_viewport/native_viewport_service.h +++ b/mojo/services/native_viewport/native_viewport_service.h @@ -10,9 +10,14 @@ #include "mojo/services/native_viewport/native_viewport_export.h" #include "mojo/shell/context.h" +namespace mojo { +namespace services { + MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* CreateNativeViewportService( - mojo::shell::Context* context, - mojo::ScopedMessagePipeHandle service_provider_handle); + ScopedMessagePipeHandle service_provider_handle); + +} // namespace services +} // namespace mojo #endif // MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ diff --git a/mojo/services/native_viewport/native_viewport_stub.cc b/mojo/services/native_viewport/native_viewport_stub.cc index 9dcb33a..f685c0b 100644 --- a/mojo/services/native_viewport/native_viewport_stub.cc +++ b/mojo/services/native_viewport/native_viewport_stub.cc @@ -41,7 +41,6 @@ class NativeViewportStub : public NativeViewport { // static scoped_ptr<NativeViewport> NativeViewport::Create( - shell::Context* context, NativeViewportDelegate* delegate) { return scoped_ptr<NativeViewport>(new NativeViewportStub(delegate)).Pass(); } diff --git a/mojo/services/native_viewport/native_viewport_win.cc b/mojo/services/native_viewport/native_viewport_win.cc index bf1bb33..43e9ca6 100644 --- a/mojo/services/native_viewport/native_viewport_win.cc +++ b/mojo/services/native_viewport/native_viewport_win.cc @@ -161,7 +161,6 @@ class NativeViewportWin : public gfx::WindowImpl, // static scoped_ptr<NativeViewport> NativeViewport::Create( - shell::Context* context, NativeViewportDelegate* delegate) { return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass(); } diff --git a/mojo/services/native_viewport/native_viewport_x11.cc b/mojo/services/native_viewport/native_viewport_x11.cc index 16a9ae3..35c9c3b 100644 --- a/mojo/services/native_viewport/native_viewport_x11.cc +++ b/mojo/services/native_viewport/native_viewport_x11.cc @@ -112,7 +112,6 @@ class NativeViewportX11 : public NativeViewport, // static scoped_ptr<NativeViewport> NativeViewport::Create( - shell::Context* context, NativeViewportDelegate* delegate) { return scoped_ptr<NativeViewport>(new NativeViewportX11(delegate)).Pass(); } diff --git a/mojo/shell/android/mojo_main.cc b/mojo/shell/android/mojo_main.cc index 4848ad9..a892317 100644 --- a/mojo/shell/android/mojo_main.cc +++ b/mojo/shell/android/mojo_main.cc @@ -38,7 +38,6 @@ LazyInstance<scoped_ptr<base::android::JavaHandlerThread> > g_shell_thread = void RunShell(std::vector<GURL> app_urls) { shell::Context* shell_context = new shell::Context(); - shell_context->set_activity(base::android::GetApplicationContext()); shell_context->set_ui_loop(g_java_message_loop.Get().get()); g_context.Get().reset(shell_context); diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc index 0eba764..7400d1c 100644 --- a/mojo/shell/context.cc +++ b/mojo/shell/context.cc @@ -65,21 +65,20 @@ static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER; class Context::NativeViewportServiceLoader : public ServiceLoader { public: - explicit NativeViewportServiceLoader(Context* context) : context_(context) {} + NativeViewportServiceLoader() {} virtual ~NativeViewportServiceLoader() {} private: virtual void LoadService(ServiceManager* manager, const GURL& url, ScopedMessagePipeHandle shell_handle) OVERRIDE { - app_.reset(::CreateNativeViewportService(context_, shell_handle.Pass())); + app_.reset(services::CreateNativeViewportService(shell_handle.Pass())); } virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE { } - Context* context_; scoped_ptr<ApplicationImpl> app_; DISALLOW_COPY_AND_ASSIGN(NativeViewportServiceLoader); }; @@ -108,14 +107,14 @@ Context::Context() service_manager_.SetLoaderForURL( scoped_ptr<ServiceLoader>( new UIServiceLoader( - scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader(this)), + scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader()), this)), GURL("mojo:mojo_native_viewport_service")); #else service_manager_.SetLoaderForURL( scoped_ptr<ServiceLoader>( new BackgroundServiceLoader( - scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader(this)), + scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader()), "native_viewport", base::MessageLoop::TYPE_UI)), GURL("mojo:mojo_native_viewport_service")); diff --git a/mojo/shell/context.h b/mojo/shell/context.h index 2173377..f8970a5 100644 --- a/mojo/shell/context.h +++ b/mojo/shell/context.h @@ -36,8 +36,6 @@ class Context { MojoURLResolver* mojo_url_resolver() { return &mojo_url_resolver_; } #if defined(OS_ANDROID) - jobject activity() const { return activity_.obj(); } - void set_activity(jobject activity) { activity_.Reset(NULL, activity); } base::MessageLoop* ui_loop() const { return ui_loop_; } void set_ui_loop(base::MessageLoop* ui_loop) { ui_loop_ = ui_loop; } #endif // defined(OS_ANDROID) @@ -50,7 +48,6 @@ class Context { MojoURLResolver mojo_url_resolver_; scoped_ptr<Spy> spy_; #if defined(OS_ANDROID) - base::android::ScopedJavaGlobalRef<jobject> activity_; base::MessageLoop* ui_loop_; #endif // defined(OS_ANDROID) |