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

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

Issue 720883003: Adds a CloneAndAnimate function to WindowManagerInternalClient (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add GetView(ClonedViewId) coverage Created 6 years, 1 month 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 | « mojo/services/view_manager/BUILD.gn ('k') | mojo/services/view_manager/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 MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ 6 #define MOJO_SERVICES_VIEW_MANAGER_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 "mojo/public/cpp/bindings/array.h" 14 #include "mojo/public/cpp/bindings/array.h"
14 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
15 #include "mojo/services/public/interfaces/window_manager/window_manager_internal .mojom.h" 16 #include "mojo/services/public/interfaces/window_manager/window_manager_internal .mojom.h"
16 #include "mojo/services/view_manager/ids.h" 17 #include "mojo/services/view_manager/ids.h"
17 #include "mojo/services/view_manager/server_view.h"
18 #include "mojo/services/view_manager/server_view_delegate.h" 18 #include "mojo/services/view_manager/server_view_delegate.h"
19 19
20 namespace mojo { 20 namespace mojo {
21 namespace service { 21 namespace service {
22 22
23 class ClientConnection; 23 class ClientConnection;
24 class ConnectionManagerDelegate; 24 class ConnectionManagerDelegate;
25 class DisplayManager; 25 class DisplayManager;
26 class ServerView;
26 class ViewManagerServiceImpl; 27 class ViewManagerServiceImpl;
27 28
28 // ConnectionManager manages the set of connections to the ViewManager (all the 29 // ConnectionManager manages the set of connections to the ViewManager (all the
29 // ViewManagerServiceImpls) as well as providing the root of the hierarchy. 30 // ViewManagerServiceImpls) as well as providing the root of the hierarchy.
30 class ConnectionManager : public ServerViewDelegate, 31 class ConnectionManager : public ServerViewDelegate,
31 public WindowManagerInternalClient { 32 public WindowManagerInternalClient {
32 public: 33 public:
33 // Create when a ViewManagerServiceImpl is about to make a change. Ensures 34 // Create when a ViewManagerServiceImpl is about to make a change. Ensures
34 // clients are notified correctly. 35 // clients are notified correctly.
35 class ScopedChange { 36 class ScopedChange {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 // Returns the id for the next ViewManagerServiceImpl. 72 // Returns the id for the next ViewManagerServiceImpl.
72 ConnectionSpecificId GetAndAdvanceNextConnectionId(); 73 ConnectionSpecificId GetAndAdvanceNextConnectionId();
73 74
74 // Invoked when a ViewManagerServiceImpl's connection encounters an error. 75 // Invoked when a ViewManagerServiceImpl's connection encounters an error.
75 void OnConnectionError(ClientConnection* connection); 76 void OnConnectionError(ClientConnection* connection);
76 77
77 // See description of ViewManagerService::Embed() for details. This assumes 78 // See description of ViewManagerService::Embed() for details. This assumes
78 // |transport_view_id| is valid. 79 // |transport_view_id| is valid.
79 void EmbedAtView(ConnectionSpecificId creator_id, 80 void EmbedAtView(ConnectionSpecificId creator_id,
80 const String& url, 81 const std::string& url,
81 Id transport_view_id, 82 const ViewId& view_id,
82 InterfaceRequest<ServiceProvider> service_provider); 83 InterfaceRequest<ServiceProvider> service_provider);
83 84
84 // Returns the connection by id. 85 // Returns the connection by id.
85 ViewManagerServiceImpl* GetConnection(ConnectionSpecificId connection_id); 86 ViewManagerServiceImpl* GetConnection(ConnectionSpecificId connection_id);
86 87
87 // Returns the View identified by |id|. 88 // Returns the View identified by |id|.
88 ServerView* GetView(const ViewId& id); 89 ServerView* GetView(const ViewId& id);
89 90
90 ServerView* root() { return root_.get(); } 91 ServerView* root() { return root_.get(); }
91 92
(...skipping 18 matching lines...) Expand all
110 const ViewManagerServiceImpl* GetConnectionWithRoot(const ViewId& id) const; 111 const ViewManagerServiceImpl* GetConnectionWithRoot(const ViewId& id) const;
111 112
112 WindowManagerInternal* wm_internal() { return wm_internal_; } 113 WindowManagerInternal* wm_internal() { return wm_internal_; }
113 114
114 void SetWindowManagerClientConnection( 115 void SetWindowManagerClientConnection(
115 scoped_ptr<ClientConnection> connection); 116 scoped_ptr<ClientConnection> connection);
116 bool has_window_manager_client_connection() const { 117 bool has_window_manager_client_connection() const {
117 return window_manager_client_connection_ != nullptr; 118 return window_manager_client_connection_ != nullptr;
118 } 119 }
119 120
121 // WindowManagerInternalClient implementation helper; see mojom for details.
122 bool CloneAndAnimate(const ViewId& view_id);
123
120 // These functions trivially delegate to all ViewManagerServiceImpls, which in 124 // These functions trivially delegate to all ViewManagerServiceImpls, which in
121 // term notify their clients. 125 // term notify their clients.
122 void ProcessViewDestroyed(ServerView* view); 126 void ProcessViewDestroyed(ServerView* view);
123 void ProcessViewBoundsChanged(const ServerView* view, 127 void ProcessViewBoundsChanged(const ServerView* view,
124 const gfx::Rect& old_bounds, 128 const gfx::Rect& old_bounds,
125 const gfx::Rect& new_bounds); 129 const gfx::Rect& new_bounds);
126 void ProcessWillChangeViewHierarchy(const ServerView* view, 130 void ProcessWillChangeViewHierarchy(const ServerView* view,
127 const ServerView* new_parent, 131 const ServerView* new_parent,
128 const ServerView* old_parent); 132 const ServerView* old_parent);
129 void ProcessViewHierarchyChanged(const ServerView* view, 133 void ProcessViewHierarchyChanged(const ServerView* view,
(...skipping 19 matching lines...) Expand all
149 void FinishChange(); 153 void FinishChange();
150 154
151 // Returns true if the specified connection originated the current change. 155 // Returns true if the specified connection originated the current change.
152 bool IsChangeSource(ConnectionSpecificId connection_id) const { 156 bool IsChangeSource(ConnectionSpecificId connection_id) const {
153 return current_change_ && current_change_->connection_id() == connection_id; 157 return current_change_ && current_change_->connection_id() == connection_id;
154 } 158 }
155 159
156 // Adds |connection| to internal maps. 160 // Adds |connection| to internal maps.
157 void AddConnection(ClientConnection* connection); 161 void AddConnection(ClientConnection* connection);
158 162
163 // Callback from animation timer.
164 // TODO(sky): make this real (move to a different class).
165 void DoAnimation();
166
159 // Overridden from ServerViewDelegate: 167 // Overridden from ServerViewDelegate:
168 void OnWillDestroyView(ServerView* view) override;
160 void OnViewDestroyed(const ServerView* view) override; 169 void OnViewDestroyed(const ServerView* view) override;
161 void OnWillChangeViewHierarchy(const ServerView* view, 170 void OnWillChangeViewHierarchy(ServerView* view,
162 const ServerView* new_parent, 171 ServerView* new_parent,
163 const ServerView* old_parent) override; 172 ServerView* old_parent) override;
164 void OnViewHierarchyChanged(const ServerView* view, 173 void OnViewHierarchyChanged(const ServerView* view,
165 const ServerView* new_parent, 174 const ServerView* new_parent,
166 const ServerView* old_parent) override; 175 const ServerView* old_parent) override;
167 void OnViewBoundsChanged(const ServerView* view, 176 void OnViewBoundsChanged(const ServerView* view,
168 const gfx::Rect& old_bounds, 177 const gfx::Rect& old_bounds,
169 const gfx::Rect& new_bounds) override; 178 const gfx::Rect& new_bounds) override;
170 void OnViewSurfaceIdChanged(const ServerView* view) override; 179 void OnViewSurfaceIdChanged(const ServerView* view) override;
171 void OnViewReordered(const ServerView* view, 180 void OnViewReordered(const ServerView* view,
172 const ServerView* relative, 181 const ServerView* relative,
173 OrderDirection direction) override; 182 OrderDirection direction) override;
174 void OnWillChangeViewVisibility(const ServerView* view) override; 183 void OnWillChangeViewVisibility(ServerView* view) override;
175 void OnViewSharedPropertyChanged( 184 void OnViewSharedPropertyChanged(
176 const ServerView* view, 185 const ServerView* view,
177 const std::string& name, 186 const std::string& name,
178 const std::vector<uint8_t>* new_data) override; 187 const std::vector<uint8_t>* new_data) override;
188 void OnScheduleViewPaint(const ServerView* view) override;
179 189
180 // WindowManagerInternalClient: 190 // WindowManagerInternalClient:
181 void DispatchInputEventToView(Id transport_view_id, 191 void DispatchInputEventToView(Id transport_view_id, EventPtr event) override;
182 EventPtr event) override;
183 void SetViewportSize(SizePtr size) override; 192 void SetViewportSize(SizePtr size) override;
193 void CloneAndAnimate(Id transport_view_id) override;
184 194
185 ConnectionManagerDelegate* delegate_; 195 ConnectionManagerDelegate* delegate_;
186 196
187 // The ClientConnection containing the ViewManagerService implementation 197 // The ClientConnection containing the ViewManagerService implementation
188 // provided to the initial connection (the WindowManager). 198 // provided to the initial connection (the WindowManager).
189 // NOTE: |window_manager_client_connection_| is also in |connection_map_|. 199 // NOTE: |window_manager_client_connection_| is also in |connection_map_|.
190 ClientConnection* window_manager_client_connection_; 200 ClientConnection* window_manager_client_connection_;
191 201
192 // ID to use for next ViewManagerServiceImpl. 202 // ID to use for next ViewManagerServiceImpl.
193 ConnectionSpecificId next_connection_id_; 203 ConnectionSpecificId next_connection_id_;
194 204
195 // Set of ViewManagerServiceImpls. 205 // Set of ViewManagerServiceImpls.
196 ConnectionMap connection_map_; 206 ConnectionMap connection_map_;
197 207
198 scoped_ptr<DisplayManager> display_manager_; 208 scoped_ptr<DisplayManager> display_manager_;
199 209
200 scoped_ptr<ServerView> root_; 210 scoped_ptr<ServerView> root_;
201 211
202 WindowManagerInternal* wm_internal_; 212 WindowManagerInternal* wm_internal_;
203 213
204 // If non-null we're processing a change. The ScopedChange is not owned by us 214 // If non-null we're processing a change. The ScopedChange is not owned by us
205 // (it's created on the stack by ViewManagerServiceImpl). 215 // (it's created on the stack by ViewManagerServiceImpl).
206 ScopedChange* current_change_; 216 ScopedChange* current_change_;
207 217
208 bool in_destructor_; 218 bool in_destructor_;
209 219
220 // TODO(sky): nuke! Just a proof of concept until get real animation api.
221 base::RepeatingTimer<ConnectionManager> animation_timer_;
222
210 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 223 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
211 }; 224 };
212 225
213 } // namespace service 226 } // namespace service
214 } // namespace mojo 227 } // namespace mojo
215 228
216 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ 229 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/services/view_manager/BUILD.gn ('k') | mojo/services/view_manager/connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698