| OLD | NEW |
| 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 SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 5 #ifndef SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ |
| 6 #define SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 6 #define 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 "base/timer/timer.h" |
| 14 #include "mojo/public/cpp/bindings/array.h" | 14 #include "mojo/public/cpp/bindings/array.h" |
| 15 #include "mojo/services/view_manager/public/interfaces/view_manager.mojom.h" | 15 #include "mojo/services/view_manager/public/interfaces/view_manager.mojom.h" |
| 16 #include "mojo/services/window_manager/public/interfaces/window_manager_internal
.mojom.h" | 16 #include "mojo/services/window_manager/public/interfaces/window_manager_internal
.mojom.h" |
| 17 #include "services/view_manager/animation_runner.h" | 17 #include "services/view_manager/animation_runner.h" |
| 18 #include "services/view_manager/ids.h" | 18 #include "services/view_manager/ids.h" |
| 19 #include "services/view_manager/server_view_delegate.h" | 19 #include "services/view_manager/server_view_delegate.h" |
| 20 #include "services/view_manager/server_view_observer.h" |
| 20 | 21 |
| 21 namespace view_manager { | 22 namespace view_manager { |
| 22 | 23 |
| 23 class ClientConnection; | 24 class ClientConnection; |
| 24 class ConnectionManagerDelegate; | 25 class ConnectionManagerDelegate; |
| 25 class DisplayManager; | 26 class DisplayManager; |
| 26 class ServerView; | 27 class ServerView; |
| 27 class ViewManagerServiceImpl; | 28 class ViewManagerServiceImpl; |
| 28 | 29 |
| 29 // ConnectionManager manages the set of connections to the ViewManager (all the | 30 // ConnectionManager manages the set of connections to the ViewManager (all the |
| 30 // ViewManagerServiceImpls) as well as providing the root of the hierarchy. | 31 // ViewManagerServiceImpls) as well as providing the root of the hierarchy. |
| 31 class ConnectionManager : public ServerViewDelegate, | 32 class ConnectionManager : public ServerViewDelegate, |
| 33 public ServerViewObserver, |
| 32 public mojo::WindowManagerInternalClient { | 34 public mojo::WindowManagerInternalClient { |
| 33 public: | 35 public: |
| 34 // Create when a ViewManagerServiceImpl is about to make a change. Ensures | 36 // Create when a ViewManagerServiceImpl is about to make a change. Ensures |
| 35 // clients are notified correctly. | 37 // clients are notified correctly. |
| 36 class ScopedChange { | 38 class ScopedChange { |
| 37 public: | 39 public: |
| 38 ScopedChange(ViewManagerServiceImpl* connection, | 40 ScopedChange(ViewManagerServiceImpl* connection, |
| 39 ConnectionManager* connection_manager, | 41 ConnectionManager* connection_manager, |
| 40 bool is_delete_view); | 42 bool is_delete_view); |
| 41 ~ScopedChange(); | 43 ~ScopedChange(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 62 std::set<mojo::ConnectionSpecificId> message_ids_; | 64 std::set<mojo::ConnectionSpecificId> message_ids_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(ScopedChange); | 66 DISALLOW_COPY_AND_ASSIGN(ScopedChange); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 ConnectionManager(ConnectionManagerDelegate* delegate, | 69 ConnectionManager(ConnectionManagerDelegate* delegate, |
| 68 scoped_ptr<DisplayManager> display_manager, | 70 scoped_ptr<DisplayManager> display_manager, |
| 69 mojo::WindowManagerInternal* wm_internal); | 71 mojo::WindowManagerInternal* wm_internal); |
| 70 ~ConnectionManager() override; | 72 ~ConnectionManager() override; |
| 71 | 73 |
| 74 // Creates a new ServerView. The return value is owned by the caller, but must |
| 75 // be destroyed before ConnectionManager. |
| 76 ServerView* CreateServerView(const ViewId& id); |
| 77 |
| 72 // Returns the id for the next ViewManagerServiceImpl. | 78 // Returns the id for the next ViewManagerServiceImpl. |
| 73 mojo::ConnectionSpecificId GetAndAdvanceNextConnectionId(); | 79 mojo::ConnectionSpecificId GetAndAdvanceNextConnectionId(); |
| 74 | 80 |
| 75 // Invoked when a ViewManagerServiceImpl's connection encounters an error. | 81 // Invoked when a ViewManagerServiceImpl's connection encounters an error. |
| 76 void OnConnectionError(ClientConnection* connection); | 82 void OnConnectionError(ClientConnection* connection); |
| 77 | 83 |
| 78 // See description of ViewManagerService::Embed() for details. This assumes | 84 // See description of ViewManagerService::Embed() for details. This assumes |
| 79 // |transport_view_id| is valid. | 85 // |transport_view_id| is valid. |
| 80 void EmbedAtView(mojo::ConnectionSpecificId creator_id, | 86 void EmbedAtView(mojo::ConnectionSpecificId creator_id, |
| 81 const std::string& url, | 87 const std::string& url, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 174 } |
| 169 | 175 |
| 170 // Adds |connection| to internal maps. | 176 // Adds |connection| to internal maps. |
| 171 void AddConnection(ClientConnection* connection); | 177 void AddConnection(ClientConnection* connection); |
| 172 | 178 |
| 173 // Callback from animation timer. | 179 // Callback from animation timer. |
| 174 // TODO(sky): make this real (move to a different class). | 180 // TODO(sky): make this real (move to a different class). |
| 175 void DoAnimation(); | 181 void DoAnimation(); |
| 176 | 182 |
| 177 // Overridden from ServerViewDelegate: | 183 // Overridden from ServerViewDelegate: |
| 178 void OnWillDestroyView(ServerView* view) override; | 184 void PrepareToDestroyView(ServerView* view) override; |
| 185 void PrepareToChangeViewHierarchy(ServerView* view, |
| 186 ServerView* new_parent, |
| 187 ServerView* old_parent) override; |
| 188 void PrepareToChangeViewVisibility(ServerView* view) override; |
| 189 void OnScheduleViewPaint(const ServerView* view) override; |
| 190 |
| 191 // Overridden from ServerViewObserver: |
| 179 void OnViewDestroyed(const ServerView* view) override; | 192 void OnViewDestroyed(const ServerView* view) override; |
| 180 void OnWillChangeViewHierarchy(ServerView* view, | 193 void OnWillChangeViewHierarchy(const ServerView* view, |
| 181 ServerView* new_parent, | 194 const ServerView* new_parent, |
| 182 ServerView* old_parent) override; | 195 const ServerView* old_parent) override; |
| 183 void OnViewHierarchyChanged(const ServerView* view, | 196 void OnViewHierarchyChanged(const ServerView* view, |
| 184 const ServerView* new_parent, | 197 const ServerView* new_parent, |
| 185 const ServerView* old_parent) override; | 198 const ServerView* old_parent) override; |
| 186 void OnViewBoundsChanged(const ServerView* view, | 199 void OnViewBoundsChanged(const ServerView* view, |
| 187 const gfx::Rect& old_bounds, | 200 const gfx::Rect& old_bounds, |
| 188 const gfx::Rect& new_bounds) override; | 201 const gfx::Rect& new_bounds) override; |
| 189 void OnViewSurfaceIdChanged(const ServerView* view) override; | |
| 190 void OnViewReordered(const ServerView* view, | 202 void OnViewReordered(const ServerView* view, |
| 191 const ServerView* relative, | 203 const ServerView* relative, |
| 192 mojo::OrderDirection direction) override; | 204 mojo::OrderDirection direction) override; |
| 193 void OnWillChangeViewVisibility(ServerView* view) override; | 205 void OnWillChangeViewVisibility(const ServerView* view) override; |
| 194 void OnViewSharedPropertyChanged( | 206 void OnViewSharedPropertyChanged( |
| 195 const ServerView* view, | 207 const ServerView* view, |
| 196 const std::string& name, | 208 const std::string& name, |
| 197 const std::vector<uint8_t>* new_data) override; | 209 const std::vector<uint8_t>* new_data) override; |
| 198 void OnScheduleViewPaint(const ServerView* view) override; | |
| 199 | 210 |
| 200 // WindowManagerInternalClient: | 211 // WindowManagerInternalClient: |
| 201 void DispatchInputEventToView(mojo::Id transport_view_id, | 212 void DispatchInputEventToView(mojo::Id transport_view_id, |
| 202 mojo::EventPtr event) override; | 213 mojo::EventPtr event) override; |
| 203 void SetViewportSize(mojo::SizePtr size) override; | 214 void SetViewportSize(mojo::SizePtr size) override; |
| 204 void CloneAndAnimate(mojo::Id transport_view_id) override; | 215 void CloneAndAnimate(mojo::Id transport_view_id) override; |
| 205 | 216 |
| 206 ConnectionManagerDelegate* delegate_; | 217 ConnectionManagerDelegate* delegate_; |
| 207 | 218 |
| 208 // The ClientConnection containing the ViewManagerService implementation | 219 // The ClientConnection containing the ViewManagerService implementation |
| (...skipping 23 matching lines...) Expand all Loading... |
| 232 base::RepeatingTimer<ConnectionManager> animation_timer_; | 243 base::RepeatingTimer<ConnectionManager> animation_timer_; |
| 233 | 244 |
| 234 AnimationRunner animation_runner_; | 245 AnimationRunner animation_runner_; |
| 235 | 246 |
| 236 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); | 247 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
| 237 }; | 248 }; |
| 238 | 249 |
| 239 } // namespace view_manager | 250 } // namespace view_manager |
| 240 | 251 |
| 241 #endif // SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 252 #endif // SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ |
| OLD | NEW |