summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 14:48:12 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 14:49:40 +0000
commit4bf5740ebbca20827ce9d68e251d051cda2ef44e (patch)
treef3c4983497695048a7f3fbdbc3f508506db75d86 /mojo
parenta723bc205ed065a9dfec01cf5921e84545e8e7b6 (diff)
downloadchromium_src-4bf5740ebbca20827ce9d68e251d051cda2ef44e.zip
chromium_src-4bf5740ebbca20827ce9d68e251d051cda2ef44e.tar.gz
chromium_src-4bf5740ebbca20827ce9d68e251d051cda2ef44e.tar.bz2
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
Diffstat (limited to 'mojo')
-rw-r--r--mojo/mojo.gyp4
-rw-r--r--mojo/mojo_services.gypi21
-rw-r--r--mojo/services/gles2/command_buffer_impl.cc2
-rw-r--r--mojo/services/gles2/command_buffer_impl.h2
-rw-r--r--mojo/services/native_viewport/BUILD.gn9
-rw-r--r--mojo/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java2
-rw-r--r--mojo/services/native_viewport/native_viewport_export.h32
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.cc138
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.h57
-rw-r--r--mojo/services/native_viewport/native_viewport_service.cc183
-rw-r--r--mojo/services/native_viewport/native_viewport_service.h23
-rw-r--r--mojo/services/native_viewport/platform_viewport.h3
-rw-r--r--mojo/services/native_viewport/platform_viewport_android.cc2
-rw-r--r--mojo/services/native_viewport/platform_viewport_android.h8
-rw-r--r--mojo/services/native_viewport/platform_viewport_mac.mm2
-rw-r--r--mojo/services/native_viewport/platform_viewport_ozone.cc2
-rw-r--r--mojo/services/native_viewport/platform_viewport_stub.cc2
-rw-r--r--mojo/services/native_viewport/platform_viewport_win.cc2
-rw-r--r--mojo/services/native_viewport/platform_viewport_x11.cc2
-rw-r--r--mojo/shell/android/library_loader.cc2
-rw-r--r--mojo/shell/context.cc25
21 files changed, 235 insertions, 288 deletions
diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp
index 4ba1770..69678c5 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 5f73a42..5bd127e 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 8674f12..d3b9137 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 fc79c5f..fc90d34 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<CommandBuffer> {
public:
@@ -65,7 +64,6 @@ class CommandBufferImpl : public InterfaceImpl<CommandBuffer> {
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 480ea67..b1089d1 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 8aa452f..c3f8075 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 4870c56..0000000
--- 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 0000000..8755dfd
--- /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<gfx::Rect>());
+ client()->OnCreated();
+ OnBoundsChanged(bounds.To<gfx::Rect>());
+}
+
+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<gfx::Rect>());
+}
+
+void NativeViewportImpl::CreateGLES2Context(
+ InterfaceRequest<CommandBuffer> 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<EventPtr, ui::Event>::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 0000000..5d26da5
--- /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<NativeViewport>,
+ public PlatformViewport::Delegate {
+ public:
+ NativeViewportImpl();
+ virtual ~NativeViewportImpl();
+
+ // InterfaceImpl<NativeViewport> 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<CommandBuffer> 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<PlatformViewport> platform_viewport_;
+ InterfaceRequest<CommandBuffer> command_buffer_request_;
+ scoped_ptr<CommandBufferImpl> command_buffer_;
+ bool waiting_for_event_ack_;
+ base::WeakPtrFactory<NativeViewportImpl> 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 9bdc51e..0000000
--- 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<NativeViewport>,
- 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<gfx::Rect>());
- client()->OnCreated();
- OnBoundsChanged(bounds.To<gfx::Rect>());
- }
-
- 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<gfx::Rect>());
- }
-
- virtual void CreateGLES2Context(
- InterfaceRequest<CommandBuffer> 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<EventPtr, ui::Event>::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<PlatformViewport> platform_viewport_;
- InterfaceRequest<CommandBuffer> command_buffer_request_;
- scoped_ptr<CommandBufferImpl> command_buffer_;
- bool waiting_for_event_ack_;
- base::WeakPtrFactory<NativeViewportImpl> weak_factory_;
-};
-
-class NVSDelegate : public ApplicationDelegate,
- public InterfaceFactory<mojo::NativeViewport> {
- public:
- NVSDelegate() {}
- virtual ~NVSDelegate() {}
-
- // ApplicationDelegate implementation.
- virtual bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) OVERRIDE {
- connection->AddService(this);
- return true;
- }
-
- // ServiceFactory<mojo::NativeViewport> implementation.
- virtual void Create(ApplicationConnection* connection,
- InterfaceRequest<mojo::NativeViewport> 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 7613011..0000000
--- 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 628c693..f42eb7d 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<PlatformViewport> 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 62ff9b4..bbe22c9 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> 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 4f8e22e..faf7275 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 3cdc5ad..9d1105278 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> PlatformViewport::Create(Delegate* delegate) {
return scoped_ptr<PlatformViewport>(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 551f125..f0694cb 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> 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 5a6db0a..9ed83fd 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> 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 e759b16..22271122 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> PlatformViewport::Create(Delegate* delegate) {
return scoped_ptr<PlatformViewport>(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 b15083c..6654cf5 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> PlatformViewport::Create(Delegate* delegate) {
return scoped_ptr<PlatformViewport>(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 56d298b..26a99a5 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 2b218f3..a6585e2 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<NativeViewport> {
public:
NativeViewportApplicationLoader() {}
virtual ~NativeViewportApplicationLoader() {}
private:
+ // ApplicationLoader implementation.
virtual void Load(ApplicationManager* manager,
const GURL& url,
scoped_refptr<LoadCallbacks> 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<NativeViewport> implementation.
+ virtual void Create(ApplicationConnection* connection,
+ InterfaceRequest<NativeViewport> request) OVERRIDE {
+ BindToRequest(new NativeViewportImpl, &request);
+ }
+
scoped_ptr<ApplicationImpl> app_;
DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader);
};