| 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_MANAGER_ROOT_CONNECTION_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ |
| 6 #define COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ | 6 #define COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_ROOT_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_manager_root.mojom.h" | 9 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" |
| 10 #include "components/view_manager/view_manager_root_delegate.h" | 10 #include "components/view_manager/view_manager_root_delegate.h" |
| 11 #include "components/view_manager/view_manager_root_impl.h" | 11 #include "components/view_manager/view_manager_root_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 ViewManagerServiceImpl; | 17 class ViewTreeImpl; |
| 18 | 18 |
| 19 // ViewManagerRootConnection is a server-side object that encapsulates the | 19 // ViewManagerRootConnection is a server-side object that encapsulates the |
| 20 // connection between a client of the ViewManagerRoot and its implementation. | 20 // connection between a client of the ViewManagerRoot and its implementation. |
| 21 // ViewManagerRootConnection also establishes a ClientConnection via the same | 21 // ViewManagerRootConnection 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 // ViewManagerRootConnections. If a connection to the client is lost or if the | 23 // ViewManagerRootConnections. If a connection to the client is lost or if the |
| 24 // associated root is closed, the ViewManagerRootConnection will inform the | 24 // associated root is closed, the ViewManagerRootConnection 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 ViewManagerRootConnection : public ViewManagerRootDelegate { | 26 class ViewManagerRootConnection : public ViewManagerRootDelegate { |
| 27 public: | 27 public: |
| 28 ViewManagerRootConnection( | 28 ViewManagerRootConnection( |
| 29 scoped_ptr<ViewManagerRootImpl> view_manager_root, | 29 scoped_ptr<ViewManagerRootImpl> view_manager_root, |
| 30 ConnectionManager* connection_manager); | 30 ConnectionManager* connection_manager); |
| 31 | 31 |
| 32 void set_view_manager_service(ViewManagerServiceImpl* service) { | 32 void set_view_tree(ViewTreeImpl* tree) { |
| 33 service_ = service; | 33 tree_ = tree; |
| 34 } | 34 } |
| 35 | 35 |
| 36 ViewManagerRootImpl* view_manager_root() { return root_.get();} | 36 ViewManagerRootImpl* view_manager_root() { return root_.get();} |
| 37 const ViewManagerRootImpl* view_manager_root() const { return root_.get(); } | 37 const ViewManagerRootImpl* view_manager_root() const { return root_.get(); } |
| 38 | 38 |
| 39 ConnectionManager* connection_manager() { return connection_manager_; } | 39 ConnectionManager* connection_manager() { return connection_manager_; } |
| 40 const ConnectionManager* connection_manager() const { | 40 const ConnectionManager* connection_manager() const { |
| 41 return connection_manager_; | 41 return connection_manager_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void CloseConnection(); | 44 void CloseConnection(); |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 ~ViewManagerRootConnection() override; | 47 ~ViewManagerRootConnection() override; |
| 48 | 48 |
| 49 // ViewManagerRootDelegate: | 49 // ViewManagerRootDelegate: |
| 50 void OnDisplayInitialized() override; | 50 void OnDisplayInitialized() override; |
| 51 void OnDisplayClosed() override; | 51 void OnDisplayClosed() override; |
| 52 ViewManagerServiceImpl* GetViewManagerService() override; | 52 ViewTreeImpl* GetViewTree() override; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 scoped_ptr<ViewManagerRootImpl> root_; | 55 scoped_ptr<ViewManagerRootImpl> root_; |
| 56 ViewManagerServiceImpl* service_; | 56 ViewTreeImpl* tree_; |
| 57 ConnectionManager* connection_manager_; | 57 ConnectionManager* connection_manager_; |
| 58 bool connection_closed_; | 58 bool connection_closed_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ViewManagerRootConnection); | 60 DISALLOW_COPY_AND_ASSIGN(ViewManagerRootConnection); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Live implementation of ViewManagerRootConnection. | 63 // Live implementation of ViewManagerRootConnection. |
| 64 class ViewManagerRootConnectionImpl : public ViewManagerRootConnection { | 64 class ViewManagerRootConnectionImpl : public ViewManagerRootConnection { |
| 65 public: | 65 public: |
| 66 ViewManagerRootConnectionImpl( | 66 ViewManagerRootConnectionImpl( |
| 67 mojo::InterfaceRequest<mojo::ViewManagerRoot> request, | 67 mojo::InterfaceRequest<mojo::ViewManagerRoot> request, |
| 68 scoped_ptr<ViewManagerRootImpl> root, | 68 scoped_ptr<ViewManagerRootImpl> root, |
| 69 mojo::ViewManagerClientPtr client, | 69 mojo::ViewTreeClientPtr client, |
| 70 ConnectionManager* connection_manager); | 70 ConnectionManager* connection_manager); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 ~ViewManagerRootConnectionImpl() override; | 73 ~ViewManagerRootConnectionImpl() override; |
| 74 | 74 |
| 75 // ViewManagerRootDelegate: | 75 // ViewManagerRootDelegate: |
| 76 void OnDisplayInitialized() override; | 76 void OnDisplayInitialized() override; |
| 77 | 77 |
| 78 mojo::Binding<mojo::ViewManagerRoot> binding_; | 78 mojo::Binding<mojo::ViewManagerRoot> binding_; |
| 79 mojo::ViewManagerClientPtr client_; | 79 mojo::ViewTreeClientPtr client_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(ViewManagerRootConnectionImpl); | 81 DISALLOW_COPY_AND_ASSIGN(ViewManagerRootConnectionImpl); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace view_manager | 84 } // namespace view_manager |
| 85 | 85 |
| 86 #endif // COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ | 86 #endif // COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ |
| OLD | NEW |