Chromium Code Reviews| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "mojo/public/cpp/bindings/callback.h" | 13 #include "mojo/public/cpp/bindings/callback.h" |
| 14 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" | 14 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 class Application; | 17 class Application; |
| 18 namespace view_manager { | 18 namespace view_manager { |
| 19 | 19 |
| 20 class View; | 20 class View; |
| 21 class ViewManagerSynchronizer; | 21 class ViewManagerSynchronizer; |
| 22 class ViewTreeNode; | 22 class ViewTreeNode; |
| 23 | 23 |
| 24 class ViewManagerDelegate { | |
|
sky
2014/06/06 20:02:07
nit: move into its own file.
| |
| 25 public: | |
| 26 virtual void OnRootAdded(ViewManager* view_manager, ViewTreeNode* root) {} | |
| 27 virtual void OnRootRemoved(ViewManager* view_manager, ViewTreeNode* root) {} | |
| 28 | |
| 29 protected: | |
| 30 virtual ~ViewManagerDelegate() {} | |
| 31 }; | |
| 32 | |
| 24 // Approximately encapsulates the View Manager service. | 33 // Approximately encapsulates the View Manager service. |
| 25 // Has a synchronizer that keeps a client model in sync with the service. | 34 // Has a synchronizer that keeps a client model in sync with the service. |
| 26 // Owned by the connection. | 35 // Owned by the connection. |
| 27 // | |
| 28 // TODO: displays | |
| 29 class ViewManager { | 36 class ViewManager { |
|
Ben Goodger (Google)
2014/06/06 19:55:46
I think that after this change, it may make most s
| |
| 30 public: | 37 public: |
| 31 typedef base::Callback<void(ViewManager*, ViewTreeNode*)> RootCallback; | |
| 32 | |
| 33 ~ViewManager(); | 38 ~ViewManager(); |
| 34 | 39 |
| 35 // |ready_callback| is run when the ViewManager connection is established | 40 // Delegate is owned by the caller. |
| 36 // and ready to use. | 41 static void Create(Application* application, ViewManagerDelegate* delegate); |
| 37 static void Create( | |
| 38 Application* application, | |
| 39 const RootCallback& root_added_callback, | |
| 40 const RootCallback& root_removed_callback); | |
| 41 // Blocks until ViewManager is ready to use. | |
| 42 static ViewManager* CreateBlocking(Application* application); | |
| 43 | 42 |
| 44 const std::vector<ViewTreeNode*>& roots() { return roots_; } | 43 const std::vector<ViewTreeNode*>& roots() { return roots_; } |
| 45 | 44 |
| 46 ViewTreeNode* GetNodeById(TransportNodeId id); | 45 ViewTreeNode* GetNodeById(TransportNodeId id); |
| 47 View* GetViewById(TransportViewId id); | 46 View* GetViewById(TransportViewId id); |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 friend class ViewManagerPrivate; | 49 friend class ViewManagerPrivate; |
| 50 friend class ViewManagerSynchronizer; | |
| 51 | |
| 51 typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; | 52 typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; |
| 52 typedef std::map<TransportViewId, View*> IdToViewMap; | 53 typedef std::map<TransportViewId, View*> IdToViewMap; |
| 54 typedef std::map<TransportConnectionId, | |
| 55 ViewManagerSynchronizer*> SynchronizerMap; | |
| 53 | 56 |
| 54 ViewManager(Application* application, | 57 ViewManager(ViewManagerSynchronizer* synchronizer, |
| 55 const RootCallback& root_added_callback, | 58 ViewManagerDelegate* delegate); |
| 56 const RootCallback& root_removed_callback); | |
| 57 | 59 |
| 58 RootCallback root_added_callback_; | 60 ViewManagerDelegate* delegate_; |
| 59 RootCallback root_removed_callback_; | |
| 60 | |
| 61 ViewManagerSynchronizer* synchronizer_; | 61 ViewManagerSynchronizer* synchronizer_; |
| 62 | 62 |
| 63 std::vector<ViewTreeNode*> roots_; | 63 std::vector<ViewTreeNode*> roots_; |
| 64 | 64 |
| 65 IdToNodeMap nodes_; | 65 IdToNodeMap nodes_; |
| 66 IdToViewMap views_; | 66 IdToViewMap views_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ViewManager); | 68 DISALLOW_COPY_AND_ASSIGN(ViewManager); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 } // namespace view_manager | 71 } // namespace view_manager |
| 72 } // namespace mojo | 72 } // namespace mojo |
| 73 | 73 |
| 74 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ | 74 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ |
| OLD | NEW |