OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_COMPOSITOR_MUS_CONNECTION_H_ |
| 6 #define CONTENT_RENDERER_COMPOSITOR_MUS_CONNECTION_H_ |
| 7 |
| 8 #include "base/bind.h" |
| 9 #include "base/macros.h" |
| 10 #include "components/mus/public/cpp/window.h" |
| 11 #include "components/mus/public/cpp/window_observer.h" |
| 12 #include "components/mus/public/cpp/window_tree_connection.h" |
| 13 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 14 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class InputHandlerManager; |
| 19 |
| 20 // CompositorMusConnection manages the connection to the Mandoline UI Service |
| 21 // (Mus) on the compositor thread. For operations that need to happen on the |
| 22 // main thread, CompositorMusConnection deals with passing information across |
| 23 // threads. CompositorMusConnection is constructed on the main thread. By |
| 24 // default all other methods are assumed to run on the compositor thread unless |
| 25 // explicited suffixed with OnMainThread. |
| 26 class CompositorMusConnection |
| 27 : public mus::WindowTreeDelegate, |
| 28 public mus::WindowObserver, |
| 29 public base::RefCountedThreadSafe<CompositorMusConnection> { |
| 30 public: |
| 31 // Created on main thread. |
| 32 CompositorMusConnection( |
| 33 int routing_id, |
| 34 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
| 35 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, |
| 36 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request, |
| 37 InputHandlerManager* input_handler_manager); |
| 38 |
| 39 // Attaches the provided |surface_binding| with the mus::Window for the |
| 40 // renderer once it becomes available. |
| 41 void AttachSurfaceOnMainThread( |
| 42 scoped_ptr<mus::WindowSurfaceBinding> surface_binding); |
| 43 |
| 44 private: |
| 45 friend class base::RefCountedThreadSafe<CompositorMusConnection>; |
| 46 |
| 47 ~CompositorMusConnection() override; |
| 48 |
| 49 void AttachSurfaceOnCompositorThread( |
| 50 scoped_ptr<mus::WindowSurfaceBinding> surface_binding); |
| 51 |
| 52 void CreateWindowTreeConnectionOnCompositorThread( |
| 53 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request); |
| 54 |
| 55 void OnConnectionLostOnMainThread(); |
| 56 |
| 57 void OnWindowInputEventOnMainThread( |
| 58 scoped_ptr<blink::WebInputEvent> web_event, |
| 59 const base::Closure& ack); |
| 60 |
| 61 void OnWindowInputEventAckOnMainThread(const base::Closure& ack); |
| 62 |
| 63 // WindowTreeDelegate implementation: |
| 64 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
| 65 void OnEmbed(mus::Window* root) override; |
| 66 |
| 67 // WindowObserver implementation: |
| 68 void OnWindowInputEvent(mus::Window* window, |
| 69 const mus::mojom::EventPtr& event) override; |
| 70 |
| 71 const int routing_id_; |
| 72 mus::Window* root_; |
| 73 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 74 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 75 InputHandlerManager* const input_handler_manager_; |
| 76 scoped_ptr<mus::WindowSurfaceBinding> window_surface_binding_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(CompositorMusConnection); |
| 79 }; |
| 80 |
| 81 } // namespace content |
| 82 |
| 83 #endif // CONTENT_RENDERER_COMPOSITOR_MUS_CONNECTION_H_ |
OLD | NEW |