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

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

Issue 1340983002: Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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 view_manager { 26 namespace mus {
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 mojo::ConnectionSpecificId connection_id() const { return connection_id_; } 49 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(mojo::ConnectionSpecificId connection_id) { 53 void MarkConnectionAsMessaged(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(mojo::ConnectionSpecificId connection_id) const { 58 bool DidMessageConnection(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 mojo::ConnectionSpecificId connection_id_; 64 const 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<mojo::ConnectionSpecificId> message_ids_; 68 std::set<ConnectionSpecificId> message_ids_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(ScopedChange); 70 DISALLOW_COPY_AND_ASSIGN(ScopedChange);
71 }; 71 };
72 72
73 ConnectionManager( 73 ConnectionManager(ConnectionManagerDelegate* delegate,
74 ConnectionManagerDelegate* delegate, 74 const scoped_refptr<SurfacesState>& surfaces_state);
75 const scoped_refptr<surfaces::SurfacesState>& surfaces_state);
76 ~ConnectionManager() override; 75 ~ConnectionManager() override;
77 76
78 // Adds a ViewTreeHost. 77 // Adds a ViewTreeHost.
79 void AddHost(ViewTreeHostConnection* connection); 78 void AddHost(ViewTreeHostConnection* connection);
80 79
81 // Creates a new ServerView. The return value is owned by the caller, but must 80 // Creates a new ServerView. The return value is owned by the caller, but must
82 // be destroyed before ConnectionManager. 81 // be destroyed before ConnectionManager.
83 ServerView* CreateServerView(const ViewId& id); 82 ServerView* CreateServerView(const ViewId& id);
84 83
85 // Returns the id for the next ViewTreeImpl. 84 // Returns the id for the next ViewTreeImpl.
86 mojo::ConnectionSpecificId GetAndAdvanceNextConnectionId(); 85 ConnectionSpecificId GetAndAdvanceNextConnectionId();
87 86
88 // Returns the id for the next ViewTreeHostImpl. 87 // Returns the id for the next ViewTreeHostImpl.
89 uint16_t GetAndAdvanceNextHostId(); 88 uint16_t GetAndAdvanceNextHostId();
90 89
91 // Invoked when a ViewTreeImpl's connection encounters an error. 90 // Invoked when a ViewTreeImpl's connection encounters an error.
92 void OnConnectionError(ClientConnection* connection); 91 void OnConnectionError(ClientConnection* connection);
93 92
94 // Invoked when a ViewTreeHostBindingOwnerBase's connection encounters an 93 // Invoked when a ViewTreeHostBindingOwnerBase's connection encounters an
95 // error or the associated Display window is closed. 94 // error or the associated Display window is closed.
96 void OnHostConnectionClosed(ViewTreeHostConnection* connection); 95 void OnHostConnectionClosed(ViewTreeHostConnection* connection);
97 96
98 // See description of ViewTree::Embed() for details. This assumes 97 // See description of ViewTree::Embed() for details. This assumes
99 // |transport_view_id| is valid. 98 // |transport_view_id| is valid.
100 void EmbedAtView(mojo::ConnectionSpecificId creator_id, 99 void EmbedAtView(ConnectionSpecificId creator_id,
101 const ViewId& view_id, 100 const ViewId& view_id,
102 uint32_t policy_bitmask, 101 uint32_t policy_bitmask,
103 mojo::URLRequestPtr request); 102 mojo::URLRequestPtr request);
104 ViewTreeImpl* EmbedAtView(mojo::ConnectionSpecificId creator_id, 103 ViewTreeImpl* EmbedAtView(ConnectionSpecificId creator_id,
105 const ViewId& view_id, 104 const ViewId& view_id,
106 uint32_t policy_bitmask, 105 uint32_t policy_bitmask,
107 mojo::ViewTreeClientPtr client); 106 mojo::ViewTreeClientPtr client);
108 107
109 // Returns the connection by id. 108 // Returns the connection by id.
110 ViewTreeImpl* GetConnection(mojo::ConnectionSpecificId connection_id); 109 ViewTreeImpl* GetConnection(ConnectionSpecificId connection_id);
111 110
112 // Returns the View identified by |id|. 111 // Returns the View identified by |id|.
113 ServerView* GetView(const ViewId& id); 112 ServerView* GetView(const ViewId& id);
114 113
115 // Returns whether |view| is a descendant of some root view but not itself a 114 // Returns whether |view| is a descendant of some root view but not itself a
116 // root view. 115 // root view.
117 bool IsViewAttachedToRoot(const ServerView* view) const; 116 bool IsViewAttachedToRoot(const ServerView* view) const;
118 117
119 // Schedules a paint for the specified region in the coordinates of |view|. 118 // Schedules a paint for the specified region in the coordinates of |view|.
120 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds); 119 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds);
121 120
122 bool IsProcessingChange() const { return current_change_ != NULL; } 121 bool IsProcessingChange() const { return current_change_ != NULL; }
123 122
124 bool is_processing_delete_view() const { 123 bool is_processing_delete_view() const {
125 return current_change_ && current_change_->is_delete_view(); 124 return current_change_ && current_change_->is_delete_view();
126 } 125 }
127 126
128 // Invoked when the ViewTreeHostImpl's display is closed. 127 // Invoked when the ViewTreeHostImpl's display is closed.
129 void OnDisplayClosed(); 128 void OnDisplayClosed();
130 129
131 // Invoked when a connection messages a client about the change. This is used 130 // Invoked when a connection messages a client about the change. This is used
132 // to avoid sending ServerChangeIdAdvanced() unnecessarily. 131 // to avoid sending ServerChangeIdAdvanced() unnecessarily.
133 void OnConnectionMessagedClient(mojo::ConnectionSpecificId id); 132 void OnConnectionMessagedClient(ConnectionSpecificId id);
134 133
135 // Returns true if OnConnectionMessagedClient() was invoked for id. 134 // Returns true if OnConnectionMessagedClient() was invoked for id.
136 bool DidConnectionMessageClient(mojo::ConnectionSpecificId id) const; 135 bool DidConnectionMessageClient(ConnectionSpecificId id) const;
137 136
138 // Returns the metrics of the viewport where the provided |view| is displayed. 137 // Returns the metrics of the viewport where the provided |view| is displayed.
139 mojo::ViewportMetricsPtr GetViewportMetricsForView(const ServerView* view); 138 mojo::ViewportMetricsPtr GetViewportMetricsForView(const ServerView* view);
140 139
141 // Returns the ViewTreeImpl that has |id| as a root. 140 // Returns the ViewTreeImpl that has |id| as a root.
142 ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) { 141 ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) {
143 return const_cast<ViewTreeImpl*>( 142 return const_cast<ViewTreeImpl*>(
144 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id)); 143 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id));
145 } 144 }
146 const ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) const; 145 const ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) const;
(...skipping 23 matching lines...) Expand all
170 const ServerView* old_parent); 169 const ServerView* old_parent);
171 void ProcessViewHierarchyChanged(const ServerView* view, 170 void ProcessViewHierarchyChanged(const ServerView* view,
172 const ServerView* new_parent, 171 const ServerView* new_parent,
173 const ServerView* old_parent); 172 const ServerView* old_parent);
174 void ProcessViewReorder(const ServerView* view, 173 void ProcessViewReorder(const ServerView* view,
175 const ServerView* relative_view, 174 const ServerView* relative_view,
176 const mojo::OrderDirection direction); 175 const mojo::OrderDirection direction);
177 void ProcessViewDeleted(const ViewId& view); 176 void ProcessViewDeleted(const ViewId& view);
178 177
179 private: 178 private:
180 using ConnectionMap = std::map<mojo::ConnectionSpecificId, ClientConnection*>; 179 using ConnectionMap = std::map<ConnectionSpecificId, ClientConnection*>;
181 using HostConnectionMap = 180 using HostConnectionMap =
182 std::map<ViewTreeHostImpl*, ViewTreeHostConnection*>; 181 std::map<ViewTreeHostImpl*, ViewTreeHostConnection*>;
183 182
184 // Invoked when a connection is about to make a change. Subsequently followed 183 // Invoked when a connection is about to make a change. Subsequently followed
185 // by FinishChange() once the change is done. 184 // by FinishChange() once the change is done.
186 // 185 //
187 // Changes should never nest, meaning each PrepareForChange() must be 186 // Changes should never nest, meaning each PrepareForChange() must be
188 // balanced with a call to FinishChange() with no PrepareForChange() 187 // balanced with a call to FinishChange() with no PrepareForChange()
189 // in between. 188 // in between.
190 void PrepareForChange(ScopedChange* change); 189 void PrepareForChange(ScopedChange* change);
191 190
192 // Balances a call to PrepareForChange(). 191 // Balances a call to PrepareForChange().
193 void FinishChange(); 192 void FinishChange();
194 193
195 // Returns true if the specified connection originated the current change. 194 // Returns true if the specified connection originated the current change.
196 bool IsChangeSource(mojo::ConnectionSpecificId connection_id) const { 195 bool IsChangeSource(ConnectionSpecificId connection_id) const {
197 return current_change_ && current_change_->connection_id() == connection_id; 196 return current_change_ && current_change_->connection_id() == connection_id;
198 } 197 }
199 198
200 // Adds |connection| to internal maps. 199 // Adds |connection| to internal maps.
201 void AddConnection(ClientConnection* connection); 200 void AddConnection(ClientConnection* connection);
202 201
203 // Overridden from ServerViewDelegate: 202 // Overridden from ServerViewDelegate:
204 scoped_ptr<cc::CompositorFrame> UpdateViewTreeFromCompositorFrame( 203 scoped_ptr<cc::CompositorFrame> UpdateViewTreeFromCompositorFrame(
205 const mojo::CompositorFramePtr& input) override; 204 const mojo::CompositorFramePtr& input) override;
206 surfaces::SurfacesState* GetSurfacesState() override; 205 SurfacesState* GetSurfacesState() override;
207 void OnScheduleViewPaint(const ServerView* view) override; 206 void OnScheduleViewPaint(const ServerView* view) override;
208 const ServerView* GetRootView(const ServerView* view) const override; 207 const ServerView* GetRootView(const ServerView* view) const override;
209 208
210 // Overridden from ServerViewObserver: 209 // Overridden from ServerViewObserver:
211 void OnViewDestroyed(ServerView* view) override; 210 void OnViewDestroyed(ServerView* view) override;
212 void OnWillChangeViewHierarchy(ServerView* view, 211 void OnWillChangeViewHierarchy(ServerView* view,
213 ServerView* new_parent, 212 ServerView* new_parent,
214 ServerView* old_parent) override; 213 ServerView* old_parent) override;
215 void OnViewHierarchyChanged(ServerView* view, 214 void OnViewHierarchyChanged(ServerView* view,
216 ServerView* new_parent, 215 ServerView* new_parent,
(...skipping 14 matching lines...) Expand all
231 230
232 // Overriden from CustomSurfaceConverter: 231 // Overriden from CustomSurfaceConverter:
233 bool ConvertSurfaceDrawQuad(const mojo::QuadPtr& input, 232 bool ConvertSurfaceDrawQuad(const mojo::QuadPtr& input,
234 const mojo::CompositorFrameMetadataPtr& metadata, 233 const mojo::CompositorFrameMetadataPtr& metadata,
235 cc::SharedQuadState* sqs, 234 cc::SharedQuadState* sqs,
236 cc::RenderPass* render_pass) override; 235 cc::RenderPass* render_pass) override;
237 236
238 ConnectionManagerDelegate* delegate_; 237 ConnectionManagerDelegate* delegate_;
239 238
240 // State for rendering into a Surface. 239 // State for rendering into a Surface.
241 scoped_refptr<surfaces::SurfacesState> surfaces_state_; 240 scoped_refptr<SurfacesState> surfaces_state_;
242 241
243 // ID to use for next ViewTreeImpl. 242 // ID to use for next ViewTreeImpl.
244 mojo::ConnectionSpecificId next_connection_id_; 243 ConnectionSpecificId next_connection_id_;
245 244
246 // ID to use for next ViewTreeHostImpl. 245 // ID to use for next ViewTreeHostImpl.
247 uint16_t next_host_id_; 246 uint16_t next_host_id_;
248 247
249 // Set of ViewTreeImpls. 248 // Set of ViewTreeImpls.
250 ConnectionMap connection_map_; 249 ConnectionMap connection_map_;
251 250
252 // Set of ViewTreeHostImpls. 251 // Set of ViewTreeHostImpls.
253 HostConnectionMap host_connection_map_; 252 HostConnectionMap host_connection_map_;
254 253
255 // If non-null we're processing a change. The ScopedChange is not owned by us 254 // If non-null we're processing a change. The ScopedChange is not owned by us
256 // (it's created on the stack by ViewTreeImpl). 255 // (it's created on the stack by ViewTreeImpl).
257 ScopedChange* current_change_; 256 ScopedChange* current_change_;
258 257
259 bool in_destructor_; 258 bool in_destructor_;
260 259
261 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 260 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
262 }; 261 };
263 262
264 } // namespace view_manager 263 } // namespace mus
265 264
266 #endif // COMPONENTS_MUS_CONNECTION_MANAGER_H_ 265 #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