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

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

Powered by Google App Engine
This is Rietveld 408576698