Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: mojo/services/view_manager/root_node_manager.h

Issue 267293004: Wires up view manager to an actual display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/services/view_manager/node.cc ('k') | mojo/services/view_manager/root_node_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ 6 #define MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "mojo/services/native_viewport/native_viewport.mojom.h"
12 #include "mojo/services/view_manager/ids.h" 11 #include "mojo/services/view_manager/ids.h"
13 #include "mojo/services/view_manager/node.h" 12 #include "mojo/services/view_manager/node.h"
14 #include "mojo/services/view_manager/node_delegate.h" 13 #include "mojo/services/view_manager/node_delegate.h"
14 #include "mojo/services/view_manager/root_view_manager.h"
15 #include "mojo/services/view_manager/view_manager_export.h" 15 #include "mojo/services/view_manager/view_manager_export.h"
16 16
17 namespace mojo { 17 namespace mojo {
18
19 class Shell;
20
18 namespace services { 21 namespace services {
19 namespace view_manager { 22 namespace view_manager {
20 23
21 class View; 24 class View;
22 class ViewManagerConnection; 25 class ViewManagerConnection;
23 26
24 // RootNodeManager is responsible for managing the set of ViewManagerConnections 27 // RootNodeManager is responsible for managing the set of ViewManagerConnections
25 // as well as providing the root of the node hierarchy. 28 // as well as providing the root of the node hierarchy.
26 class MOJO_VIEW_MANAGER_EXPORT RootNodeManager 29 class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate {
27 : public NativeViewportClient,
28 public NodeDelegate {
29 public: 30 public:
30 // Create when a ViewManagerConnection is about to make a change. Ensures 31 // Create when a ViewManagerConnection is about to make a change. Ensures
31 // clients are notified of the correct change id. 32 // clients are notified of the correct change id.
32 class ScopedChange { 33 class ScopedChange {
33 public: 34 public:
34 ScopedChange(ViewManagerConnection* connection, 35 ScopedChange(ViewManagerConnection* connection,
35 RootNodeManager* root, 36 RootNodeManager* root,
36 TransportChangeId change_id); 37 TransportChangeId change_id);
37 ~ScopedChange(); 38 ~ScopedChange();
38 39
39 private: 40 private:
40 RootNodeManager* root_; 41 RootNodeManager* root_;
41 42
42 DISALLOW_COPY_AND_ASSIGN(ScopedChange); 43 DISALLOW_COPY_AND_ASSIGN(ScopedChange);
43 }; 44 };
44 45
45 RootNodeManager(); 46 explicit RootNodeManager(Shell* shell);
46 virtual ~RootNodeManager(); 47 virtual ~RootNodeManager();
47 48
48 // Returns the id for the next ViewManagerConnection. 49 // Returns the id for the next ViewManagerConnection.
49 TransportConnectionId GetAndAdvanceNextConnectionId(); 50 TransportConnectionId GetAndAdvanceNextConnectionId();
50 51
51 void AddConnection(ViewManagerConnection* connection); 52 void AddConnection(ViewManagerConnection* connection);
52 void RemoveConnection(ViewManagerConnection* connection); 53 void RemoveConnection(ViewManagerConnection* connection);
53 54
54 // Returns the connection by id. 55 // Returns the connection by id.
55 ViewManagerConnection* GetConnection(TransportConnectionId connection_id); 56 ViewManagerConnection* GetConnection(TransportConnectionId connection_id);
56 57
57 // Returns the Node identified by |id|. 58 // Returns the Node identified by |id|.
58 Node* GetNode(const NodeId& id); 59 Node* GetNode(const NodeId& id);
59 60
60 // Returns the View identified by |id|. 61 // Returns the View identified by |id|.
61 View* GetView(const ViewId& id); 62 View* GetView(const ViewId& id);
62 63
64 Node* root() { return &root_; }
65
63 // These functions trivially delegate to all ViewManagerConnections, which in 66 // These functions trivially delegate to all ViewManagerConnections, which in
64 // term notify their clients. 67 // term notify their clients.
65 void NotifyNodeHierarchyChanged(const NodeId& node, 68 void NotifyNodeHierarchyChanged(const NodeId& node,
66 const NodeId& new_parent, 69 const NodeId& new_parent,
67 const NodeId& old_parent); 70 const NodeId& old_parent);
68 void NotifyNodeViewReplaced(const NodeId& node, 71 void NotifyNodeViewReplaced(const NodeId& node,
69 const ViewId& new_view_id, 72 const ViewId& new_view_id,
70 const ViewId& old_view_id); 73 const ViewId& old_view_id);
71 74
72 private: 75 private:
76 // Used to setup any static state needed by RootNodeManager.
77 struct Context {
78 Context();
79 ~Context();
80 };
81
73 // Tracks a change. 82 // Tracks a change.
74 struct Change { 83 struct Change {
75 Change(TransportConnectionId connection_id, TransportChangeId change_id) 84 Change(TransportConnectionId connection_id, TransportChangeId change_id)
76 : connection_id(connection_id), 85 : connection_id(connection_id),
77 change_id(change_id) { 86 change_id(change_id) {
78 } 87 }
79 88
80 TransportConnectionId connection_id; 89 TransportConnectionId connection_id;
81 TransportChangeId change_id; 90 TransportChangeId change_id;
82 }; 91 };
83 92
84 typedef std::map<TransportConnectionId, ViewManagerConnection*> ConnectionMap; 93 typedef std::map<TransportConnectionId, ViewManagerConnection*> ConnectionMap;
85 94
86 // Invoked when a particular connection is about to make a change. Records 95 // Invoked when a particular connection is about to make a change. Records
87 // the |change_id| so that it can be supplied to the clients by way of 96 // the |change_id| so that it can be supplied to the clients by way of
88 // OnNodeHierarchyChanged(). 97 // OnNodeHierarchyChanged().
89 // Changes should never nest, meaning each PrepareForChange() must be 98 // Changes should never nest, meaning each PrepareForChange() must be
90 // balanced with a call to FinishChange() with no PrepareForChange() 99 // balanced with a call to FinishChange() with no PrepareForChange()
91 // in between. 100 // in between.
92 void PrepareForChange(ViewManagerConnection* connection, 101 void PrepareForChange(ViewManagerConnection* connection,
93 TransportChangeId change_id); 102 TransportChangeId change_id);
94 103
95 // Balances a call to PrepareForChange(). 104 // Balances a call to PrepareForChange().
96 void FinishChange(); 105 void FinishChange();
97 106
98 // Overridden from NativeViewportClient:
99 virtual void OnCreated() OVERRIDE;
100 virtual void OnDestroyed() OVERRIDE;
101 virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE;
102 virtual void OnEvent(const Event& event,
103 const mojo::Callback<void()>& callback) OVERRIDE;
104
105 // Overriden from NodeDelegate: 107 // Overriden from NodeDelegate:
106 virtual void OnNodeHierarchyChanged(const NodeId& node, 108 virtual void OnNodeHierarchyChanged(const NodeId& node,
107 const NodeId& new_parent, 109 const NodeId& new_parent,
108 const NodeId& old_parent) OVERRIDE; 110 const NodeId& old_parent) OVERRIDE;
109 virtual void OnNodeViewReplaced(const NodeId& node, 111 virtual void OnNodeViewReplaced(const NodeId& node,
110 const ViewId& new_view_id, 112 const ViewId& new_view_id,
111 const ViewId& old_view_id) OVERRIDE; 113 const ViewId& old_view_id) OVERRIDE;
112 114
115 Context context_;
116
113 // ID to use for next ViewManagerConnection. 117 // ID to use for next ViewManagerConnection.
114 TransportConnectionId next_connection_id_; 118 TransportConnectionId next_connection_id_;
115 119
116 // Set of ViewManagerConnections. 120 // Set of ViewManagerConnections.
117 ConnectionMap connection_map_; 121 ConnectionMap connection_map_;
118 122
123 // If non-null we're processing a change.
124 scoped_ptr<Change> change_;
125
126 RootViewManager root_view_manager_;
127
119 // Root node. 128 // Root node.
120 Node root_; 129 Node root_;
121 130
122 // If non-null we're processing a change.
123 scoped_ptr<Change> change_;
124
125 DISALLOW_COPY_AND_ASSIGN(RootNodeManager); 131 DISALLOW_COPY_AND_ASSIGN(RootNodeManager);
126 }; 132 };
127 133
128 } // namespace view_manager 134 } // namespace view_manager
129 } // namespace services 135 } // namespace services
130 } // namespace mojo 136 } // namespace mojo
131 137
132 #endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ 138 #endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/services/view_manager/node.cc ('k') | mojo/services/view_manager/root_node_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698