| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ |
| 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class ViewManagerSynchronizer; | 21 class ViewManagerSynchronizer; |
| 22 class ViewTreeNode; | 22 class ViewTreeNode; |
| 23 | 23 |
| 24 // Approximately encapsulates the View Manager service. | 24 // Approximately encapsulates the View Manager service. |
| 25 // Has a synchronizer that keeps a client model in sync with the service. | 25 // Has a synchronizer that keeps a client model in sync with the service. |
| 26 // Owned by the connection. | 26 // Owned by the connection. |
| 27 // | 27 // |
| 28 // TODO: displays | 28 // TODO: displays |
| 29 class ViewManager { | 29 class ViewManager { |
| 30 public: | 30 public: |
| 31 typedef base::Callback<void(ViewManager*, ViewTreeNode*)> RootCallback; |
| 32 |
| 31 ~ViewManager(); | 33 ~ViewManager(); |
| 32 | 34 |
| 33 // |ready_callback| is run when the ViewManager connection is established | 35 // |ready_callback| is run when the ViewManager connection is established |
| 34 // and ready to use. | 36 // and ready to use. |
| 35 static void Create( | 37 static void Create( |
| 36 Application* application, | 38 Application* application, |
| 37 const base::Callback<void(ViewManager*)>& root_added_callback); | 39 const RootCallback& root_added_callback, |
| 40 const RootCallback& root_removed_callback); |
| 38 // Blocks until ViewManager is ready to use. | 41 // Blocks until ViewManager is ready to use. |
| 39 static ViewManager* CreateBlocking( | 42 static ViewManager* CreateBlocking(Application* application); |
| 40 Application* application, | |
| 41 const base::Callback<void(ViewManager*)>& root_added_callback); | |
| 42 | 43 |
| 43 const std::vector<ViewTreeNode*>& roots() { return roots_; } | 44 const std::vector<ViewTreeNode*>& roots() { return roots_; } |
| 44 | 45 |
| 45 ViewTreeNode* GetNodeById(TransportNodeId id); | 46 ViewTreeNode* GetNodeById(TransportNodeId id); |
| 46 View* GetViewById(TransportViewId id); | 47 View* GetViewById(TransportViewId id); |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 friend class ViewManagerPrivate; | 50 friend class ViewManagerPrivate; |
| 50 typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; | 51 typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; |
| 51 typedef std::map<TransportViewId, View*> IdToViewMap; | 52 typedef std::map<TransportViewId, View*> IdToViewMap; |
| 52 | 53 |
| 53 ViewManager(Application* application, | 54 ViewManager(Application* application, |
| 54 const base::Callback<void(ViewManager*)>& root_added_callback); | 55 const RootCallback& root_added_callback, |
| 56 const RootCallback& root_removed_callback); |
| 55 | 57 |
| 56 base::Callback<void(ViewManager*)> root_added_callback_; | 58 RootCallback root_added_callback_; |
| 59 RootCallback root_removed_callback_; |
| 57 | 60 |
| 58 ViewManagerSynchronizer* synchronizer_; | 61 ViewManagerSynchronizer* synchronizer_; |
| 59 | 62 |
| 60 std::vector<ViewTreeNode*> roots_; | 63 std::vector<ViewTreeNode*> roots_; |
| 61 | 64 |
| 62 IdToNodeMap nodes_; | 65 IdToNodeMap nodes_; |
| 63 IdToViewMap views_; | 66 IdToViewMap views_; |
| 64 | 67 |
| 65 DISALLOW_COPY_AND_ASSIGN(ViewManager); | 68 DISALLOW_COPY_AND_ASSIGN(ViewManager); |
| 66 }; | 69 }; |
| 67 | 70 |
| 68 } // namespace view_manager | 71 } // namespace view_manager |
| 69 } // namespace mojo | 72 } // namespace mojo |
| 70 | 73 |
| 71 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ | 74 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ |
| OLD | NEW |