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