Index: mojo/services/public/cpp/view_manager/view_manager.h |
diff --git a/mojo/services/public/cpp/view_manager/view_manager.h b/mojo/services/public/cpp/view_manager/view_manager.h |
index edfe2c1a0e1ff548968bdff77a526a45ff5843f4..34db8e7b7f2b44fadfe904ddf33374522c570ede 100644 |
--- a/mojo/services/public/cpp/view_manager/view_manager.h |
+++ b/mojo/services/public/cpp/view_manager/view_manager.h |
@@ -8,6 +8,7 @@ |
#include <map> |
#include "base/basictypes.h" |
+#include "base/callback.h" |
#include "base/memory/scoped_ptr.h" |
#include "mojo/public/cpp/bindings/callback.h" |
#include "mojo/services/public/cpp/view_manager/view_tree_node.h" |
@@ -27,16 +28,16 @@ class ViewTreeNode; |
// TODO: displays |
class ViewManager { |
public: |
- // Blocks on establishing the connection and subsequently receiving a node |
- // tree from the service. |
- // TODO(beng): blocking is currently achieved by running a nested runloop, |
- // which will dispatch all messages on all pipes while blocking. |
- // we should instead wait on the client pipe receiving a |
- // connection established message. |
- // TODO(beng): this method could optionally not block if supplied a callback. |
- explicit ViewManager(Application* application); |
~ViewManager(); |
+ // |ready_callback| is run when the ViewManager connection is established |
+ // and ready to use. |
+ static void Create( |
+ Application* application, |
+ const base::Callback<void(ViewManager*)> ready_callback); |
+ // Blocks until ViewManager is ready to use. |
+ static ViewManager* CreateBlocking(Application* application); |
+ |
ViewTreeNode* tree() { return tree_; } |
ViewTreeNode* GetNodeById(TransportNodeId id); |
@@ -49,6 +50,11 @@ class ViewManager { |
typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; |
typedef std::map<TransportViewId, View*> IdToViewMap; |
+ ViewManager(Application* application, |
+ const base::Callback<void(ViewManager*)> ready_callback); |
+ |
+ base::Callback<void(ViewManager*)> ready_callback_; |
+ |
ViewManagerSynchronizer* synchronizer_; |
ViewTreeNode* tree_; |