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