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_RENDER_WIDGET_MUS_CONNECTION_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_MUS_CONNECTION_H_ |
6 #define CONTENT_RENDERER_RENDER_WIDGET_MUS_CONNECTION_H_ | 6 #define CONTENT_RENDERER_RENDER_WIDGET_MUS_CONNECTION_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "cc/output/output_surface.h" | 9 #include "cc/output/output_surface.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_surface.h" | 10 #include "components/mus/public/cpp/window_surface.h" |
13 #include "components/mus/public/cpp/window_tree_connection.h" | 11 #include "content/renderer/compositor_mus_connection.h" |
14 #include "components/mus/public/cpp/window_tree_delegate.h" | |
15 #include "mojo/public/cpp/bindings/binding.h" | |
16 | 12 |
17 namespace content { | 13 namespace content { |
18 | 14 |
19 class RenderWidgetMusConnection : public mus::WindowTreeDelegate, | 15 class InputHandlerManager; |
20 public mus::WindowObserver { | 16 |
| 17 // Use on main thread. |
| 18 class RenderWidgetMusConnection { |
21 public: | 19 public: |
22 RenderWidgetMusConnection( | 20 // Bind to a WindowTreeClient request. |
23 int routing_id); | 21 void Bind(mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request); |
24 ~RenderWidgetMusConnection() override; | |
25 | |
26 // Connect to a WindowTreeClient request. | |
27 void Connect(mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request); | |
28 | 22 |
29 // Create a cc output surface. | 23 // Create a cc output surface. |
30 scoped_ptr<cc::OutputSurface> CreateOutputSurface(); | 24 scoped_ptr<cc::OutputSurface> CreateOutputSurface(); |
31 | 25 |
| 26 static RenderWidgetMusConnection* Get(int routing_id); |
| 27 |
32 // Get the connection from a routing_id, if the connection doesn't exist, | 28 // Get the connection from a routing_id, if the connection doesn't exist, |
33 // a new connection will be created. | 29 // a new connection will be created. |
34 static RenderWidgetMusConnection* Get(int routing_id); | 30 static RenderWidgetMusConnection* GetOrCreate(int routing_id); |
35 | 31 |
36 private: | 32 private: |
37 // WindowTreeDelegate implementation: | 33 friend class CompositorMusConnection; |
38 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 34 |
39 void OnEmbed(mus::Window* root) override; | 35 explicit RenderWidgetMusConnection(int routing_id); |
40 void OnUnembed() override; | 36 ~RenderWidgetMusConnection(); |
41 void OnWindowBoundsChanged(mus::Window* window, | 37 |
42 const gfx::Rect& old_bounds, | 38 void OnConnectionLost(); |
43 const gfx::Rect& new_bounds) override; | 39 void OnWindowInputEvent(scoped_ptr<blink::WebInputEvent> input_event); |
44 | 40 |
45 const int routing_id_; | 41 const int routing_id_; |
46 bool connected_; | |
47 mus::Window* root_; | |
48 scoped_ptr<mus::WindowSurfaceBinding> window_surface_binding_; | 42 scoped_ptr<mus::WindowSurfaceBinding> window_surface_binding_; |
| 43 scoped_refptr<CompositorMusConnection> compositor_mus_connection_; |
49 | 44 |
50 DISALLOW_COPY_AND_ASSIGN(RenderWidgetMusConnection); | 45 DISALLOW_COPY_AND_ASSIGN(RenderWidgetMusConnection); |
51 }; | 46 }; |
52 | 47 |
53 } // namespace content | 48 } // namespace content |
54 | 49 |
55 #endif // CONTENT_RENDERER_RENDER_WIDGET_MUS_CONNECTION_H_ | 50 #endif // CONTENT_RENDERER_RENDER_WIDGET_MUS_CONNECTION_H_ |
OLD | NEW |