| 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 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 "mojo/public/cpp/bindings/array.h" | 12 #include "mojo/public/cpp/bindings/array.h" |
| 13 #include "mojo/services/view_manager/display_manager.h" | 13 #include "mojo/services/view_manager/display_manager.h" |
| 14 #include "mojo/services/view_manager/ids.h" | 14 #include "mojo/services/view_manager/ids.h" |
| 15 #include "mojo/services/view_manager/server_view.h" | 15 #include "mojo/services/view_manager/server_view.h" |
| 16 #include "mojo/services/view_manager/server_view_delegate.h" | 16 #include "mojo/services/view_manager/server_view_delegate.h" |
| 17 #include "mojo/services/view_manager/view_manager_export.h" | 17 #include "mojo/services/view_manager/view_manager_export.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 class Event; | 20 class Event; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace mojo { | 23 namespace mojo { |
| 24 | 24 |
| 25 class ApplicationConnection; | 25 class ApplicationConnection; |
| 26 | 26 |
| 27 namespace service { | 27 namespace service { |
| 28 | 28 |
| 29 class DisplayManagerDelegate; | |
| 30 class ViewManagerServiceImpl; | 29 class ViewManagerServiceImpl; |
| 31 | 30 |
| 32 // ConnectionManager manages the set of connections to the ViewManager (all the | 31 // ConnectionManager manages the set of connections to the ViewManager (all the |
| 33 // ViewManagerServiceImpls) as well as providing the root of the hierarchy. | 32 // ViewManagerServiceImpls) as well as providing the root of the hierarchy. |
| 34 class MOJO_VIEW_MANAGER_EXPORT ConnectionManager : public ServerViewDelegate { | 33 class MOJO_VIEW_MANAGER_EXPORT ConnectionManager : public ServerViewDelegate { |
| 35 public: | 34 public: |
| 36 // Create when a ViewManagerServiceImpl is about to make a change. Ensures | 35 // Create when a ViewManagerServiceImpl is about to make a change. Ensures |
| 37 // clients are notified correctly. | 36 // clients are notified correctly. |
| 38 class ScopedChange { | 37 class ScopedChange { |
| 39 public: | 38 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 const ConnectionSpecificId connection_id_; | 59 const ConnectionSpecificId connection_id_; |
| 61 const bool is_delete_view_; | 60 const bool is_delete_view_; |
| 62 | 61 |
| 63 // See description of MarkConnectionAsMessaged/DidMessageConnection. | 62 // See description of MarkConnectionAsMessaged/DidMessageConnection. |
| 64 std::set<ConnectionSpecificId> message_ids_; | 63 std::set<ConnectionSpecificId> message_ids_; |
| 65 | 64 |
| 66 DISALLOW_COPY_AND_ASSIGN(ScopedChange); | 65 DISALLOW_COPY_AND_ASSIGN(ScopedChange); |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 ConnectionManager(ApplicationConnection* app_connection, | 68 ConnectionManager(ApplicationConnection* app_connection, |
| 70 DisplayManagerDelegate* display_manager_delegate, | |
| 71 const Callback<void()>& native_viewport_closed_callback); | 69 const Callback<void()>& native_viewport_closed_callback); |
| 72 virtual ~ConnectionManager(); | 70 virtual ~ConnectionManager(); |
| 73 | 71 |
| 74 // Returns the id for the next ViewManagerServiceImpl. | 72 // Returns the id for the next ViewManagerServiceImpl. |
| 75 ConnectionSpecificId GetAndAdvanceNextConnectionId(); | 73 ConnectionSpecificId GetAndAdvanceNextConnectionId(); |
| 76 | 74 |
| 77 void AddConnection(ViewManagerServiceImpl* connection); | 75 void AddConnection(ViewManagerServiceImpl* connection); |
| 78 void RemoveConnection(ViewManagerServiceImpl* connection); | 76 void RemoveConnection(ViewManagerServiceImpl* connection); |
| 79 | 77 |
| 80 // Establishes the initial client. Similar to Connect(), but the resulting | 78 // Establishes the initial client. Similar to Connect(), but the resulting |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const ServerView* old_parent); | 128 const ServerView* old_parent); |
| 131 void ProcessViewHierarchyChanged(const ServerView* view, | 129 void ProcessViewHierarchyChanged(const ServerView* view, |
| 132 const ServerView* new_parent, | 130 const ServerView* new_parent, |
| 133 const ServerView* old_parent); | 131 const ServerView* old_parent); |
| 134 void ProcessViewReorder(const ServerView* view, | 132 void ProcessViewReorder(const ServerView* view, |
| 135 const ServerView* relative_view, | 133 const ServerView* relative_view, |
| 136 const OrderDirection direction); | 134 const OrderDirection direction); |
| 137 void ProcessViewDeleted(const ViewId& view); | 135 void ProcessViewDeleted(const ViewId& view); |
| 138 | 136 |
| 139 private: | 137 private: |
| 140 // Used to setup any static state needed by ConnectionManager. | |
| 141 struct Context { | |
| 142 Context(); | |
| 143 ~Context(); | |
| 144 }; | |
| 145 | |
| 146 typedef std::map<ConnectionSpecificId, ViewManagerServiceImpl*> ConnectionMap; | 138 typedef std::map<ConnectionSpecificId, ViewManagerServiceImpl*> ConnectionMap; |
| 147 | 139 |
| 148 // Invoked when a connection is about to make a change. Subsequently followed | 140 // Invoked when a connection is about to make a change. Subsequently followed |
| 149 // by FinishChange() once the change is done. | 141 // by FinishChange() once the change is done. |
| 150 // | 142 // |
| 151 // Changes should never nest, meaning each PrepareForChange() must be | 143 // Changes should never nest, meaning each PrepareForChange() must be |
| 152 // balanced with a call to FinishChange() with no PrepareForChange() | 144 // balanced with a call to FinishChange() with no PrepareForChange() |
| 153 // in between. | 145 // in between. |
| 154 void PrepareForChange(ScopedChange* change); | 146 void PrepareForChange(ScopedChange* change); |
| 155 | 147 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 172 virtual void OnViewDestroyed(const ServerView* view) OVERRIDE; | 164 virtual void OnViewDestroyed(const ServerView* view) OVERRIDE; |
| 173 virtual void OnWillChangeViewHierarchy(const ServerView* view, | 165 virtual void OnWillChangeViewHierarchy(const ServerView* view, |
| 174 const ServerView* new_parent, | 166 const ServerView* new_parent, |
| 175 const ServerView* old_parent) OVERRIDE; | 167 const ServerView* old_parent) OVERRIDE; |
| 176 virtual void OnViewHierarchyChanged(const ServerView* view, | 168 virtual void OnViewHierarchyChanged(const ServerView* view, |
| 177 const ServerView* new_parent, | 169 const ServerView* new_parent, |
| 178 const ServerView* old_parent) OVERRIDE; | 170 const ServerView* old_parent) OVERRIDE; |
| 179 virtual void OnViewBoundsChanged(const ServerView* view, | 171 virtual void OnViewBoundsChanged(const ServerView* view, |
| 180 const gfx::Rect& old_bounds, | 172 const gfx::Rect& old_bounds, |
| 181 const gfx::Rect& new_bounds) OVERRIDE; | 173 const gfx::Rect& new_bounds) OVERRIDE; |
| 182 virtual void OnViewBitmapChanged(const ServerView* view) OVERRIDE; | 174 virtual void OnViewSurfaceIdChanged(const ServerView* view) OVERRIDE; |
| 183 virtual void OnWillChangeViewVisibility(const ServerView* view) OVERRIDE; | 175 virtual void OnWillChangeViewVisibility(const ServerView* view) OVERRIDE; |
| 184 | 176 |
| 185 Context context_; | |
| 186 | |
| 187 ApplicationConnection* app_connection_; | 177 ApplicationConnection* app_connection_; |
| 188 | 178 |
| 189 // ID to use for next ViewManagerServiceImpl. | 179 // ID to use for next ViewManagerServiceImpl. |
| 190 ConnectionSpecificId next_connection_id_; | 180 ConnectionSpecificId next_connection_id_; |
| 191 | 181 |
| 192 // Set of ViewManagerServiceImpls. | 182 // Set of ViewManagerServiceImpls. |
| 193 ConnectionMap connection_map_; | 183 ConnectionMap connection_map_; |
| 194 | 184 |
| 195 DisplayManager display_manager_; | 185 DisplayManager display_manager_; |
| 196 | 186 |
| 197 scoped_ptr<ServerView> root_; | 187 scoped_ptr<ServerView> root_; |
| 198 | 188 |
| 199 // Set of ViewManagerServiceImpls created by way of Connect(). These have to | 189 // Set of ViewManagerServiceImpls created by way of Connect(). These have to |
| 200 // be explicitly destroyed. | 190 // be explicitly destroyed. |
| 201 std::set<ViewManagerServiceImpl*> connections_created_by_connect_; | 191 std::set<ViewManagerServiceImpl*> connections_created_by_connect_; |
| 202 | 192 |
| 203 // If non-null we're processing a change. The ScopedChange is not owned by us | 193 // If non-null we're processing a change. The ScopedChange is not owned by us |
| 204 // (it's created on the stack by ViewManagerServiceImpl). | 194 // (it's created on the stack by ViewManagerServiceImpl). |
| 205 ScopedChange* current_change_; | 195 ScopedChange* current_change_; |
| 206 | 196 |
| 207 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); | 197 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
| 208 }; | 198 }; |
| 209 | 199 |
| 210 } // namespace service | 200 } // namespace service |
| 211 } // namespace mojo | 201 } // namespace mojo |
| 212 | 202 |
| 213 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 203 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ |
| OLD | NEW |