Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: content/renderer/render_widget_mus_connection.cc

Issue 1484013003: mustash: Implement basic input event routing in renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed dependency for unit test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_widget_mus_connection.h ('k') | mojo/converters/blink/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget_mus_connection.cc
diff --git a/content/renderer/render_widget_mus_connection.cc b/content/renderer/render_widget_mus_connection.cc
index e0e81a565ce3eb7ca3d19cd69846872d36f11647..cb7ea382224658340de6f34afd28535792b6a223 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
« no previous file with comments | « content/renderer/render_widget_mus_connection.h ('k') | mojo/converters/blink/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698