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

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

Issue 534843002: Convert view manager to surfaces with uploading shim in client lib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 "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
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const gfx::Rect& new_bounds); 129 const gfx::Rect& new_bounds);
132 void ProcessViewHierarchyChanged(const ServerView* view, 130 void ProcessViewHierarchyChanged(const ServerView* view,
133 const ServerView* new_parent, 131 const ServerView* new_parent,
134 const ServerView* old_parent); 132 const ServerView* old_parent);
135 void ProcessViewReorder(const ServerView* view, 133 void ProcessViewReorder(const ServerView* view,
136 const ServerView* relative_view, 134 const ServerView* relative_view,
137 const OrderDirection direction); 135 const OrderDirection direction);
138 void ProcessViewDeleted(const ViewId& view); 136 void ProcessViewDeleted(const ViewId& view);
139 137
140 private: 138 private:
141 // Used to setup any static state needed by ConnectionManager.
142 struct Context {
143 Context();
144 ~Context();
145 };
146
147 typedef std::map<ConnectionSpecificId, ViewManagerServiceImpl*> ConnectionMap; 139 typedef std::map<ConnectionSpecificId, ViewManagerServiceImpl*> ConnectionMap;
148 140
149 // Invoked when a connection is about to make a change. Subsequently followed 141 // Invoked when a connection is about to make a change. Subsequently followed
150 // by FinishChange() once the change is done. 142 // by FinishChange() once the change is done.
151 // 143 //
152 // Changes should never nest, meaning each PrepareForChange() must be 144 // Changes should never nest, meaning each PrepareForChange() must be
153 // balanced with a call to FinishChange() with no PrepareForChange() 145 // balanced with a call to FinishChange() with no PrepareForChange()
154 // in between. 146 // in between.
155 void PrepareForChange(ScopedChange* change); 147 void PrepareForChange(ScopedChange* change);
156 148
(...skipping 13 matching lines...) Expand all
170 InterfaceRequest<ServiceProvider> service_provider); 162 InterfaceRequest<ServiceProvider> service_provider);
171 163
172 // Overridden from ServerViewDelegate: 164 // Overridden from ServerViewDelegate:
173 virtual void OnViewDestroyed(const ServerView* view) OVERRIDE; 165 virtual void OnViewDestroyed(const ServerView* view) OVERRIDE;
174 virtual void OnViewHierarchyChanged(const ServerView* view, 166 virtual void OnViewHierarchyChanged(const ServerView* view,
175 const ServerView* new_parent, 167 const ServerView* new_parent,
176 const ServerView* old_parent) OVERRIDE; 168 const ServerView* old_parent) OVERRIDE;
177 virtual void OnViewBoundsChanged(const ServerView* view, 169 virtual void OnViewBoundsChanged(const ServerView* view,
178 const gfx::Rect& old_bounds, 170 const gfx::Rect& old_bounds,
179 const gfx::Rect& new_bounds) OVERRIDE; 171 const gfx::Rect& new_bounds) OVERRIDE;
180 virtual void OnViewBitmapChanged(const ServerView* view) OVERRIDE; 172 virtual void OnViewSurfaceChanged(const ServerView* view) OVERRIDE;
181
182 Context context_;
183 173
184 ApplicationConnection* app_connection_; 174 ApplicationConnection* app_connection_;
185 175
186 // ID to use for next ViewManagerServiceImpl. 176 // ID to use for next ViewManagerServiceImpl.
187 ConnectionSpecificId next_connection_id_; 177 ConnectionSpecificId next_connection_id_;
188 178
189 // Set of ViewManagerServiceImpls. 179 // Set of ViewManagerServiceImpls.
190 ConnectionMap connection_map_; 180 ConnectionMap connection_map_;
191 181
192 DisplayManager display_manager_; 182 DisplayManager display_manager_;
193 183
194 scoped_ptr<ServerView> root_; 184 scoped_ptr<ServerView> root_;
195 185
196 // Set of ViewManagerServiceImpls created by way of Connect(). These have to 186 // Set of ViewManagerServiceImpls created by way of Connect(). These have to
197 // be explicitly destroyed. 187 // be explicitly destroyed.
198 std::set<ViewManagerServiceImpl*> connections_created_by_connect_; 188 std::set<ViewManagerServiceImpl*> connections_created_by_connect_;
199 189
200 // If non-null we're processing a change. The ScopedChange is not owned by us 190 // If non-null we're processing a change. The ScopedChange is not owned by us
201 // (it's created on the stack by ViewManagerServiceImpl). 191 // (it's created on the stack by ViewManagerServiceImpl).
202 ScopedChange* current_change_; 192 ScopedChange* current_change_;
203 193
204 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 194 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
205 }; 195 };
206 196
207 } // namespace service 197 } // namespace service
208 } // namespace mojo 198 } // namespace mojo
209 199
210 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ 200 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698