summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfsamuel <fsamuel@chromium.org>2015-12-03 11:15:46 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-03 19:16:43 +0000
commit2e7bf2f61d4d5082769314c90ad557bdf330791c (patch)
tree119e885228b21e4bf782afa9eec3c317516b4c80
parent86b329a6a0dd95fdecf769e1eb868b0ce79243f6 (diff)
downloadchromium_src-2e7bf2f61d4d5082769314c90ad557bdf330791c.zip
chromium_src-2e7bf2f61d4d5082769314c90ad557bdf330791c.tar.gz
chromium_src-2e7bf2f61d4d5082769314c90ad557bdf330791c.tar.bz2
mustash: Implement basic input event routing in renderer
This CL does the following: 1. It introduces CompositorMusConnection. The connection to the Mus Window server is now managed on the compositor thread. RenderWidgetMusConnection is the corresponding main thread object. CompositorMusConnection deals with postTasking information RenderWidgetMusConnection wants to the main thread and passing information from RenderWidgetMusConnection to the compositor thread. 2. Input events are routed directly to InputHandlerManager on the compositor thread. Unconsumed input events make their way to RenderWidgetMusConnection where they're currently dropped on the floor. TEST=./out/mandoline_Debug/mojo_runner mojo:example_main --use-mus-in-renderer --use-zero-copy BUG=551250 Review URL: https://codereview.chromium.org/1484013003 Cr-Commit-Position: refs/heads/master@{#363030}
-rw-r--r--components/html_viewer/BUILD.gn4
-rw-r--r--components/html_viewer/DEPS1
-rw-r--r--components/html_viewer/html_frame.cc2
-rw-r--r--components/html_viewer/ime_controller.cc2
-rw-r--r--components/html_viewer/input_events_unittest.cc2
-rw-r--r--content/renderer/BUILD.gn4
-rw-r--r--content/renderer/compositor_mus_connection.cc139
-rw-r--r--content/renderer/compositor_mus_connection.h83
-rw-r--r--content/renderer/render_widget_mus_connection.cc88
-rw-r--r--content/renderer/render_widget_mus_connection.h40
-rw-r--r--mojo/converters/blink/BUILD.gn24
-rw-r--r--mojo/converters/blink/DEPS6
-rw-r--r--mojo/converters/blink/blink_input_events_type_converters.cc (renamed from components/html_viewer/blink_input_events_type_converters.cc)10
-rw-r--r--mojo/converters/blink/blink_input_events_type_converters.h (renamed from components/html_viewer/blink_input_events_type_converters.h)10
-rw-r--r--mojo/converters/blink/mojo_blink_export.h32
15 files changed, 377 insertions, 70 deletions
diff --git a/components/html_viewer/BUILD.gn b/components/html_viewer/BUILD.gn
index 5f4a08a..2848a5d 100644
--- a/components/html_viewer/BUILD.gn
+++ b/components/html_viewer/BUILD.gn
@@ -63,8 +63,6 @@ source_set("lib") {
"blink_basic_type_converters.h",
"blink_find_type_converters.cc",
"blink_find_type_converters.h",
- "blink_input_events_type_converters.cc",
- "blink_input_events_type_converters.h",
"blink_platform_impl.cc",
"blink_platform_impl.h",
"blink_resource_constants.h",
@@ -177,6 +175,7 @@ source_set("lib") {
"//mojo/application/public/cpp",
"//mojo/application/public/interfaces",
"//mojo/common",
+ "//mojo/converters/blink",
"//mojo/converters/surfaces",
"//mojo/gles2:headers",
"//mojo/gpu:mojo_gles2_implementation",
@@ -316,6 +315,7 @@ test("html_viewer_unittests") {
"//base/test:test_support",
"//components/scheduler",
"//gin",
+ "//mojo/converters/blink",
"//mojo/converters/input_events",
"//mojo/gles2",
"//mojo/platform_handle:platform_handle_impl",
diff --git a/components/html_viewer/DEPS b/components/html_viewer/DEPS
index 21d04e9..e1e5a2f 100644
--- a/components/html_viewer/DEPS
+++ b/components/html_viewer/DEPS
@@ -24,6 +24,7 @@ include_rules = [
"+mojo/application",
"+mojo/cc",
"+mojo/common",
+ "+mojo/converters/blink",
"+mojo/converters/geometry",
"+mojo/converters/input_events",
"+mojo/converters/network",
diff --git a/components/html_viewer/html_frame.cc b/components/html_viewer/html_frame.cc
index 8050f14..1ddb997 100644
--- a/components/html_viewer/html_frame.cc
+++ b/components/html_viewer/html_frame.cc
@@ -17,7 +17,6 @@
#include "components/html_viewer/ax_provider_impl.h"
#include "components/html_viewer/blink_basic_type_converters.h"
#include "components/html_viewer/blink_find_type_converters.h"
-#include "components/html_viewer/blink_input_events_type_converters.h"
#include "components/html_viewer/blink_text_input_type_converters.h"
#include "components/html_viewer/blink_url_request_type_converters.h"
#include "components/html_viewer/devtools_agent_impl.h"
@@ -42,6 +41,7 @@
#include "mojo/application/public/cpp/connect.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
#include "mojo/common/common_type_converters.h"
+#include "mojo/converters/blink/blink_input_events_type_converters.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
diff --git a/components/html_viewer/ime_controller.cc b/components/html_viewer/ime_controller.cc
index 3b65a5a..da6e7b1 100644
--- a/components/html_viewer/ime_controller.cc
+++ b/components/html_viewer/ime_controller.cc
@@ -4,9 +4,9 @@
#include "components/html_viewer/ime_controller.h"
-#include "components/html_viewer/blink_input_events_type_converters.h"
#include "components/html_viewer/blink_text_input_type_converters.h"
#include "components/mus/public/cpp/window.h"
+#include "mojo/converters/blink/blink_input_events_type_converters.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebWidget.h"
diff --git a/components/html_viewer/input_events_unittest.cc b/components/html_viewer/input_events_unittest.cc
index afaf724..4a28bbe 100644
--- a/components/html_viewer/input_events_unittest.cc
+++ b/components/html_viewer/input_events_unittest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/memory/scoped_ptr.h"
-#include "components/html_viewer/blink_input_events_type_converters.h"
+#include "mojo/converters/blink/blink_input_events_type_converters.h"
#include "mojo/converters/input_events/input_events_type_converters.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
index bf1d4de..8275f4e 100644
--- a/content/renderer/BUILD.gn
+++ b/content/renderer/BUILD.gn
@@ -78,11 +78,15 @@ source_set("renderer") {
if (use_aura) {
sources += [
+ "compositor_mus_connection.cc",
+ "compositor_mus_connection.h",
"render_widget_mus_connection.cc",
"render_widget_mus_connection.h",
"render_widget_window_tree_client_factory.cc",
"render_widget_window_tree_client_factory.h",
]
+
+ deps += [ "//mojo/converters/blink" ]
}
if (is_mac) {
diff --git a/content/renderer/compositor_mus_connection.cc b/content/renderer/compositor_mus_connection.cc
new file mode 100644
index 0000000..bb3c7e5
--- /dev/null
+++ b/content/renderer/compositor_mus_connection.cc
@@ -0,0 +1,139 @@
+// Copyright 2015 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 "content/renderer/compositor_mus_connection.h"
+
+#include "base/single_thread_task_runner.h"
+#include "content/common/input/web_input_event_traits.h"
+#include "content/renderer/input/input_handler_manager.h"
+#include "content/renderer/render_widget_mus_connection.h"
+#include "mojo/converters/blink/blink_input_events_type_converters.h"
+#include "ui/events/latency_info.h"
+
+namespace content {
+
+CompositorMusConnection::CompositorMusConnection(
+ int routing_id,
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request,
+ InputHandlerManager* input_handler_manager)
+ : routing_id_(routing_id),
+ root_(nullptr),
+ main_task_runner_(main_task_runner),
+ compositor_task_runner_(compositor_task_runner),
+ input_handler_manager_(input_handler_manager) {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ compositor_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&CompositorMusConnection::
+ CreateWindowTreeConnectionOnCompositorThread,
+ this, base::Passed(std::move(request))));
+}
+
+void CompositorMusConnection::AttachSurfaceOnMainThread(
+ scoped_ptr<mus::WindowSurfaceBinding> surface_binding) {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ compositor_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CompositorMusConnection::AttachSurfaceOnCompositorThread,
+ this, base::Passed(std::move(surface_binding))));
+}
+
+CompositorMusConnection::~CompositorMusConnection() {}
+
+void CompositorMusConnection::AttachSurfaceOnCompositorThread(
+ scoped_ptr<mus::WindowSurfaceBinding> surface_binding) {
+ DCHECK(compositor_task_runner_->BelongsToCurrentThread());
+ window_surface_binding_ = std::move(surface_binding);
+ if (root_) {
+ root_->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
+ std::move(window_surface_binding_));
+ }
+}
+
+void CompositorMusConnection::CreateWindowTreeConnectionOnCompositorThread(
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) {
+ DCHECK(compositor_task_runner_->BelongsToCurrentThread());
+ mus::WindowTreeConnection::Create(
+ this, std::move(request),
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+}
+
+void CompositorMusConnection::OnConnectionLostOnMainThread() {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ RenderWidgetMusConnection* connection =
+ RenderWidgetMusConnection::Get(routing_id_);
+ if (!connection)
+ return;
+ connection->OnConnectionLost();
+}
+
+void CompositorMusConnection::OnWindowInputEventOnMainThread(
+ scoped_ptr<blink::WebInputEvent> web_event,
+ const base::Closure& ack) {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ RenderWidgetMusConnection* connection =
+ RenderWidgetMusConnection::Get(routing_id_);
+ if (!connection) {
+ ack.Run();
+ return;
+ }
+ connection->OnWindowInputEvent(std::move(web_event), ack);
+}
+
+void CompositorMusConnection::OnWindowInputEventAckOnMainThread(
+ const base::Closure& ack) {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ compositor_task_runner_->PostTask(FROM_HERE, ack);
+}
+
+void CompositorMusConnection::OnConnectionLost(
+ mus::WindowTreeConnection* connection) {
+ DCHECK(compositor_task_runner_->BelongsToCurrentThread());
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this));
+}
+
+void CompositorMusConnection::OnEmbed(mus::Window* root) {
+ DCHECK(compositor_task_runner_->BelongsToCurrentThread());
+ root_ = root;
+ root_->AddObserver(this);
+ if (window_surface_binding_) {
+ root->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
+ std::move(window_surface_binding_));
+ }
+}
+
+void CompositorMusConnection::OnWindowInputEvent(
+ mus::Window* window,
+ const mus::mojom::EventPtr& event) {
+ DCHECK(compositor_task_runner_->BelongsToCurrentThread());
+ scoped_ptr<blink::WebInputEvent> web_event =
+ event.To<scoped_ptr<blink::WebInputEvent>>();
+ // TODO(sad): We probably need to plumb LatencyInfo through Mus.
+ ui::LatencyInfo info;
+ InputEventAckState ack_state = input_handler_manager_->HandleInputEvent(
+ routing_id_, web_event.get(), &info);
+ if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED)
+ return;
+ // TODO(sad): Do something more useful once we can do async acks.
+ base::Closure ack = base::Bind(&base::DoNothing);
+ const bool send_ack =
+ WebInputEventTraits::WillReceiveAckFromRenderer(*web_event);
+ if (send_ack) {
+ // Ultimately, this ACK needs to go back to the Mus client lib which is not
+ // thread-safe and lives on the compositor thread. For ACKs that are passed
+ // to the main thread we pass them back to the compositor thread via
+ // OnWindowInputEventAckOnMainThread.
+ ack = base::Bind(
+ &CompositorMusConnection::OnWindowInputEventAckOnMainThread, this, ack);
+ }
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,
+ base::Passed(std::move(web_event)), ack));
+}
+
+} // namespace content
diff --git a/content/renderer/compositor_mus_connection.h b/content/renderer/compositor_mus_connection.h
new file mode 100644
index 0000000..a11af6b
--- /dev/null
+++ b/content/renderer/compositor_mus_connection.h
@@ -0,0 +1,83 @@
+// Copyright 2015 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 CONTENT_RENDERER_COMPOSITOR_MUS_CONNECTION_H_
+#define CONTENT_RENDERER_COMPOSITOR_MUS_CONNECTION_H_
+
+#include "base/bind.h"
+#include "base/macros.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+
+namespace content {
+
+class InputHandlerManager;
+
+// CompositorMusConnection manages the connection to the Mandoline UI Service
+// (Mus) on the compositor thread. For operations that need to happen on the
+// main thread, CompositorMusConnection deals with passing information across
+// threads. CompositorMusConnection is constructed on the main thread. By
+// default all other methods are assumed to run on the compositor thread unless
+// explicited suffixed with OnMainThread.
+class CompositorMusConnection
+ : public mus::WindowTreeDelegate,
+ public mus::WindowObserver,
+ public base::RefCountedThreadSafe<CompositorMusConnection> {
+ public:
+ // Created on main thread.
+ CompositorMusConnection(
+ int routing_id,
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request,
+ InputHandlerManager* input_handler_manager);
+
+ // Attaches the provided |surface_binding| with the mus::Window for the
+ // renderer once it becomes available.
+ void AttachSurfaceOnMainThread(
+ scoped_ptr<mus::WindowSurfaceBinding> surface_binding);
+
+ private:
+ friend class base::RefCountedThreadSafe<CompositorMusConnection>;
+
+ ~CompositorMusConnection() override;
+
+ void AttachSurfaceOnCompositorThread(
+ scoped_ptr<mus::WindowSurfaceBinding> surface_binding);
+
+ void CreateWindowTreeConnectionOnCompositorThread(
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request);
+
+ void OnConnectionLostOnMainThread();
+
+ void OnWindowInputEventOnMainThread(
+ scoped_ptr<blink::WebInputEvent> web_event,
+ const base::Closure& ack);
+
+ void OnWindowInputEventAckOnMainThread(const base::Closure& ack);
+
+ // WindowTreeDelegate implementation:
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
+ void OnEmbed(mus::Window* root) override;
+
+ // WindowObserver implementation:
+ void OnWindowInputEvent(mus::Window* window,
+ const mus::mojom::EventPtr& event) override;
+
+ const int routing_id_;
+ mus::Window* root_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
+ InputHandlerManager* const input_handler_manager_;
+ scoped_ptr<mus::WindowSurfaceBinding> window_surface_binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompositorMusConnection);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_COMPOSITOR_MUS_CONNECTION_H_
diff --git a/content/renderer/render_widget_mus_connection.cc b/content/renderer/render_widget_mus_connection.cc
index e0e81a5..cb7ea38 100644
--- a/content/renderer/render_widget_mus_connection.cc
+++ b/content/renderer/render_widget_mus_connection.cc
@@ -7,6 +7,7 @@
#include <map>
#include "base/lazy_instance.h"
+#include "base/macros.h"
#include "components/mus/public/cpp/context_provider.h"
#include "components/mus/public/cpp/output_surface.h"
#include "components/mus/public/interfaces/command_buffer.mojom.h"
@@ -14,6 +15,9 @@
#include "components/mus/public/interfaces/gpu.mojom.h"
#include "components/mus/public/interfaces/window_tree.mojom.h"
#include "content/public/common/mojo_shell_connection.h"
+#include "content/renderer/compositor_mus_connection.h"
+#include "content/renderer/render_thread_impl.h"
+#include "content/renderer/render_view_impl.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/surfaces/surfaces_utils.h"
@@ -27,22 +31,22 @@ base::LazyInstance<ConnectionMap>::Leaky g_connections =
LAZY_INSTANCE_INITIALIZER;
}
-RenderWidgetMusConnection::RenderWidgetMusConnection(int routing_id)
- : routing_id_(routing_id), root_(nullptr) {
- DCHECK(routing_id);
-}
-
-RenderWidgetMusConnection::~RenderWidgetMusConnection() {}
-
void RenderWidgetMusConnection::Bind(
mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) {
- DCHECK(!root_);
- mus::WindowTreeConnection::Create(
- this, request.Pass(),
- mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ DCHECK(thread_checker_.CalledOnValidThread());
+ RenderThreadImpl* render_thread = RenderThreadImpl::current();
+ compositor_mus_connection_ = new CompositorMusConnection(
+ routing_id_, render_thread->GetCompositorMainThreadTaskRunner(),
+ render_thread->compositor_task_runner(), std::move(request),
+ render_thread->input_handler_manager());
+ if (window_surface_binding_) {
+ compositor_mus_connection_->AttachSurfaceOnMainThread(
+ std::move(window_surface_binding_));
+ }
}
scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!window_surface_binding_);
mus::mojom::GpuPtr gpu_service;
MojoShellConnection::Get()->GetApplication()->ConnectToService("mojo:mus",
@@ -51,49 +55,57 @@ scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
scoped_refptr<cc::ContextProvider> context_provider(
new mus::ContextProvider(cb.PassInterface().PassHandle()));
- scoped_ptr<cc::OutputSurface> output_surface(new mus::OutputSurface(
+ scoped_ptr<cc::OutputSurface> surface(new mus::OutputSurface(
context_provider, mus::WindowSurface::Create(&window_surface_binding_)));
- if (root_) {
- root_->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
- window_surface_binding_.Pass());
+ if (compositor_mus_connection_) {
+ compositor_mus_connection_->AttachSurfaceOnMainThread(
+ std::move(window_surface_binding_));
}
- return output_surface.Pass();
+ return surface;
}
// static
-RenderWidgetMusConnection* RenderWidgetMusConnection::GetOrCreate(
- int routing_id) {
+RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) {
auto it = g_connections.Get().find(routing_id);
if (it != g_connections.Get().end())
return it->second;
+ return nullptr;
+}
- RenderWidgetMusConnection* connection =
- new RenderWidgetMusConnection(routing_id);
- g_connections.Get().insert(std::make_pair(routing_id, connection));
+// static
+RenderWidgetMusConnection* RenderWidgetMusConnection::GetOrCreate(
+ int routing_id) {
+ RenderWidgetMusConnection* connection = Get(routing_id);
+ if (!connection) {
+ connection = new RenderWidgetMusConnection(routing_id);
+ g_connections.Get().insert(std::make_pair(routing_id, connection));
+ }
return connection;
}
-void RenderWidgetMusConnection::OnConnectionLost(
- mus::WindowTreeConnection* connection) {
- g_connections.Get().erase(routing_id_);
- delete this;
+RenderWidgetMusConnection::RenderWidgetMusConnection(int routing_id)
+ : routing_id_(routing_id) {
+ DCHECK(routing_id);
}
-void RenderWidgetMusConnection::OnEmbed(mus::Window* root) {
- root_ = root;
- root_->AddObserver(this);
- if (window_surface_binding_) {
- root->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
- window_surface_binding_.Pass());
- }
-}
+RenderWidgetMusConnection::~RenderWidgetMusConnection() {}
-void RenderWidgetMusConnection::OnUnembed() {}
+void RenderWidgetMusConnection::OnConnectionLost() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ g_connections.Get().erase(routing_id_);
+ delete this;
+}
-void RenderWidgetMusConnection::OnWindowBoundsChanged(
- mus::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
+void RenderWidgetMusConnection::OnWindowInputEvent(
+ scoped_ptr<blink::WebInputEvent> input_event,
+ const base::Closure& ack) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ // TODO(fsamuel): Implement this once the following is complete:
+ // 1. The Mus client lib supports manual event ACKing.
+ // 2. Mus supports event coalescing.
+ // 3. RenderWidget is refactored so that we don't send ACKs to the browser
+ // process.
+ ack.Run();
}
} // namespace content
diff --git a/content/renderer/render_widget_mus_connection.h b/content/renderer/render_widget_mus_connection.h
index b3f4549..316fbbc 100644
--- a/content/renderer/render_widget_mus_connection.h
+++ b/content/renderer/render_widget_mus_connection.h
@@ -6,44 +6,46 @@
#define CONTENT_RENDERER_RENDER_WIDGET_MUS_CONNECTION_H_
#include "base/macros.h"
+#include "base/threading/thread_checker.h"
#include "cc/output/output_surface.h"
-#include "components/mus/public/cpp/window.h"
-#include "components/mus/public/cpp/window_observer.h"
#include "components/mus/public/cpp/window_surface.h"
-#include "components/mus/public/cpp/window_tree_connection.h"
-#include "components/mus/public/cpp/window_tree_delegate.h"
-#include "mojo/public/cpp/bindings/binding.h"
+#include "content/renderer/compositor_mus_connection.h"
namespace content {
-class RenderWidgetMusConnection : public mus::WindowTreeDelegate,
- public mus::WindowObserver {
- public:
- explicit RenderWidgetMusConnection(int routing_id);
- ~RenderWidgetMusConnection() override;
+class InputHandlerManager;
- // Connect to a WindowTreeClient request.
+// Use on main thread.
+class RenderWidgetMusConnection {
+ public:
+ // Bind to a WindowTreeClient request.
void Bind(mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request);
// Create a cc output surface.
scoped_ptr<cc::OutputSurface> CreateOutputSurface();
+ static RenderWidgetMusConnection* Get(int routing_id);
+
// Get the connection from a routing_id, if the connection doesn't exist,
// a new connection will be created.
static RenderWidgetMusConnection* GetOrCreate(int routing_id);
private:
- // WindowTreeDelegate implementation:
- void OnConnectionLost(mus::WindowTreeConnection* connection) override;
- void OnEmbed(mus::Window* root) override;
- void OnUnembed() override;
- void OnWindowBoundsChanged(mus::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) override;
+ friend class CompositorMusConnection;
+
+ explicit RenderWidgetMusConnection(int routing_id);
+ ~RenderWidgetMusConnection();
+
+ void OnConnectionLost();
+ void OnWindowInputEvent(scoped_ptr<blink::WebInputEvent> input_event,
+ const base::Closure& ack);
const int routing_id_;
- mus::Window* root_;
scoped_ptr<mus::WindowSurfaceBinding> window_surface_binding_;
+ scoped_refptr<CompositorMusConnection> compositor_mus_connection_;
+
+ // Used to verify single threaded access.
+ base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetMusConnection);
};
diff --git a/mojo/converters/blink/BUILD.gn b/mojo/converters/blink/BUILD.gn
new file mode 100644
index 0000000..f5486f05
--- /dev/null
+++ b/mojo/converters/blink/BUILD.gn
@@ -0,0 +1,24 @@
+# Copyright 2015 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.
+
+component("blink") {
+ output_name = "mojo_blink_lib"
+
+ sources = [
+ "blink_input_events_type_converters.cc",
+ "blink_input_events_type_converters.h",
+ "mojo_blink_export.h",
+ ]
+
+ defines = [ "MOJO_CONVERTERS_BLINK_IMPLEMENTATION" ]
+
+ deps = [
+ "//base",
+ "//components/mus/public/interfaces",
+ "//mojo/environment:chromium",
+ "//mojo/public/c/system:for_component",
+ "//third_party/WebKit/public:blink",
+ "//ui/events",
+ ]
+}
diff --git a/mojo/converters/blink/DEPS b/mojo/converters/blink/DEPS
new file mode 100644
index 0000000..95de851
--- /dev/null
+++ b/mojo/converters/blink/DEPS
@@ -0,0 +1,6 @@
+include_rules = [
+ "+base",
+ "+components/mus/public",
+ "+third_party/WebKit/public",
+ "+ui/events"
+]
diff --git a/components/html_viewer/blink_input_events_type_converters.cc b/mojo/converters/blink/blink_input_events_type_converters.cc
index 5b36a77..eca9fac 100644
--- a/components/html_viewer/blink_input_events_type_converters.cc
+++ b/mojo/converters/blink/blink_input_events_type_converters.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/html_viewer/blink_input_events_type_converters.h"
+#include "mojo/converters/blink/blink_input_events_type_converters.h"
#include "base/logging.h"
#include "base/time/time.h"
@@ -117,8 +117,9 @@ scoped_ptr<blink::WebInputEvent> BuildWebKeyboardEvent(
switch (event->action) {
case mus::mojom::EVENT_TYPE_KEY_PRESSED:
- web_event->type = event->key_data->is_char ? blink::WebInputEvent::Char :
- blink::WebInputEvent::RawKeyDown;
+ web_event->type = event->key_data->is_char
+ ? blink::WebInputEvent::Char
+ : blink::WebInputEvent::RawKeyDown;
break;
case mus::mojom::EVENT_TYPE_KEY_RELEASED:
web_event->type = blink::WebInputEvent::KeyUp;
@@ -204,7 +205,8 @@ TypeConverter<scoped_ptr<blink::WebInputEvent>, mus::mojom::EventPtr>::Convert(
if (event->pointer_data &&
event->pointer_data->kind == mus::mojom::POINTER_KIND_MOUSE) {
return BuildWebMouseEventFrom(event);
- }
+ }
+ return nullptr;
case mus::mojom::EVENT_TYPE_WHEEL:
return BuildWebMouseWheelEventFrom(event);
case mus::mojom::EVENT_TYPE_KEY_PRESSED:
diff --git a/components/html_viewer/blink_input_events_type_converters.h b/mojo/converters/blink/blink_input_events_type_converters.h
index 9461bdc..bb1dce1 100644
--- a/components/html_viewer/blink_input_events_type_converters.h
+++ b/mojo/converters/blink/blink_input_events_type_converters.h
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_HTML_VIEWER_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
-#define COMPONENTS_HTML_VIEWER_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
+#ifndef MOJO_CONVERTERS_BLINK_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
+#define MOJO_CONVERTERS_BLINK_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
#include "base/memory/scoped_ptr.h"
#include "components/mus/public/interfaces/input_events.mojom.h"
+#include "mojo/converters/blink/mojo_blink_export.h"
namespace blink {
class WebInputEvent;
@@ -15,11 +16,12 @@ class WebInputEvent;
namespace mojo {
template <>
-struct TypeConverter<scoped_ptr<blink::WebInputEvent>, mus::mojom::EventPtr> {
+struct MOJO_BLINK_EXPORT
+ TypeConverter<scoped_ptr<blink::WebInputEvent>, mus::mojom::EventPtr> {
static scoped_ptr<blink::WebInputEvent> Convert(
const mus::mojom::EventPtr& input);
};
} // namespace mojo
-#endif // COMPONENTS_HTML_VIEWER_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
+#endif // MOJO_CONVERTERS_BLINK_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
diff --git a/mojo/converters/blink/mojo_blink_export.h b/mojo/converters/blink/mojo_blink_export.h
new file mode 100644
index 0000000..1a77184
--- /dev/null
+++ b/mojo/converters/blink/mojo_blink_export.h
@@ -0,0 +1,32 @@
+// Copyright 2015 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_CONVERTERS_BLINK_MOJO_BLINK_EXPORT_H_
+#define MOJO_CONVERTERS_BLINK_MOJO_BLINK_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+
+#if defined(WIN32)
+
+#if defined(MOJO_CONVERTERS_BLINK_IMPLEMENTATION)
+#define MOJO_BLINK_EXPORT __declspec(dllexport)
+#else
+#define MOJO_BLINK_EXPORT __declspec(dllimport)
+#endif
+
+#else // !defined(WIN32)
+
+#if defined(MOJO_CONVERTERS_BLINK_IMPLEMENTATION)
+#define MOJO_BLINK_EXPORT __attribute__((visibility("default")))
+#else
+#define MOJO_BLINK_EXPORT
+#endif
+
+#endif // defined(WIN32)
+
+#else // !defined(COMPONENT_BUILD)
+#define MOJO_BLINK_EXPORT
+#endif
+
+#endif // MOJO_CONVERTERS_BLINK_MOJO_BLINK_EXPORT_H_