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