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

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: tweaks 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
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 // Implementation of WindowManagerInternalClient functions. See mojom for
msw 2014/11/18 23:37:42 nit: "WindowManagerInternalClient implementation h
sky 2014/11/19 00:49:39 Done.
122 // details.
123 bool CloneAndAnimate(const ViewId& view_id);
124
120 // These functions trivially delegate to all ViewManagerServiceImpls, which in 125 // These functions trivially delegate to all ViewManagerServiceImpls, which in
121 // term notify their clients. 126 // term notify their clients.
122 void ProcessViewDestroyed(ServerView* view); 127 void ProcessViewDestroyed(ServerView* view);
123 void ProcessViewBoundsChanged(const ServerView* view, 128 void ProcessViewBoundsChanged(const ServerView* view,
124 const gfx::Rect& old_bounds, 129 const gfx::Rect& old_bounds,
125 const gfx::Rect& new_bounds); 130 const gfx::Rect& new_bounds);
126 void ProcessWillChangeViewHierarchy(const ServerView* view, 131 void ProcessWillChangeViewHierarchy(const ServerView* view,
127 const ServerView* new_parent, 132 const ServerView* new_parent,
128 const ServerView* old_parent); 133 const ServerView* old_parent);
129 void ProcessViewHierarchyChanged(const ServerView* view, 134 void ProcessViewHierarchyChanged(const ServerView* view,
(...skipping 19 matching lines...) Expand all
149 void FinishChange(); 154 void FinishChange();
150 155
151 // Returns true if the specified connection originated the current change. 156 // Returns true if the specified connection originated the current change.
152 bool IsChangeSource(ConnectionSpecificId connection_id) const { 157 bool IsChangeSource(ConnectionSpecificId connection_id) const {
153 return current_change_ && current_change_->connection_id() == connection_id; 158 return current_change_ && current_change_->connection_id() == connection_id;
154 } 159 }
155 160
156 // Adds |connection| to internal maps. 161 // Adds |connection| to internal maps.
157 void AddConnection(ClientConnection* connection); 162 void AddConnection(ClientConnection* connection);
158 163
164 // Callback from animation timer.
165 // TODO(sky): make this real (move to a different class).
166 void DoAnimation();
167
159 // Overridden from ServerViewDelegate: 168 // Overridden from ServerViewDelegate:
169 void OnWillDestroyView(ServerView* view) override;
160 void OnViewDestroyed(const ServerView* view) override; 170 void OnViewDestroyed(const ServerView* view) override;
161 void OnWillChangeViewHierarchy(const ServerView* view, 171 void OnWillChangeViewHierarchy(ServerView* view,
162 const ServerView* new_parent, 172 ServerView* new_parent,
163 const ServerView* old_parent) override; 173 ServerView* old_parent) override;
164 void OnViewHierarchyChanged(const ServerView* view, 174 void OnViewHierarchyChanged(const ServerView* view,
165 const ServerView* new_parent, 175 const ServerView* new_parent,
166 const ServerView* old_parent) override; 176 const ServerView* old_parent) override;
167 void OnViewBoundsChanged(const ServerView* view, 177 void OnViewBoundsChanged(const ServerView* view,
168 const gfx::Rect& old_bounds, 178 const gfx::Rect& old_bounds,
169 const gfx::Rect& new_bounds) override; 179 const gfx::Rect& new_bounds) override;
170 void OnViewSurfaceIdChanged(const ServerView* view) override; 180 void OnViewSurfaceIdChanged(const ServerView* view) override;
171 void OnViewReordered(const ServerView* view, 181 void OnViewReordered(const ServerView* view,
172 const ServerView* relative, 182 const ServerView* relative,
173 OrderDirection direction) override; 183 OrderDirection direction) override;
174 void OnWillChangeViewVisibility(const ServerView* view) override; 184 void OnWillChangeViewVisibility(ServerView* view) override;
175 void OnViewSharedPropertyChanged( 185 void OnViewSharedPropertyChanged(
176 const ServerView* view, 186 const ServerView* view,
177 const std::string& name, 187 const std::string& name,
178 const std::vector<uint8_t>* new_data) override; 188 const std::vector<uint8_t>* new_data) override;
189 void OnScheduleViewPaint(const ServerView* view) override;
179 190
180 // WindowManagerInternalClient: 191 // WindowManagerInternalClient:
181 void DispatchInputEventToView(Id transport_view_id, 192 void DispatchInputEventToView(Id transport_view_id, EventPtr event) override;
182 EventPtr event) override;
183 void SetViewportSize(SizePtr size) override; 193 void SetViewportSize(SizePtr size) override;
194 void CloneAndAnimate(Id transport_view_id,
195 const Callback<void(bool)>& callback) override;
184 196
185 ConnectionManagerDelegate* delegate_; 197 ConnectionManagerDelegate* delegate_;
186 198
187 // The ClientConnection containing the ViewManagerService implementation 199 // The ClientConnection containing the ViewManagerService implementation
188 // provided to the initial connection (the WindowManager). 200 // provided to the initial connection (the WindowManager).
189 // NOTE: |window_manager_client_connection_| is also in |connection_map_|. 201 // NOTE: |window_manager_client_connection_| is also in |connection_map_|.
190 ClientConnection* window_manager_client_connection_; 202 ClientConnection* window_manager_client_connection_;
191 203
192 // ID to use for next ViewManagerServiceImpl. 204 // ID to use for next ViewManagerServiceImpl.
193 ConnectionSpecificId next_connection_id_; 205 ConnectionSpecificId next_connection_id_;
194 206
195 // Set of ViewManagerServiceImpls. 207 // Set of ViewManagerServiceImpls.
196 ConnectionMap connection_map_; 208 ConnectionMap connection_map_;
197 209
198 scoped_ptr<DisplayManager> display_manager_; 210 scoped_ptr<DisplayManager> display_manager_;
199 211
200 scoped_ptr<ServerView> root_; 212 scoped_ptr<ServerView> root_;
201 213
202 WindowManagerInternal* wm_internal_; 214 WindowManagerInternal* wm_internal_;
203 215
204 // If non-null we're processing a change. The ScopedChange is not owned by us 216 // If non-null we're processing a change. The ScopedChange is not owned by us
205 // (it's created on the stack by ViewManagerServiceImpl). 217 // (it's created on the stack by ViewManagerServiceImpl).
206 ScopedChange* current_change_; 218 ScopedChange* current_change_;
207 219
208 bool in_destructor_; 220 bool in_destructor_;
209 221
222 // TODO(sky): nuke! Just a proof of concept until get real animation api.
223 base::RepeatingTimer<ConnectionManager> animation_timer_;
224
210 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 225 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
211 }; 226 };
212 227
213 } // namespace service 228 } // namespace service
214 } // namespace mojo 229 } // namespace mojo
215 230
216 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ 231 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698