Index: content/renderer/compositor_mus_connection.h |
diff --git a/content/renderer/compositor_mus_connection.h b/content/renderer/compositor_mus_connection.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eaf36460b65af5a9a385b31b9d85b10f3fb212fa |
--- /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::ScopedMessagePipeHandle window_tree_client_pipe); |
+ |
+ 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_ |