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

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

Issue 288313002: Tweaks to ViewManager: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup 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
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_VIEW_MANAGER_CONNECTION_H_ 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ 6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/containers/hash_tables.h"
12 #include "mojo/public/cpp/shell/service.h" 14 #include "mojo/public/cpp/shell/service.h"
13 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
14 #include "mojo/services/view_manager/ids.h" 16 #include "mojo/services/view_manager/ids.h"
15 #include "mojo/services/view_manager/node_delegate.h" 17 #include "mojo/services/view_manager/node_delegate.h"
16 #include "mojo/services/view_manager/view_manager_export.h" 18 #include "mojo/services/view_manager/view_manager_export.h"
17 19
18 namespace mojo { 20 namespace mojo {
19 namespace view_manager { 21 namespace view_manager {
20 namespace service { 22 namespace service {
21 23
(...skipping 21 matching lines...) Expand all
43 45
44 // Invoked when connection is established. 46 // Invoked when connection is established.
45 void Initialize(); 47 void Initialize();
46 48
47 // Returns the Node with the specified id. 49 // Returns the Node with the specified id.
48 Node* GetNode(const NodeId& id); 50 Node* GetNode(const NodeId& id);
49 51
50 // Returns the View with the specified id. 52 // Returns the View with the specified id.
51 View* GetView(const ViewId& id); 53 View* GetView(const ViewId& id);
52 54
53 // Notifies the client of a hierarchy change. 55 // The following methods are invoked after the corresponding change has been
54 void NotifyNodeHierarchyChanged(const NodeId& node, 56 // processed. They do the appropriate bookkeeping and update the client as
55 const NodeId& new_parent, 57 // necessary.
56 const NodeId& old_parent, 58 // TODO(sky): convert these to take Node*s.
57 TransportChangeId server_change_id); 59 void ProcessNodeHierarchyChanged(const NodeId& node_id,
58 void NotifyNodeViewReplaced(const NodeId& node, 60 const NodeId& new_parent_id,
59 const ViewId& new_view_id, 61 const NodeId& old_parent_id,
60 const ViewId& old_view_id); 62 TransportChangeId server_change_id,
61 void NotifyNodeDeleted(const NodeId& node, 63 bool originated_change);
62 TransportChangeId server_change_id); 64 void ProcessNodeViewReplaced(const NodeId& node,
63 void NotifyViewDeleted(const ViewId& view); 65 const ViewId& new_view_id,
66 const ViewId& old_view_id,
67 bool originated_change);
68 void ProcessNodeDeleted(const NodeId& node,
69 TransportChangeId server_change_id,
70 bool originated_change);
71 void ProcessViewDeleted(const ViewId& view, bool originated_change);
64 72
65 private: 73 private:
66 typedef std::map<TransportConnectionSpecificNodeId, Node*> NodeMap; 74 typedef std::map<TransportConnectionSpecificNodeId, Node*> NodeMap;
67 typedef std::map<TransportConnectionSpecificViewId, View*> ViewMap; 75 typedef std::map<TransportConnectionSpecificViewId, View*> ViewMap;
76 typedef base::hash_set<TransportNodeId> NodeIdSet;
68 77
69 // Deletes a node owned by this connection. Returns true on success. |source| 78 // Deletes a node owned by this connection. Returns true on success. |source|
70 // is the connection that originated the change. 79 // is the connection that originated the change.
71 bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id); 80 bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id);
72 81
73 // Deletes a view owned by this connection. Returns true on success. |source| 82 // Deletes a view owned by this connection. Returns true on success. |source|
74 // is the connection that originated the change. 83 // is the connection that originated the change.
75 bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id); 84 bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id);
76 85
77 // Sets the view associated with a node. 86 // Sets the view associated with a node.
78 bool SetViewImpl(const NodeId& node_id, const ViewId& view_id); 87 bool SetViewImpl(const NodeId& node_id, const ViewId& view_id);
79 88
89 // If |node| is known (in |known_nodes_|) does nothing. Otherwise adds |node|
90 // to |nodes|, marks |node| as known and recurses.
91 void GetUnknownNodesFrom(Node* node, std::vector<Node*>* nodes);
92
93 // Returns true if notification should be sent of a hierarchy change. If true
94 // is returned, any nodes that need to be sent to the client are added to
95 // |to_send|.
96 bool ShouldNotifyOnHierarchyChange(const NodeId& node_id,
97 const NodeId& new_parent_id,
98 const NodeId& old_parent_id,
99 std::vector<Node*>* to_send);
100
80 // Overridden from IViewManager: 101 // Overridden from IViewManager:
81 virtual void CreateNode(TransportNodeId transport_node_id, 102 virtual void CreateNode(TransportNodeId transport_node_id,
82 const Callback<void(bool)>& callback) OVERRIDE; 103 const Callback<void(bool)>& callback) OVERRIDE;
83 virtual void DeleteNode(TransportNodeId transport_node_id, 104 virtual void DeleteNode(TransportNodeId transport_node_id,
84 const Callback<void(bool)>& callback) OVERRIDE; 105 const Callback<void(bool)>& callback) OVERRIDE;
85 virtual void AddNode(TransportNodeId parent_id, 106 virtual void AddNode(TransportNodeId parent_id,
86 TransportNodeId child_id, 107 TransportNodeId child_id,
87 TransportChangeId server_change_id, 108 TransportChangeId server_change_id,
88 const Callback<void(bool)>& callback) OVERRIDE; 109 const Callback<void(bool)>& callback) OVERRIDE;
89 virtual void RemoveNodeFromParent( 110 virtual void RemoveNodeFromParent(
(...skipping 23 matching lines...) Expand all
113 const ViewId& old_view_id) OVERRIDE; 134 const ViewId& old_view_id) OVERRIDE;
114 135
115 // Id of this connection as assigned by RootNodeManager. Assigned in 136 // Id of this connection as assigned by RootNodeManager. Assigned in
116 // Initialize(). 137 // Initialize().
117 TransportConnectionId id_; 138 TransportConnectionId id_;
118 139
119 NodeMap node_map_; 140 NodeMap node_map_;
120 141
121 ViewMap view_map_; 142 ViewMap view_map_;
122 143
144 // The set of nodes that has been communicated to the client.
145 NodeIdSet known_nodes_;
146
123 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); 147 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection);
124 }; 148 };
125 149
126 #if defined(OS_WIN) 150 #if defined(OS_WIN)
127 #pragma warning(pop) 151 #pragma warning(pop)
128 #endif 152 #endif
129 153
130 } // namespace service 154 } // namespace service
131 } // namespace view_manager 155 } // namespace view_manager
132 } // namespace mojo 156 } // namespace mojo
133 157
134 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ 158 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698