From 4bf5740ebbca20827ce9d68e251d051cda2ef44e Mon Sep 17 00:00:00 2001 From: "davemoore@chromium.org" Date: Fri, 15 Aug 2014 14:48:12 +0000 Subject: [PATCH] Turn mojo_native_viewport_service from component into a static_library. This is in preparation for creating a true mojo application out of it on platforms other than Android which will require static linking for a while longer. This will help us make mojo_shell smaller. BUG= Review URL: https://codereview.chromium.org/475183002 Cr-Commit-Position: refs/heads/master@{#289853} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289853 0039d316-1c4b-4281-b951-d872f2087c98 --- mojo/mojo.gyp | 4 +- mojo/mojo_services.gypi | 21 +-- mojo/services/gles2/command_buffer_impl.cc | 2 - mojo/services/gles2/command_buffer_impl.h | 2 - mojo/services/native_viewport/BUILD.gn | 9 +- .../org/chromium/mojo/PlatformViewportAndroid.java | 2 +- .../native_viewport/native_viewport_export.h | 32 ---- .../native_viewport/native_viewport_impl.cc | 138 ++++++++++++++++ .../native_viewport/native_viewport_impl.h | 57 +++++++ .../native_viewport/native_viewport_service.cc | 183 --------------------- .../native_viewport/native_viewport_service.h | 23 --- mojo/services/native_viewport/platform_viewport.h | 3 - .../native_viewport/platform_viewport_android.cc | 2 - .../native_viewport/platform_viewport_android.h | 8 +- .../native_viewport/platform_viewport_mac.mm | 2 - .../native_viewport/platform_viewport_ozone.cc | 2 - .../native_viewport/platform_viewport_stub.cc | 2 - .../native_viewport/platform_viewport_win.cc | 2 - .../native_viewport/platform_viewport_x11.cc | 2 - mojo/shell/android/library_loader.cc | 2 +- mojo/shell/context.cc | 25 ++- 21 files changed, 235 insertions(+), 288 deletions(-) delete mode 100644 mojo/services/native_viewport/native_viewport_export.h create mode 100644 mojo/services/native_viewport/native_viewport_impl.cc create mode 100644 mojo/services/native_viewport/native_viewport_impl.h delete mode 100644 mojo/services/native_viewport/native_viewport_service.cc delete mode 100644 mojo/services/native_viewport/native_viewport_service.h diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index 4ba177075f4c..69678c5772f6 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -38,7 +38,7 @@ 'mojo_html_viewer', 'mojo_js', 'mojo_launcher', - 'mojo_native_viewport_service', + 'mojo_native_viewport_service_lib', 'mojo_network_service', 'mojo_pepper_container_app', 'mojo_png_viewer', @@ -145,7 +145,7 @@ 'mojo_base.gyp:mojo_system_impl', 'mojo_base.gyp:mojo_application_chromium', 'mojo_external_service_bindings', - 'mojo_native_viewport_service', + 'mojo_native_viewport_service_lib', 'mojo_network_bindings', 'mojo_spy', ], diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index 5f73a4202e58..5bd127e32144 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -236,9 +236,10 @@ }, { # GN version: //mojo/services/native_viewport - 'target_name': 'mojo_native_viewport_service', - # This is linked directly into the embedder, so we make it a component. - 'type': '<(component)', + 'target_name': 'mojo_native_viewport_service_lib', + # This is linked directly into the embedder, so we make it a static_library. + # TODO(davemoore): Make this a true service. + 'type': 'static_library', 'dependencies': [ '../base/base.gyp:base', '../ui/events/events.gyp:events', @@ -252,15 +253,10 @@ 'mojo_gles2_service', 'mojo_input_events_lib', 'mojo_native_viewport_bindings', - '<(mojo_system_for_component)', - ], - 'defines': [ - 'MOJO_NATIVE_VIEWPORT_IMPLEMENTATION', ], 'sources': [ - 'services/native_viewport/native_viewport_export.h', - 'services/native_viewport/native_viewport_service.cc', - 'services/native_viewport/native_viewport_service.h', + 'services/native_viewport/native_viewport_impl.cc', + 'services/native_viewport/native_viewport_impl.h', 'services/native_viewport/platform_viewport.h', 'services/native_viewport/platform_viewport_android.cc', 'services/native_viewport/platform_viewport_mac.mm', @@ -288,6 +284,7 @@ ['use_x11==1', { 'dependencies': [ '../ui/platform_window/x11/x11_window.gyp:x11_window', + '../ui/events/platform/x11/x11_events_platform.gyp:x11_events_platform', ], }], ], @@ -727,7 +724,7 @@ ['OS=="linux"', { 'dependencies': [ '../third_party/mesa/mesa.gyp:osmesa', - 'mojo_native_viewport_service', + 'mojo_native_viewport_service_lib', ], }], ['use_x11==1', { @@ -832,7 +829,7 @@ ['OS=="linux"', { 'dependencies': [ '../third_party/mesa/mesa.gyp:osmesa', - 'mojo_native_viewport_service', + 'mojo_native_viewport_service_lib', ], }], ['use_x11==1', { diff --git a/mojo/services/gles2/command_buffer_impl.cc b/mojo/services/gles2/command_buffer_impl.cc index 8674f121b236..d3b9137f40fb 100644 --- a/mojo/services/gles2/command_buffer_impl.cc +++ b/mojo/services/gles2/command_buffer_impl.cc @@ -21,7 +21,6 @@ #include "ui/gl/gl_surface.h" namespace mojo { -namespace services { namespace { @@ -179,5 +178,4 @@ void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { surface_->Resize(size); } -} // namespace services } // namespace mojo diff --git a/mojo/services/gles2/command_buffer_impl.h b/mojo/services/gles2/command_buffer_impl.h index fc79c5f0d4c2..fc90d348aa9e 100644 --- a/mojo/services/gles2/command_buffer_impl.h +++ b/mojo/services/gles2/command_buffer_impl.h @@ -26,7 +26,6 @@ class GLSurface; } namespace mojo { -namespace services { class CommandBufferImpl : public InterfaceImpl { public: @@ -65,7 +64,6 @@ class CommandBufferImpl : public InterfaceImpl { DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); }; -} // namespace services } // namespace mojo #endif // MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ diff --git a/mojo/services/native_viewport/BUILD.gn b/mojo/services/native_viewport/BUILD.gn index 480ea6780446..b1089d1ccd6c 100644 --- a/mojo/services/native_viewport/BUILD.gn +++ b/mojo/services/native_viewport/BUILD.gn @@ -5,7 +5,7 @@ import("//build/config/ui.gni") import("//mojo/system.gni") -component("native_viewport") { +static_library("native_viewport") { output_name = "mojo_native_viewport" deps = [ @@ -22,13 +22,10 @@ component("native_viewport") { "//mojo/services/public/cpp/input_events", "//mojo/services/public/interfaces/native_viewport", ] - deps += mojo_system_for_component - - defines = [ "MOJO_NATIVE_VIEWPORT_IMPLEMENTATION" ] sources = [ - "native_viewport_service.cc", - "native_viewport_service.h", + "native_viewport_impl.cc", + "native_viewport_impl.h", "platform_viewport.h", "platform_viewport_android.cc", "platform_viewport_android.h", diff --git a/mojo/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java b/mojo/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java index 8aa452f886c2..c3f8075ceef8 100644 --- a/mojo/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java +++ b/mojo/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java @@ -17,7 +17,7 @@ import org.chromium.base.JNINamespace; /** * Exposes SurfaceView to native code. */ -@JNINamespace("mojo::services") +@JNINamespace("mojo") public class PlatformViewportAndroid extends SurfaceView { private long mNativeMojoViewport; diff --git a/mojo/services/native_viewport/native_viewport_export.h b/mojo/services/native_viewport/native_viewport_export.h deleted file mode 100644 index 4870c566f9d9..000000000000 --- a/mojo/services/native_viewport/native_viewport_export.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 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 MOJO_SERVICES_NATIVE_VIEWPORT_EXPORT_H_ -#define MOJO_SERVICES_NATIVE_VIEWPORT_EXPORT_H_ - -#if defined(COMPONENT_BUILD) - -#if defined(WIN32) - -#if defined(MOJO_NATIVE_VIEWPORT_IMPLEMENTATION) -#define MOJO_NATIVE_VIEWPORT_EXPORT __declspec(dllexport) -#else -#define MOJO_NATIVE_VIEWPORT_EXPORT __declspec(dllimport) -#endif - -#else // !defined(WIN32) - -#if defined(MOJO_NATIVE_VIEWPORT_IMPLEMENTATION) -#define MOJO_NATIVE_VIEWPORT_EXPORT __attribute__((visibility("default"))) -#else -#define MOJO_NATIVE_VIEWPORT_EXPORT -#endif - -#endif // defined(WIN32) - -#else // !defined(COMPONENT_BUILD) -#define MOJO_NATIVE_VIEWPORT_EXPORT -#endif - -#endif // MOJO_SERVICES_NATIVE_VIEWPORT_EXPORT_H_ diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc new file mode 100644 index 000000000000..8755dfd1c74b --- /dev/null +++ b/mojo/services/native_viewport/native_viewport_impl.cc @@ -0,0 +1,138 @@ +// Copyright 2014 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 "mojo/services/native_viewport/native_viewport_impl.h" + +#include "base/macros.h" +#include "base/message_loop/message_loop.h" +#include "base/time/time.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/interface_factory.h" +#include "mojo/services/public/cpp/geometry/geometry_type_converters.h" +#include "mojo/services/public/cpp/input_events/input_events_type_converters.h" +#include "ui/events/event.h" + +namespace mojo { +namespace { + +bool IsRateLimitedEventType(ui::Event* event) { + return event->type() == ui::ET_MOUSE_MOVED || + event->type() == ui::ET_MOUSE_DRAGGED || + event->type() == ui::ET_TOUCH_MOVED; +} + +} // namespace + +NativeViewportImpl::NativeViewportImpl() + : widget_(gfx::kNullAcceleratedWidget), + waiting_for_event_ack_(false), + weak_factory_(this) {} + +NativeViewportImpl::~NativeViewportImpl() { + // Destroy the NativeViewport early on as it may call us back during + // destruction and we want to be in a known state. + platform_viewport_.reset(); +} + +void NativeViewportImpl::Create(RectPtr bounds) { + platform_viewport_ = PlatformViewport::Create(this); + platform_viewport_->Init(bounds.To()); + client()->OnCreated(); + OnBoundsChanged(bounds.To()); +} + +void NativeViewportImpl::Show() { + platform_viewport_->Show(); +} + +void NativeViewportImpl::Hide() { + platform_viewport_->Hide(); +} + +void NativeViewportImpl::Close() { + command_buffer_.reset(); + DCHECK(platform_viewport_); + platform_viewport_->Close(); +} + +void NativeViewportImpl::SetBounds(RectPtr bounds) { + platform_viewport_->SetBounds(bounds.To()); +} + +void NativeViewportImpl::CreateGLES2Context( + InterfaceRequest command_buffer_request) { + if (command_buffer_ || command_buffer_request_.is_pending()) { + LOG(ERROR) << "Can't create multiple contexts on a NativeViewport"; + return; + } + command_buffer_request_ = command_buffer_request.Pass(); + CreateCommandBufferIfNeeded(); +} + +void NativeViewportImpl::OnBoundsChanged(const gfx::Rect& bounds) { + CreateCommandBufferIfNeeded(); + client()->OnBoundsChanged(Rect::From(bounds)); +} + +void NativeViewportImpl::OnAcceleratedWidgetAvailable( + gfx::AcceleratedWidget widget) { + widget_ = widget; + CreateCommandBufferIfNeeded(); +} + +bool NativeViewportImpl::OnEvent(ui::Event* ui_event) { + // Must not return early before updating capture. + switch (ui_event->type()) { + case ui::ET_MOUSE_PRESSED: + case ui::ET_TOUCH_PRESSED: + platform_viewport_->SetCapture(); + break; + case ui::ET_MOUSE_RELEASED: + case ui::ET_TOUCH_RELEASED: + platform_viewport_->ReleaseCapture(); + break; + default: + break; + } + + if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event)) + return false; + + client()->OnEvent( + TypeConverter::ConvertFrom(*ui_event), + base::Bind(&NativeViewportImpl::AckEvent, + weak_factory_.GetWeakPtr())); + waiting_for_event_ack_ = true; + return false; +} + +void NativeViewportImpl::OnDestroyed() { + client()->OnDestroyed(base::Bind(&NativeViewportImpl::AckDestroyed, + base::Unretained(this))); +} + +void NativeViewportImpl::AckEvent() { + waiting_for_event_ack_ = false; +} + +void NativeViewportImpl::CreateCommandBufferIfNeeded() { + if (!command_buffer_request_.is_pending()) + return; + DCHECK(!command_buffer_.get()); + if (widget_ == gfx::kNullAcceleratedWidget) + return; + gfx::Size size = platform_viewport_->GetSize(); + if (size.IsEmpty()) + return; + command_buffer_.reset( + new CommandBufferImpl(widget_, platform_viewport_->GetSize())); + WeakBindToRequest(command_buffer_.get(), &command_buffer_request_); +} + +void NativeViewportImpl::AckDestroyed() { + command_buffer_.reset(); +} + +} // namespace mojo + diff --git a/mojo/services/native_viewport/native_viewport_impl.h b/mojo/services/native_viewport/native_viewport_impl.h new file mode 100644 index 000000000000..5d26da582511 --- /dev/null +++ b/mojo/services/native_viewport/native_viewport_impl.h @@ -0,0 +1,57 @@ +// Copyright 2014 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 MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_ +#define MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_ + +#include "base/memory/weak_ptr.h" +#include "mojo/services/gles2/command_buffer_impl.h" +#include "mojo/services/native_viewport/platform_viewport.h" +#include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" + +namespace ui { +class Event; +} + +namespace mojo { + +class NativeViewportImpl : public InterfaceImpl, + public PlatformViewport::Delegate { + public: + NativeViewportImpl(); + virtual ~NativeViewportImpl(); + + // InterfaceImpl implementation. + virtual void Create(RectPtr bounds) OVERRIDE; + virtual void Show() OVERRIDE; + virtual void Hide() OVERRIDE; + virtual void Close() OVERRIDE; + virtual void SetBounds(RectPtr bounds) OVERRIDE; + virtual void CreateGLES2Context( + InterfaceRequest command_buffer_request) OVERRIDE; + + // PlatformViewport::Delegate implementation. + virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE; + virtual void OnAcceleratedWidgetAvailable( + gfx::AcceleratedWidget widget) OVERRIDE; + virtual bool OnEvent(ui::Event* ui_event) OVERRIDE; + virtual void OnDestroyed() OVERRIDE; + + void AckEvent(); + void CreateCommandBufferIfNeeded(); + + private: + void AckDestroyed(); + + gfx::AcceleratedWidget widget_; + scoped_ptr platform_viewport_; + InterfaceRequest command_buffer_request_; + scoped_ptr command_buffer_; + bool waiting_for_event_ack_; + base::WeakPtrFactory weak_factory_; +}; + +} // namespace mojo + +#endif // MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_ diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc deleted file mode 100644 index 9bdc51ee9fbd..000000000000 --- a/mojo/services/native_viewport/native_viewport_service.cc +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2013 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 "mojo/services/native_viewport/native_viewport_service.h" - -#include "base/macros.h" -#include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/time/time.h" -#include "mojo/public/cpp/application/application_delegate.h" -#include "mojo/public/cpp/application/interface_factory.h" -#include "mojo/services/gles2/command_buffer_impl.h" -#include "mojo/services/native_viewport/platform_viewport.h" -#include "mojo/services/public/cpp/geometry/geometry_type_converters.h" -#include "mojo/services/public/cpp/input_events/input_events_type_converters.h" -#include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" -#include "ui/events/event.h" - -namespace mojo { -namespace services { -namespace { - -bool IsRateLimitedEventType(ui::Event* event) { - return event->type() == ui::ET_MOUSE_MOVED || - event->type() == ui::ET_MOUSE_DRAGGED || - event->type() == ui::ET_TOUCH_MOVED; -} - -} // namespace - -class NativeViewportImpl : public InterfaceImpl, - public PlatformViewport::Delegate { - public: - NativeViewportImpl() - : widget_(gfx::kNullAcceleratedWidget), - waiting_for_event_ack_(false), - weak_factory_(this) {} - virtual ~NativeViewportImpl() { - // Destroy the NativeViewport early on as it may call us back during - // destruction and we want to be in a known state. - platform_viewport_.reset(); - } - - virtual void Create(RectPtr bounds) OVERRIDE { - platform_viewport_ = PlatformViewport::Create(this); - platform_viewport_->Init(bounds.To()); - client()->OnCreated(); - OnBoundsChanged(bounds.To()); - } - - virtual void Show() OVERRIDE { - platform_viewport_->Show(); - } - - virtual void Hide() OVERRIDE { - platform_viewport_->Hide(); - } - - virtual void Close() OVERRIDE { - command_buffer_.reset(); - DCHECK(platform_viewport_); - platform_viewport_->Close(); - } - - virtual void SetBounds(RectPtr bounds) OVERRIDE { - platform_viewport_->SetBounds(bounds.To()); - } - - virtual void CreateGLES2Context( - InterfaceRequest command_buffer_request) OVERRIDE { - if (command_buffer_ || command_buffer_request_.is_pending()) { - LOG(ERROR) << "Can't create multiple contexts on a NativeViewport"; - return; - } - command_buffer_request_ = command_buffer_request.Pass(); - CreateCommandBufferIfNeeded(); - } - - void AckEvent() { - waiting_for_event_ack_ = false; - } - - void CreateCommandBufferIfNeeded() { - if (!command_buffer_request_.is_pending()) - return; - DCHECK(!command_buffer_.get()); - if (widget_ == gfx::kNullAcceleratedWidget) - return; - gfx::Size size = platform_viewport_->GetSize(); - if (size.IsEmpty()) - return; - command_buffer_.reset( - new CommandBufferImpl(widget_, platform_viewport_->GetSize())); - WeakBindToRequest(command_buffer_.get(), &command_buffer_request_); - } - - virtual bool OnEvent(ui::Event* ui_event) OVERRIDE { - // Must not return early before updating capture. - switch (ui_event->type()) { - case ui::ET_MOUSE_PRESSED: - case ui::ET_TOUCH_PRESSED: - platform_viewport_->SetCapture(); - break; - case ui::ET_MOUSE_RELEASED: - case ui::ET_TOUCH_RELEASED: - platform_viewport_->ReleaseCapture(); - break; - default: - break; - } - - if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event)) - return false; - - client()->OnEvent( - TypeConverter::ConvertFrom(*ui_event), - base::Bind(&NativeViewportImpl::AckEvent, - weak_factory_.GetWeakPtr())); - waiting_for_event_ack_ = true; - return false; - } - - virtual void OnAcceleratedWidgetAvailable( - gfx::AcceleratedWidget widget) OVERRIDE { - widget_ = widget; - CreateCommandBufferIfNeeded(); - } - - virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE { - CreateCommandBufferIfNeeded(); - client()->OnBoundsChanged(Rect::From(bounds)); - } - - virtual void OnDestroyed() OVERRIDE { - client()->OnDestroyed(base::Bind(&NativeViewportImpl::AckDestroyed, - base::Unretained(this))); - } - - private: - void AckDestroyed() { - command_buffer_.reset(); - } - - gfx::AcceleratedWidget widget_; - scoped_ptr platform_viewport_; - InterfaceRequest command_buffer_request_; - scoped_ptr command_buffer_; - bool waiting_for_event_ack_; - base::WeakPtrFactory weak_factory_; -}; - -class NVSDelegate : public ApplicationDelegate, - public InterfaceFactory { - public: - NVSDelegate() {} - virtual ~NVSDelegate() {} - - // ApplicationDelegate implementation. - virtual bool ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) OVERRIDE { - connection->AddService(this); - return true; - } - - // ServiceFactory implementation. - virtual void Create(ApplicationConnection* connection, - InterfaceRequest request) OVERRIDE { - BindToRequest(new NativeViewportImpl, &request); - } -}; - -MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* - CreateNativeViewportService( - 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 deleted file mode 100644 index 761301111ab4..000000000000 --- a/mojo/services/native_viewport/native_viewport_service.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 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 MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ -#define MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ - -#include "base/memory/scoped_vector.h" -#include "mojo/public/cpp/application/application_impl.h" -#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( - ScopedMessagePipeHandle service_provider_handle); - -} // namespace services -} // namespace mojo - -#endif // MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ diff --git a/mojo/services/native_viewport/platform_viewport.h b/mojo/services/native_viewport/platform_viewport.h index 628c6930a1e8..f42eb7d27345 100644 --- a/mojo/services/native_viewport/platform_viewport.h +++ b/mojo/services/native_viewport/platform_viewport.h @@ -6,7 +6,6 @@ #define MOJO_SERVICES_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_H_ #include "base/memory/scoped_ptr.h" -#include "mojo/services/native_viewport/native_viewport_export.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/size.h" @@ -19,7 +18,6 @@ class Event; } namespace mojo { -namespace services { // Encapsulation of platform-specific Viewport. class PlatformViewport { @@ -50,7 +48,6 @@ class PlatformViewport { static scoped_ptr Create(Delegate* delegate); }; -} // namespace services } // namespace mojo #endif // MOJO_SERVICES_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_H_ diff --git a/mojo/services/native_viewport/platform_viewport_android.cc b/mojo/services/native_viewport/platform_viewport_android.cc index 62ff9b4e7c01..bbe22c953496 100644 --- a/mojo/services/native_viewport/platform_viewport_android.cc +++ b/mojo/services/native_viewport/platform_viewport_android.cc @@ -13,7 +13,6 @@ #include "ui/gfx/point.h" namespace mojo { -namespace services { ui::EventType MotionEventActionToEventType(jint action) { switch (action) { @@ -154,5 +153,4 @@ scoped_ptr PlatformViewport::Create(Delegate* delegate) { new PlatformViewportAndroid(delegate)).Pass(); } -} // namespace services } // namespace mojo diff --git a/mojo/services/native_viewport/platform_viewport_android.h b/mojo/services/native_viewport/platform_viewport_android.h index 4f8e22ebd98c..faf7275ca21d 100644 --- a/mojo/services/native_viewport/platform_viewport_android.h +++ b/mojo/services/native_viewport/platform_viewport_android.h @@ -8,7 +8,6 @@ #include "base/android/jni_weak_ref.h" #include "base/android/scoped_java_ref.h" #include "base/memory/weak_ptr.h" -#include "mojo/services/native_viewport/native_viewport_export.h" #include "mojo/services/native_viewport/platform_viewport.h" #include "ui/events/event_constants.h" #include "ui/gfx/rect.h" @@ -22,12 +21,10 @@ class GLInProcessContext; struct ANativeWindow; namespace mojo { -namespace services { -class MOJO_NATIVE_VIEWPORT_EXPORT PlatformViewportAndroid - : public PlatformViewport { +class PlatformViewportAndroid : public PlatformViewport { public: - static MOJO_NATIVE_VIEWPORT_EXPORT bool Register(JNIEnv* env); + static bool Register(JNIEnv* env); explicit PlatformViewportAndroid(Delegate* delegate); virtual ~PlatformViewportAndroid(); @@ -63,7 +60,6 @@ class MOJO_NATIVE_VIEWPORT_EXPORT PlatformViewportAndroid }; -} // namespace services } // namespace mojo #endif // MOJO_SERVICES_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_ANDROID_H_ diff --git a/mojo/services/native_viewport/platform_viewport_mac.mm b/mojo/services/native_viewport/platform_viewport_mac.mm index 3cdc5adb3aca..9d1105278169 100644 --- a/mojo/services/native_viewport/platform_viewport_mac.mm +++ b/mojo/services/native_viewport/platform_viewport_mac.mm @@ -12,7 +12,6 @@ #include "ui/gfx/rect.h" namespace mojo { -namespace services { class PlatformViewportMac : public PlatformViewport { public: @@ -82,5 +81,4 @@ scoped_ptr PlatformViewport::Create(Delegate* delegate) { return scoped_ptr(new PlatformViewportMac(delegate)).Pass(); } -} // namespace services } // namespace mojo diff --git a/mojo/services/native_viewport/platform_viewport_ozone.cc b/mojo/services/native_viewport/platform_viewport_ozone.cc index 551f125e89ca..f0694cb4f024 100644 --- a/mojo/services/native_viewport/platform_viewport_ozone.cc +++ b/mojo/services/native_viewport/platform_viewport_ozone.cc @@ -15,7 +15,6 @@ #include "ui/platform_window/platform_window_delegate.h" namespace mojo { -namespace services { // TODO(spang): Deduplicate with PlatformViewportX11.. but there's a hack // in there that prevents this. @@ -94,5 +93,4 @@ scoped_ptr PlatformViewport::Create(Delegate* delegate) { new PlatformViewportOzone(delegate)).Pass(); } -} // namespace services } // namespace mojo diff --git a/mojo/services/native_viewport/platform_viewport_stub.cc b/mojo/services/native_viewport/platform_viewport_stub.cc index 5a6db0ad0f3e..9ed83fd72fc4 100644 --- a/mojo/services/native_viewport/platform_viewport_stub.cc +++ b/mojo/services/native_viewport/platform_viewport_stub.cc @@ -7,7 +7,6 @@ // Stub to build on platforms we don't fully support yet. namespace mojo { -namespace services { class PlatformViewportStub : public PlatformViewport { public: @@ -44,5 +43,4 @@ scoped_ptr PlatformViewport::Create(Delegate* delegate) { new PlatformViewportStub(delegate)).Pass(); } -} // namespace services } // namespace mojo diff --git a/mojo/services/native_viewport/platform_viewport_win.cc b/mojo/services/native_viewport/platform_viewport_win.cc index e759b165dd5a..222711222c04 100644 --- a/mojo/services/native_viewport/platform_viewport_win.cc +++ b/mojo/services/native_viewport/platform_viewport_win.cc @@ -10,7 +10,6 @@ #include "ui/platform_window/win/win_window.h" namespace mojo { -namespace services { class PlatformViewportWin : public PlatformViewport, public ui::PlatformWindowDelegate { @@ -102,5 +101,4 @@ scoped_ptr PlatformViewport::Create(Delegate* delegate) { return scoped_ptr(new PlatformViewportWin(delegate)).Pass(); } -} // namespace services } // namespace mojo diff --git a/mojo/services/native_viewport/platform_viewport_x11.cc b/mojo/services/native_viewport/platform_viewport_x11.cc index b15083c5336e..6654cf59b2d4 100644 --- a/mojo/services/native_viewport/platform_viewport_x11.cc +++ b/mojo/services/native_viewport/platform_viewport_x11.cc @@ -16,7 +16,6 @@ #include "ui/platform_window/x11/x11_window.h" namespace mojo { -namespace services { class PlatformViewportX11 : public PlatformViewport, public ui::PlatformWindowDelegate { @@ -116,5 +115,4 @@ scoped_ptr PlatformViewport::Create(Delegate* delegate) { return scoped_ptr(new PlatformViewportX11(delegate)).Pass(); } -} // namespace services } // namespace mojo diff --git a/mojo/shell/android/library_loader.cc b/mojo/shell/android/library_loader.cc index 56d298b1a596..26a99a55ad29 100644 --- a/mojo/shell/android/library_loader.cc +++ b/mojo/shell/android/library_loader.cc @@ -16,7 +16,7 @@ namespace { base::android::RegistrationMethod kMojoRegisteredMethods[] = { { "MojoMain", mojo::RegisterMojoMain }, { "PlatformViewportAndroid", - mojo::services::PlatformViewportAndroid::Register }, + mojo::PlatformViewportAndroid::Register }, }; bool RegisterMojoJni(JNIEnv* env) { diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc index 2b218f3f06dc..a6585e2d701b 100644 --- a/mojo/shell/context.cc +++ b/mojo/shell/context.cc @@ -15,8 +15,10 @@ #include "mojo/application_manager/application_manager.h" #include "mojo/application_manager/background_shell_application_loader.h" #include "mojo/embedder/embedder.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_impl.h" -#include "mojo/services/native_viewport/native_viewport_service.h" +#include "mojo/services/native_viewport/native_viewport_impl.h" #include "mojo/shell/dynamic_application_loader.h" #include "mojo/shell/in_process_dynamic_service_runner.h" #include "mojo/shell/out_of_process_dynamic_service_runner.h" @@ -90,23 +92,40 @@ void InitContentHandlers(DynamicApplicationLoader* loader, } // namespace -class Context::NativeViewportApplicationLoader : public ApplicationLoader { +class Context::NativeViewportApplicationLoader + : public ApplicationLoader, + public ApplicationDelegate, + public InterfaceFactory { public: NativeViewportApplicationLoader() {} virtual ~NativeViewportApplicationLoader() {} private: + // ApplicationLoader implementation. virtual void Load(ApplicationManager* manager, const GURL& url, scoped_refptr callbacks) OVERRIDE { ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication(); if (shell_handle.is_valid()) - app_.reset(services::CreateNativeViewportService(shell_handle.Pass())); + app_.reset(new ApplicationImpl(this, shell_handle.Pass())); } virtual void OnServiceError(ApplicationManager* manager, const GURL& url) OVERRIDE {} + // ApplicationDelegate implementation. + virtual bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) OVERRIDE { + connection->AddService(this); + return true; + } + + // InterfaceFactory implementation. + virtual void Create(ApplicationConnection* connection, + InterfaceRequest request) OVERRIDE { + BindToRequest(new NativeViewportImpl, &request); + } + scoped_ptr app_; DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); }; -- 2.11.4.GIT