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

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: The right diff 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
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 607918007b7e9f931307379e0fff003efc3695a8..5b4c439d901b814a797d058343105c25fd5d129d 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,8 @@
#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"
@@ -26,80 +29,76 @@ namespace {
typedef std::map<int, RenderWidgetMusConnection*> ConnectionMap;
base::LazyInstance<ConnectionMap>::Leaky g_connections =
LAZY_INSTANCE_INITIALIZER;
-
-}
-
-RenderWidgetMusConnection::RenderWidgetMusConnection(
- int routing_id)
- : routing_id_(routing_id), connected_(false), root_(nullptr) {
- DCHECK(routing_id);
-}
-
-RenderWidgetMusConnection::~RenderWidgetMusConnection() {
}
-void RenderWidgetMusConnection::Connect(
+void RenderWidgetMusConnection::Bind(
mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) {
- // TODO(fsamuel): We probably want to pause processing of incoming
- // messages until we have an associated RenderWidget.
- DCHECK(!connected_);
- mus::WindowTreeConnection::Create(
- this, request.Pass(),
- mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
- connected_ = true;
+ RenderThreadImpl* render_thread = RenderThreadImpl::current();
+ compositor_mus_connection_ = new CompositorMusConnection(
+ routing_id_, render_thread->GetCompositorMainThreadTaskRunner(),
+ render_thread->compositor_task_runner(), request.Pass(),
+ render_thread->input_handler_manager());
+ if (window_surface_binding_) {
+ compositor_mus_connection_->AttachSurfaceOnMainThread(
+ window_surface_binding_.Pass());
+ }
}
scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
- DCHECK(!window_surface_binding_);
mus::mojom::GpuPtr gpu_service;
sadrul 2015/12/02 18:20:57 Is there a reason to remove the DCHECK()?
Fady Samuel 2015/12/02 21:30:28 No, restored.
- MojoShellConnection::Get()->GetApplication()->ConnectToService(
- "mojo:mus", &gpu_service);
+ MojoShellConnection::Get()->GetApplication()->ConnectToService("mojo:mus",
+ &gpu_service);
mus::mojom::CommandBufferPtr cb;
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(
- context_provider,
- mus::WindowSurface::Create(&window_surface_binding_)));
- if (root_) {
- root_->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
- window_surface_binding_.Pass());
+ scoped_ptr<cc::OutputSurface> surface(new mus::OutputSurface(
+ context_provider, mus::WindowSurface::Create(&window_surface_binding_)));
+ if (compositor_mus_connection_) {
+ compositor_mus_connection_->AttachSurfaceOnMainThread(
+ window_surface_binding_.Pass());
}
- return output_surface.Pass();
+ return surface;
sadrul 2015/12/02 18:20:57 Should RenderWidgetMusConnection also check that i
Fady Samuel 2015/12/02 21:30:28 Sure. That's a good idea. I added a ThreadChecker
}
+// static
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() {
+ 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) {
+ // TODO(fsamuel): Implement this once the following is complete:
+ // 1. The Mus client lib support manual event ACKing.
+ // 2. Mus supports event coalescing.
+ // 3. RenderWidget is refactored so that we don't send ACKs to the browser
+ // process.
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698