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

Side by Side Diff: components/mus/ws/connection_manager.h

Issue 1750143002: Changes ownership of WindowTreeHostConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 9 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
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/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 COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 5 #ifndef COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
6 #define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 6 #define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // TODO(sky): this class is doing too much. Refactor to make responsibilities 46 // TODO(sky): this class is doing too much. Refactor to make responsibilities
47 // clearer. 47 // clearer.
48 class ConnectionManager : public ServerWindowDelegate, 48 class ConnectionManager : public ServerWindowDelegate,
49 public ServerWindowObserver, 49 public ServerWindowObserver,
50 public mojom::DisplayManager { 50 public mojom::DisplayManager {
51 public: 51 public:
52 ConnectionManager(ConnectionManagerDelegate* delegate, 52 ConnectionManager(ConnectionManagerDelegate* delegate,
53 const scoped_refptr<mus::SurfacesState>& surfaces_state); 53 const scoped_refptr<mus::SurfacesState>& surfaces_state);
54 ~ConnectionManager() override; 54 ~ConnectionManager() override;
55 55
56 // Adds a WindowTreeHost. 56 // Adds/removes a WindowTreeHost. ConnectionManager owns the
57 void AddHost(WindowTreeHostConnection* connection); 57 // WindowTreeHostImpls.
58 void AddHost(WindowTreeHostImpl* host);
59 void DestroyHost(WindowTreeHostImpl* host);
58 60
59 // Creates a new ServerWindow. The return value is owned by the caller, but 61 // Creates a new ServerWindow. The return value is owned by the caller, but
60 // must be destroyed before ConnectionManager. 62 // must be destroyed before ConnectionManager.
61 ServerWindow* CreateServerWindow( 63 ServerWindow* CreateServerWindow(
62 const WindowId& id, 64 const WindowId& id,
63 const std::map<std::string, std::vector<uint8_t>>& properties); 65 const std::map<std::string, std::vector<uint8_t>>& properties);
64 66
65 // Returns the id for the next WindowTreeImpl. 67 // Returns the id for the next WindowTreeImpl.
66 ConnectionSpecificId GetAndAdvanceNextConnectionId(); 68 ConnectionSpecificId GetAndAdvanceNextConnectionId();
67 69
68 // Returns the id for the next WindowTreeHostImpl. 70 // Returns the id for the next WindowTreeHostImpl.
69 uint16_t GetAndAdvanceNextHostId(); 71 uint16_t GetAndAdvanceNextHostId();
70 72
71 // Invoked when a WindowTreeImpl's connection encounters an error. 73 // Invoked when a WindowTreeImpl's connection encounters an error.
72 void OnConnectionError(ClientConnection* connection); 74 void OnConnectionError(ClientConnection* connection);
73 75
74 ClientConnection* GetClientConnection(WindowTreeImpl* window_tree); 76 ClientConnection* GetClientConnection(WindowTreeImpl* window_tree);
75 77
76 // Invoked when a WindowTreeHostConnection encounters an error or the 78 void OnHostConnectionClosed(WindowTreeHostImpl* host);
77 // associated Display window is closed.
78 void OnHostConnectionClosed(WindowTreeHostConnection* connection);
79 79
80 // See description of WindowTree::Embed() for details. This assumes 80 // See description of WindowTree::Embed() for details. This assumes
81 // |transport_window_id| is valid. 81 // |transport_window_id| is valid.
82 WindowTreeImpl* EmbedAtWindow(ServerWindow* root, 82 WindowTreeImpl* EmbedAtWindow(ServerWindow* root,
83 uint32_t policy_bitmask, 83 uint32_t policy_bitmask,
84 mojom::WindowTreeClientPtr client); 84 mojom::WindowTreeClientPtr client);
85 85
86 // Adds |connection| to internal maps. 86 // Adds |connection| to internal maps.
87 void AddConnection(scoped_ptr<ClientConnection> owned_connection, 87 void AddConnection(scoped_ptr<ClientConnection> owned_connection,
88 mojom::WindowTreePtr tree_ptr); 88 mojom::WindowTreePtr tree_ptr);
(...skipping 12 matching lines...) Expand all
101 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds); 101 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds);
102 102
103 OperationType current_operation_type() const { 103 OperationType current_operation_type() const {
104 return current_operation_ ? current_operation_->type() 104 return current_operation_ ? current_operation_->type()
105 : OperationType::NONE; 105 : OperationType::NONE;
106 } 106 }
107 107
108 // Invoked when the WindowTreeHostImpl's display is closed. 108 // Invoked when the WindowTreeHostImpl's display is closed.
109 void OnDisplayClosed(); 109 void OnDisplayClosed();
110 110
111 // Called when the AcceleratedWidget is available for |host|.
112 void OnWindowTreeHostDisplayAvailable(WindowTreeHostImpl* host);
113
111 // Invoked when a connection messages a client about the change. This is used 114 // Invoked when a connection messages a client about the change. This is used
112 // to avoid sending ServerChangeIdAdvanced() unnecessarily. 115 // to avoid sending ServerChangeIdAdvanced() unnecessarily.
113 void OnConnectionMessagedClient(ConnectionSpecificId id); 116 void OnConnectionMessagedClient(ConnectionSpecificId id);
114 117
115 // Returns true if OnConnectionMessagedClient() was invoked for id. 118 // Returns true if OnConnectionMessagedClient() was invoked for id.
116 bool DidConnectionMessageClient(ConnectionSpecificId id) const; 119 bool DidConnectionMessageClient(ConnectionSpecificId id) const;
117 120
118 // Returns the metrics of the viewport where the provided |window| is 121 // Returns the metrics of the viewport where the provided |window| is
119 // displayed. 122 // displayed.
120 mojom::ViewportMetricsPtr GetViewportMetricsForWindow( 123 mojom::ViewportMetricsPtr GetViewportMetricsForWindow(
121 const ServerWindow* window); 124 const ServerWindow* window);
122 125
123 // Returns the WindowTreeImpl that has |id| as a root. 126 // Returns the WindowTreeImpl that has |id| as a root.
124 WindowTreeImpl* GetConnectionWithRoot(const ServerWindow* window) { 127 WindowTreeImpl* GetConnectionWithRoot(const ServerWindow* window) {
125 return const_cast<WindowTreeImpl*>( 128 return const_cast<WindowTreeImpl*>(
126 const_cast<const ConnectionManager*>(this) 129 const_cast<const ConnectionManager*>(this)
127 ->GetConnectionWithRoot(window)); 130 ->GetConnectionWithRoot(window));
128 } 131 }
129 const WindowTreeImpl* GetConnectionWithRoot(const ServerWindow* window) const; 132 const WindowTreeImpl* GetConnectionWithRoot(const ServerWindow* window) const;
130 133
131 WindowTreeHostImpl* GetWindowTreeHostByWindow(const ServerWindow* window); 134 WindowTreeHostImpl* GetWindowTreeHostByWindow(const ServerWindow* window);
132 const WindowTreeHostImpl* GetWindowTreeHostByWindow( 135 const WindowTreeHostImpl* GetWindowTreeHostByWindow(
133 const ServerWindow* window) const; 136 const ServerWindow* window) const;
134 137
135 WindowTreeHostImpl* GetActiveWindowTreeHost(); 138 WindowTreeHostImpl* GetActiveWindowTreeHost();
136 139
137 bool has_tree_host_connections() const { 140 bool has_tree_host_connections() const { return !hosts_.empty(); }
138 return !host_connection_map_.empty();
139 }
140 141
141 void AddDisplayManagerBinding( 142 void AddDisplayManagerBinding(
142 mojo::InterfaceRequest<mojom::DisplayManager> request); 143 mojo::InterfaceRequest<mojom::DisplayManager> request);
143 144
144 void CreateWindowManagerFactoryService( 145 void CreateWindowManagerFactoryService(
145 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request); 146 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request);
146 147
147 // Returns a change id for the window manager that is associated with 148 // Returns a change id for the window manager that is associated with
148 // |source| and |client_change_id|. When the window manager replies 149 // |source| and |client_change_id|. When the window manager replies
149 // WindowManagerChangeCompleted() is called to obtain the original source 150 // WindowManagerChangeCompleted() is called to obtain the original source
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 297
297 // ID to use for next WindowTreeImpl. 298 // ID to use for next WindowTreeImpl.
298 ConnectionSpecificId next_connection_id_; 299 ConnectionSpecificId next_connection_id_;
299 300
300 // ID to use for next WindowTreeHostImpl. 301 // ID to use for next WindowTreeHostImpl.
301 uint16_t next_host_id_; 302 uint16_t next_host_id_;
302 303
303 // Set of WindowTreeImpls. 304 // Set of WindowTreeImpls.
304 ConnectionMap connection_map_; 305 ConnectionMap connection_map_;
305 306
306 // Set of WindowTreeHostImpls. 307 // WindowTreeHostImpls are initially added to |pending_hosts_|. When the
307 HostConnectionMap host_connection_map_; 308 // display is initialized it is moved to |hosts_|.
309 // ConnectionManager owns the WindowTreeHostImpls.
310 std::set<WindowTreeHostImpl*> pending_hosts_;
311 std::set<WindowTreeHostImpl*> hosts_;
308 312
309 // If non-null then we're processing a client operation. The Operation is 313 // If non-null then we're processing a client operation. The Operation is
310 // not owned by us (it's created on the stack by WindowTreeImpl). 314 // not owned by us (it's created on the stack by WindowTreeImpl).
311 Operation* current_operation_; 315 Operation* current_operation_;
312 316
313 bool in_destructor_; 317 bool in_destructor_;
314 318
315 // Maps from window manager change id to the client that initiated the 319 // Maps from window manager change id to the client that initiated the
316 // request. 320 // request.
317 InFlightWindowManagerChangeMap in_flight_wm_change_map_; 321 InFlightWindowManagerChangeMap in_flight_wm_change_map_;
(...skipping 11 matching lines...) Expand all
329 333
330 scoped_ptr<WindowManagerFactoryService> window_manager_factory_service_; 334 scoped_ptr<WindowManagerFactoryService> window_manager_factory_service_;
331 335
332 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 336 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
333 }; 337 };
334 338
335 } // namespace ws 339 } // namespace ws
336 } // namespace mus 340 } // namespace mus
337 341
338 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 342 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698