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 COMPONENTS_VIEW_MANAGER_VIEW_TREE_HOST_CONNECTION_H_ | 5 #ifndef COMPONENTS_MUS_VIEW_TREE_HOST_CONNECTION_H_ |
6 #define COMPONENTS_VIEW_MANAGER_VIEW_TREE_HOST_CONNECTION_H_ | 6 #define COMPONENTS_MUS_VIEW_TREE_HOST_CONNECTION_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h" | 9 #include "components/mus/public/interfaces/view_tree_host.mojom.h" |
10 #include "components/view_manager/view_tree_host_delegate.h" | 10 #include "components/mus/view_tree_host_delegate.h" |
11 #include "components/view_manager/view_tree_host_impl.h" | 11 #include "components/mus/view_tree_host_impl.h" |
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
13 | 13 |
14 namespace view_manager { | 14 namespace view_manager { |
15 | 15 |
16 class ConnectionManager; | 16 class ConnectionManager; |
17 class ViewTreeImpl; | 17 class ViewTreeImpl; |
18 | 18 |
19 // ViewTreeHostConnection is a server-side object that encapsulates the | 19 // ViewTreeHostConnection is a server-side object that encapsulates the |
20 // connection between a client of the ViewTreeHost and its implementation. | 20 // connection between a client of the ViewTreeHost and its implementation. |
21 // ViewTreeHostConnection also establishes a ClientConnection via the same | 21 // ViewTreeHostConnection also establishes a ClientConnection via the same |
22 // code path as embedded views. ConnectionManager manages the lifetime of | 22 // code path as embedded views. ConnectionManager manages the lifetime of |
23 // ViewTreeHostConnections. If a connection to the client is lost or if the | 23 // ViewTreeHostConnections. If a connection to the client is lost or if the |
24 // associated root is closed, the ViewTreeHostConnection will inform the | 24 // associated root is closed, the ViewTreeHostConnection will inform the |
25 // ConnectionManager to destroy the root and its associated view tree. | 25 // ConnectionManager to destroy the root and its associated view tree. |
26 class ViewTreeHostConnection : public ViewTreeHostDelegate { | 26 class ViewTreeHostConnection : public ViewTreeHostDelegate { |
27 public: | 27 public: |
28 ViewTreeHostConnection( | 28 ViewTreeHostConnection(scoped_ptr<ViewTreeHostImpl> host_impl, |
29 scoped_ptr<ViewTreeHostImpl> host_impl, | 29 ConnectionManager* connection_manager); |
30 ConnectionManager* connection_manager); | |
31 | 30 |
32 void set_view_tree(ViewTreeImpl* tree) { | 31 void set_view_tree(ViewTreeImpl* tree) { tree_ = tree; } |
33 tree_ = tree; | |
34 } | |
35 | 32 |
36 ViewTreeHostImpl* view_tree_host() { return host_.get();} | 33 ViewTreeHostImpl* view_tree_host() { return host_.get(); } |
37 const ViewTreeHostImpl* view_tree_host() const { return host_.get(); } | 34 const ViewTreeHostImpl* view_tree_host() const { return host_.get(); } |
38 | 35 |
39 ConnectionManager* connection_manager() { return connection_manager_; } | 36 ConnectionManager* connection_manager() { return connection_manager_; } |
40 const ConnectionManager* connection_manager() const { | 37 const ConnectionManager* connection_manager() const { |
41 return connection_manager_; | 38 return connection_manager_; |
42 } | 39 } |
43 | 40 |
44 void CloseConnection(); | 41 void CloseConnection(); |
45 | 42 |
46 protected: | 43 protected: |
47 ~ViewTreeHostConnection() override; | 44 ~ViewTreeHostConnection() override; |
48 | 45 |
49 // ViewTreeHostDelegate: | 46 // ViewTreeHostDelegate: |
50 void OnDisplayInitialized() override; | 47 void OnDisplayInitialized() override; |
51 void OnDisplayClosed() override; | 48 void OnDisplayClosed() override; |
52 ViewTreeImpl* GetViewTree() override; | 49 ViewTreeImpl* GetViewTree() override; |
53 | 50 |
54 private: | 51 private: |
55 scoped_ptr<ViewTreeHostImpl> host_; | 52 scoped_ptr<ViewTreeHostImpl> host_; |
56 ViewTreeImpl* tree_; | 53 ViewTreeImpl* tree_; |
57 ConnectionManager* connection_manager_; | 54 ConnectionManager* connection_manager_; |
58 bool connection_closed_; | 55 bool connection_closed_; |
59 | 56 |
60 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostConnection); | 57 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostConnection); |
61 }; | 58 }; |
62 | 59 |
63 // Live implementation of ViewTreeHostConnection. | 60 // Live implementation of ViewTreeHostConnection. |
64 class ViewTreeHostConnectionImpl : public ViewTreeHostConnection { | 61 class ViewTreeHostConnectionImpl : public ViewTreeHostConnection { |
65 public: | 62 public: |
66 ViewTreeHostConnectionImpl( | 63 ViewTreeHostConnectionImpl(mojo::InterfaceRequest<mojo::ViewTreeHost> request, |
67 mojo::InterfaceRequest<mojo::ViewTreeHost> request, | 64 scoped_ptr<ViewTreeHostImpl> host_impl, |
68 scoped_ptr<ViewTreeHostImpl> host_impl, | 65 mojo::ViewTreeClientPtr client, |
69 mojo::ViewTreeClientPtr client, | 66 ConnectionManager* connection_manager); |
70 ConnectionManager* connection_manager); | |
71 | 67 |
72 private: | 68 private: |
73 ~ViewTreeHostConnectionImpl() override; | 69 ~ViewTreeHostConnectionImpl() override; |
74 | 70 |
75 // ViewTreeHostDelegate: | 71 // ViewTreeHostDelegate: |
76 void OnDisplayInitialized() override; | 72 void OnDisplayInitialized() override; |
77 | 73 |
78 mojo::Binding<mojo::ViewTreeHost> binding_; | 74 mojo::Binding<mojo::ViewTreeHost> binding_; |
79 mojo::ViewTreeClientPtr client_; | 75 mojo::ViewTreeClientPtr client_; |
80 | 76 |
81 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostConnectionImpl); | 77 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostConnectionImpl); |
82 }; | 78 }; |
83 | 79 |
84 } // namespace view_manager | 80 } // namespace view_manager |
85 | 81 |
86 #endif // COMPONENTS_VIEW_MANAGER_VIEW_TREE_HOST_CONNECTION_H_ | 82 #endif // COMPONENTS_MUS_VIEW_TREE_HOST_CONNECTION_H_ |
OLD | NEW |