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

Side by Side Diff: components/mus/connection_manager.h

Issue 1351013002: Revert of Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « components/mus/client_connection.cc ('k') | components/mus/connection_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 COMPONENTS_MUS_CONNECTION_MANAGER_H_ 5 #ifndef COMPONENTS_MUS_CONNECTION_MANAGER_H_
6 #define COMPONENTS_MUS_CONNECTION_MANAGER_H_ 6 #define COMPONENTS_MUS_CONNECTION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "components/mus/focus_controller_delegate.h" 14 #include "components/mus/focus_controller_delegate.h"
15 #include "components/mus/ids.h" 15 #include "components/mus/ids.h"
16 #include "components/mus/public/interfaces/view_tree.mojom.h" 16 #include "components/mus/public/interfaces/view_tree.mojom.h"
17 #include "components/mus/public/interfaces/view_tree_host.mojom.h" 17 #include "components/mus/public/interfaces/view_tree_host.mojom.h"
18 #include "components/mus/server_view_delegate.h" 18 #include "components/mus/server_view_delegate.h"
19 #include "components/mus/server_view_observer.h" 19 #include "components/mus/server_view_observer.h"
20 #include "components/mus/surfaces/surfaces_state.h" 20 #include "components/mus/surfaces/surfaces_state.h"
21 #include "components/mus/view_tree_host_impl.h" 21 #include "components/mus/view_tree_host_impl.h"
22 #include "mojo/converters/surfaces/custom_surface_converter.h" 22 #include "mojo/converters/surfaces/custom_surface_converter.h"
23 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" 23 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
24 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" 24 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
25 25
26 namespace mus { 26 namespace view_manager {
27 27
28 class ClientConnection; 28 class ClientConnection;
29 class ConnectionManagerDelegate; 29 class ConnectionManagerDelegate;
30 class ServerView; 30 class ServerView;
31 class ViewTreeHostConnection; 31 class ViewTreeHostConnection;
32 class ViewTreeImpl; 32 class ViewTreeImpl;
33 33
34 // ConnectionManager manages the set of connections to the ViewManager (all the 34 // ConnectionManager manages the set of connections to the ViewManager (all the
35 // ViewTreeImpl) as well as providing the root of the hierarchy. 35 // ViewTreeImpl) as well as providing the root of the hierarchy.
36 class ConnectionManager : public ServerViewDelegate, 36 class ConnectionManager : public ServerViewDelegate,
37 public ServerViewObserver, 37 public ServerViewObserver,
38 public mojo::CustomSurfaceConverter { 38 public mojo::CustomSurfaceConverter {
39 public: 39 public:
40 // Create when a ViewTreeImpl is about to make a change. Ensures clients are 40 // Create when a ViewTreeImpl is about to make a change. Ensures clients are
41 // notified correctly. 41 // notified correctly.
42 class ScopedChange { 42 class ScopedChange {
43 public: 43 public:
44 ScopedChange(ViewTreeImpl* connection, 44 ScopedChange(ViewTreeImpl* connection,
45 ConnectionManager* connection_manager, 45 ConnectionManager* connection_manager,
46 bool is_delete_view); 46 bool is_delete_view);
47 ~ScopedChange(); 47 ~ScopedChange();
48 48
49 ConnectionSpecificId connection_id() const { return connection_id_; } 49 mojo::ConnectionSpecificId connection_id() const { return connection_id_; }
50 bool is_delete_view() const { return is_delete_view_; } 50 bool is_delete_view() const { return is_delete_view_; }
51 51
52 // Marks the connection with the specified id as having seen a message. 52 // Marks the connection with the specified id as having seen a message.
53 void MarkConnectionAsMessaged(ConnectionSpecificId connection_id) { 53 void MarkConnectionAsMessaged(mojo::ConnectionSpecificId connection_id) {
54 message_ids_.insert(connection_id); 54 message_ids_.insert(connection_id);
55 } 55 }
56 56
57 // Returns true if MarkConnectionAsMessaged(connection_id) was invoked. 57 // Returns true if MarkConnectionAsMessaged(connection_id) was invoked.
58 bool DidMessageConnection(ConnectionSpecificId connection_id) const { 58 bool DidMessageConnection(mojo::ConnectionSpecificId connection_id) const {
59 return message_ids_.count(connection_id) > 0; 59 return message_ids_.count(connection_id) > 0;
60 } 60 }
61 61
62 private: 62 private:
63 ConnectionManager* connection_manager_; 63 ConnectionManager* connection_manager_;
64 const ConnectionSpecificId connection_id_; 64 const mojo::ConnectionSpecificId connection_id_;
65 const bool is_delete_view_; 65 const bool is_delete_view_;
66 66
67 // See description of MarkConnectionAsMessaged/DidMessageConnection. 67 // See description of MarkConnectionAsMessaged/DidMessageConnection.
68 std::set<ConnectionSpecificId> message_ids_; 68 std::set<mojo::ConnectionSpecificId> message_ids_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(ScopedChange); 70 DISALLOW_COPY_AND_ASSIGN(ScopedChange);
71 }; 71 };
72 72
73 ConnectionManager(ConnectionManagerDelegate* delegate, 73 ConnectionManager(
74 const scoped_refptr<SurfacesState>& surfaces_state); 74 ConnectionManagerDelegate* delegate,
75 const scoped_refptr<surfaces::SurfacesState>& surfaces_state);
75 ~ConnectionManager() override; 76 ~ConnectionManager() override;
76 77
77 // Adds a ViewTreeHost. 78 // Adds a ViewTreeHost.
78 void AddHost(ViewTreeHostConnection* connection); 79 void AddHost(ViewTreeHostConnection* connection);
79 80
80 // Creates a new ServerView. The return value is owned by the caller, but must 81 // Creates a new ServerView. The return value is owned by the caller, but must
81 // be destroyed before ConnectionManager. 82 // be destroyed before ConnectionManager.
82 ServerView* CreateServerView(const ViewId& id); 83 ServerView* CreateServerView(const ViewId& id);
83 84
84 // Returns the id for the next ViewTreeImpl. 85 // Returns the id for the next ViewTreeImpl.
85 ConnectionSpecificId GetAndAdvanceNextConnectionId(); 86 mojo::ConnectionSpecificId GetAndAdvanceNextConnectionId();
86 87
87 // Returns the id for the next ViewTreeHostImpl. 88 // Returns the id for the next ViewTreeHostImpl.
88 uint16_t GetAndAdvanceNextHostId(); 89 uint16_t GetAndAdvanceNextHostId();
89 90
90 // Invoked when a ViewTreeImpl's connection encounters an error. 91 // Invoked when a ViewTreeImpl's connection encounters an error.
91 void OnConnectionError(ClientConnection* connection); 92 void OnConnectionError(ClientConnection* connection);
92 93
93 // Invoked when a ViewTreeHostBindingOwnerBase's connection encounters an 94 // Invoked when a ViewTreeHostBindingOwnerBase's connection encounters an
94 // error or the associated Display window is closed. 95 // error or the associated Display window is closed.
95 void OnHostConnectionClosed(ViewTreeHostConnection* connection); 96 void OnHostConnectionClosed(ViewTreeHostConnection* connection);
96 97
97 // See description of ViewTree::Embed() for details. This assumes 98 // See description of ViewTree::Embed() for details. This assumes
98 // |transport_view_id| is valid. 99 // |transport_view_id| is valid.
99 void EmbedAtView(ConnectionSpecificId creator_id, 100 void EmbedAtView(mojo::ConnectionSpecificId creator_id,
100 const ViewId& view_id, 101 const ViewId& view_id,
101 uint32_t policy_bitmask, 102 uint32_t policy_bitmask,
102 mojo::URLRequestPtr request); 103 mojo::URLRequestPtr request);
103 ViewTreeImpl* EmbedAtView(ConnectionSpecificId creator_id, 104 ViewTreeImpl* EmbedAtView(mojo::ConnectionSpecificId creator_id,
104 const ViewId& view_id, 105 const ViewId& view_id,
105 uint32_t policy_bitmask, 106 uint32_t policy_bitmask,
106 mojo::ViewTreeClientPtr client); 107 mojo::ViewTreeClientPtr client);
107 108
108 // Returns the connection by id. 109 // Returns the connection by id.
109 ViewTreeImpl* GetConnection(ConnectionSpecificId connection_id); 110 ViewTreeImpl* GetConnection(mojo::ConnectionSpecificId connection_id);
110 111
111 // Returns the View identified by |id|. 112 // Returns the View identified by |id|.
112 ServerView* GetView(const ViewId& id); 113 ServerView* GetView(const ViewId& id);
113 114
114 // Returns whether |view| is a descendant of some root view but not itself a 115 // Returns whether |view| is a descendant of some root view but not itself a
115 // root view. 116 // root view.
116 bool IsViewAttachedToRoot(const ServerView* view) const; 117 bool IsViewAttachedToRoot(const ServerView* view) const;
117 118
118 // Schedules a paint for the specified region in the coordinates of |view|. 119 // Schedules a paint for the specified region in the coordinates of |view|.
119 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds); 120 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds);
120 121
121 bool IsProcessingChange() const { return current_change_ != NULL; } 122 bool IsProcessingChange() const { return current_change_ != NULL; }
122 123
123 bool is_processing_delete_view() const { 124 bool is_processing_delete_view() const {
124 return current_change_ && current_change_->is_delete_view(); 125 return current_change_ && current_change_->is_delete_view();
125 } 126 }
126 127
127 // Invoked when the ViewTreeHostImpl's display is closed. 128 // Invoked when the ViewTreeHostImpl's display is closed.
128 void OnDisplayClosed(); 129 void OnDisplayClosed();
129 130
130 // Invoked when a connection messages a client about the change. This is used 131 // Invoked when a connection messages a client about the change. This is used
131 // to avoid sending ServerChangeIdAdvanced() unnecessarily. 132 // to avoid sending ServerChangeIdAdvanced() unnecessarily.
132 void OnConnectionMessagedClient(ConnectionSpecificId id); 133 void OnConnectionMessagedClient(mojo::ConnectionSpecificId id);
133 134
134 // Returns true if OnConnectionMessagedClient() was invoked for id. 135 // Returns true if OnConnectionMessagedClient() was invoked for id.
135 bool DidConnectionMessageClient(ConnectionSpecificId id) const; 136 bool DidConnectionMessageClient(mojo::ConnectionSpecificId id) const;
136 137
137 // Returns the metrics of the viewport where the provided |view| is displayed. 138 // Returns the metrics of the viewport where the provided |view| is displayed.
138 mojo::ViewportMetricsPtr GetViewportMetricsForView(const ServerView* view); 139 mojo::ViewportMetricsPtr GetViewportMetricsForView(const ServerView* view);
139 140
140 // Returns the ViewTreeImpl that has |id| as a root. 141 // Returns the ViewTreeImpl that has |id| as a root.
141 ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) { 142 ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) {
142 return const_cast<ViewTreeImpl*>( 143 return const_cast<ViewTreeImpl*>(
143 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id)); 144 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id));
144 } 145 }
145 const ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) const; 146 const ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) const;
(...skipping 23 matching lines...) Expand all
169 const ServerView* old_parent); 170 const ServerView* old_parent);
170 void ProcessViewHierarchyChanged(const ServerView* view, 171 void ProcessViewHierarchyChanged(const ServerView* view,
171 const ServerView* new_parent, 172 const ServerView* new_parent,
172 const ServerView* old_parent); 173 const ServerView* old_parent);
173 void ProcessViewReorder(const ServerView* view, 174 void ProcessViewReorder(const ServerView* view,
174 const ServerView* relative_view, 175 const ServerView* relative_view,
175 const mojo::OrderDirection direction); 176 const mojo::OrderDirection direction);
176 void ProcessViewDeleted(const ViewId& view); 177 void ProcessViewDeleted(const ViewId& view);
177 178
178 private: 179 private:
179 using ConnectionMap = std::map<ConnectionSpecificId, ClientConnection*>; 180 using ConnectionMap = std::map<mojo::ConnectionSpecificId, ClientConnection*>;
180 using HostConnectionMap = 181 using HostConnectionMap =
181 std::map<ViewTreeHostImpl*, ViewTreeHostConnection*>; 182 std::map<ViewTreeHostImpl*, ViewTreeHostConnection*>;
182 183
183 // Invoked when a connection is about to make a change. Subsequently followed 184 // Invoked when a connection is about to make a change. Subsequently followed
184 // by FinishChange() once the change is done. 185 // by FinishChange() once the change is done.
185 // 186 //
186 // Changes should never nest, meaning each PrepareForChange() must be 187 // Changes should never nest, meaning each PrepareForChange() must be
187 // balanced with a call to FinishChange() with no PrepareForChange() 188 // balanced with a call to FinishChange() with no PrepareForChange()
188 // in between. 189 // in between.
189 void PrepareForChange(ScopedChange* change); 190 void PrepareForChange(ScopedChange* change);
190 191
191 // Balances a call to PrepareForChange(). 192 // Balances a call to PrepareForChange().
192 void FinishChange(); 193 void FinishChange();
193 194
194 // Returns true if the specified connection originated the current change. 195 // Returns true if the specified connection originated the current change.
195 bool IsChangeSource(ConnectionSpecificId connection_id) const { 196 bool IsChangeSource(mojo::ConnectionSpecificId connection_id) const {
196 return current_change_ && current_change_->connection_id() == connection_id; 197 return current_change_ && current_change_->connection_id() == connection_id;
197 } 198 }
198 199
199 // Adds |connection| to internal maps. 200 // Adds |connection| to internal maps.
200 void AddConnection(ClientConnection* connection); 201 void AddConnection(ClientConnection* connection);
201 202
202 // Overridden from ServerViewDelegate: 203 // Overridden from ServerViewDelegate:
203 scoped_ptr<cc::CompositorFrame> UpdateViewTreeFromCompositorFrame( 204 scoped_ptr<cc::CompositorFrame> UpdateViewTreeFromCompositorFrame(
204 const mojo::CompositorFramePtr& input) override; 205 const mojo::CompositorFramePtr& input) override;
205 SurfacesState* GetSurfacesState() override; 206 surfaces::SurfacesState* GetSurfacesState() override;
206 void OnScheduleViewPaint(const ServerView* view) override; 207 void OnScheduleViewPaint(const ServerView* view) override;
207 const ServerView* GetRootView(const ServerView* view) const override; 208 const ServerView* GetRootView(const ServerView* view) const override;
208 209
209 // Overridden from ServerViewObserver: 210 // Overridden from ServerViewObserver:
210 void OnViewDestroyed(ServerView* view) override; 211 void OnViewDestroyed(ServerView* view) override;
211 void OnWillChangeViewHierarchy(ServerView* view, 212 void OnWillChangeViewHierarchy(ServerView* view,
212 ServerView* new_parent, 213 ServerView* new_parent,
213 ServerView* old_parent) override; 214 ServerView* old_parent) override;
214 void OnViewHierarchyChanged(ServerView* view, 215 void OnViewHierarchyChanged(ServerView* view,
215 ServerView* new_parent, 216 ServerView* new_parent,
(...skipping 14 matching lines...) Expand all
230 231
231 // Overriden from CustomSurfaceConverter: 232 // Overriden from CustomSurfaceConverter:
232 bool ConvertSurfaceDrawQuad(const mojo::QuadPtr& input, 233 bool ConvertSurfaceDrawQuad(const mojo::QuadPtr& input,
233 const mojo::CompositorFrameMetadataPtr& metadata, 234 const mojo::CompositorFrameMetadataPtr& metadata,
234 cc::SharedQuadState* sqs, 235 cc::SharedQuadState* sqs,
235 cc::RenderPass* render_pass) override; 236 cc::RenderPass* render_pass) override;
236 237
237 ConnectionManagerDelegate* delegate_; 238 ConnectionManagerDelegate* delegate_;
238 239
239 // State for rendering into a Surface. 240 // State for rendering into a Surface.
240 scoped_refptr<SurfacesState> surfaces_state_; 241 scoped_refptr<surfaces::SurfacesState> surfaces_state_;
241 242
242 // ID to use for next ViewTreeImpl. 243 // ID to use for next ViewTreeImpl.
243 ConnectionSpecificId next_connection_id_; 244 mojo::ConnectionSpecificId next_connection_id_;
244 245
245 // ID to use for next ViewTreeHostImpl. 246 // ID to use for next ViewTreeHostImpl.
246 uint16_t next_host_id_; 247 uint16_t next_host_id_;
247 248
248 // Set of ViewTreeImpls. 249 // Set of ViewTreeImpls.
249 ConnectionMap connection_map_; 250 ConnectionMap connection_map_;
250 251
251 // Set of ViewTreeHostImpls. 252 // Set of ViewTreeHostImpls.
252 HostConnectionMap host_connection_map_; 253 HostConnectionMap host_connection_map_;
253 254
254 // If non-null we're processing a change. The ScopedChange is not owned by us 255 // If non-null we're processing a change. The ScopedChange is not owned by us
255 // (it's created on the stack by ViewTreeImpl). 256 // (it's created on the stack by ViewTreeImpl).
256 ScopedChange* current_change_; 257 ScopedChange* current_change_;
257 258
258 bool in_destructor_; 259 bool in_destructor_;
259 260
260 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 261 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
261 }; 262 };
262 263
263 } // namespace mus 264 } // namespace view_manager
264 265
265 #endif // COMPONENTS_MUS_CONNECTION_MANAGER_H_ 266 #endif // COMPONENTS_MUS_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « components/mus/client_connection.cc ('k') | components/mus/connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698