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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "mojo/public/cpp/bindings/callback.h" | 12 #include "mojo/public/cpp/bindings/callback.h" |
13 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" | 13 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 class Application; | 16 class ServiceProvider; |
17 namespace view_manager { | 17 namespace view_manager { |
18 | 18 |
19 class View; | 19 class View; |
20 class ViewManagerSynchronizer; | 20 class ViewManagerSynchronizer; |
21 class ViewTreeNode; | 21 class ViewTreeNode; |
22 | 22 |
23 // Approximately encapsulates the View Manager service. | 23 // Approximately encapsulates the View Manager service. |
24 // Has a synchronizer that keeps a client model in sync with the service. | 24 // Owns a synchronizer that keeps a client model in sync with the service. |
25 // Owned by the connection. | 25 // Owned by the creator. |
26 // | 26 // |
27 // TODO: displays | 27 // TODO: displays |
28 class ViewManager { | 28 class ViewManager { |
29 public: | 29 public: |
| 30 explicit ViewManager(ServiceProvider* service_provider); |
| 31 ~ViewManager(); |
| 32 |
| 33 // Connects to the View Manager service. This method must be called before |
| 34 // using any other View Manager lib class or function. |
30 // Blocks on establishing the connection and subsequently receiving a node | 35 // Blocks on establishing the connection and subsequently receiving a node |
31 // tree from the service. | 36 // tree from the service. |
32 // TODO(beng): blocking is currently achieved by running a nested runloop, | 37 // TODO(beng): blocking is currently achieved by running a nested runloop, |
33 // which will dispatch all messages on all pipes while blocking. | 38 // which will dispatch all messages on all pipes while blocking. |
34 // we should instead wait on the client pipe receiving a | 39 // we should instead wait on the client pipe receiving a |
35 // connection established message. | 40 // connection established message. |
36 // TODO(beng): this method could optionally not block if supplied a callback. | 41 // TODO(beng): this method could optionally not block if supplied a callback. |
37 explicit ViewManager(Application* application); | 42 void Init(); |
38 ~ViewManager(); | |
39 | 43 |
40 ViewTreeNode* tree() { return tree_; } | 44 ViewTreeNode* tree() { return tree_; } |
41 | 45 |
42 ViewTreeNode* GetNodeById(TransportNodeId id); | 46 ViewTreeNode* GetNodeById(TransportNodeId id); |
43 View* GetViewById(TransportViewId id); | 47 View* GetViewById(TransportViewId id); |
44 | 48 |
45 void Embed(const String& url, ViewTreeNode* node); | |
46 | |
47 private: | 49 private: |
48 friend class ViewManagerPrivate; | 50 friend class ViewManagerPrivate; |
49 typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; | 51 typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; |
50 typedef std::map<TransportViewId, View*> IdToViewMap; | 52 typedef std::map<TransportViewId, View*> IdToViewMap; |
51 | 53 |
52 ViewManagerSynchronizer* synchronizer_; | 54 ServiceProvider* service_provider_; |
| 55 scoped_ptr<ViewManagerSynchronizer> synchronizer_; |
53 ViewTreeNode* tree_; | 56 ViewTreeNode* tree_; |
54 | 57 |
55 IdToNodeMap nodes_; | 58 IdToNodeMap nodes_; |
56 IdToViewMap views_; | 59 IdToViewMap views_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(ViewManager); | 61 DISALLOW_COPY_AND_ASSIGN(ViewManager); |
59 }; | 62 }; |
60 | 63 |
61 } // namespace view_manager | 64 } // namespace view_manager |
62 } // namespace mojo | 65 } // namespace mojo |
63 | 66 |
64 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ | 67 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_ |
OLD | NEW |