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

Side by Side Diff: components/mus/ws/window_tree_host_connection.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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_WINDOW_TREE_HOST_CONNECTION_H_ 5 #ifndef COMPONENTS_MUS_WS_WINDOW_TREE_HOST_CONNECTION_H_
6 #define COMPONENTS_MUS_WS_WINDOW_TREE_HOST_CONNECTION_H_ 6 #define COMPONENTS_MUS_WS_WINDOW_TREE_HOST_CONNECTION_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
11 #include "components/mus/ws/window_tree_host_delegate.h"
12 #include "components/mus/ws/window_tree_host_impl.h" 11 #include "components/mus/ws/window_tree_host_impl.h"
13 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
14 13
15 namespace mus { 14 namespace mus {
16
17 namespace ws { 15 namespace ws {
18 16
19 class ConnectionManager; 17 class ConnectionManager;
18 class ServerWindow;
20 class WindowTreeImpl; 19 class WindowTreeImpl;
21 20
22 // WindowTreeHostConnection is a server-side object that encapsulates the 21 // WindowTreeHostConnection encapsulates the connection between a client of the
23 // connection between a client of the WindowTreeHost and its implementation. 22 // WindowTreeHost and its implementation. Additionally WindowTreeHostConnection
24 // WindowTreeHostConnection also establishes a ClientConnection via the same 23 // is able to create the WindowTree that is bound to the root.
25 // code path as embedded windows. ConnectionManager manages the lifetime of 24 //
26 // WindowTreeHostConnections. If a connection to the client is lost or if the 25 // WindowTreeHostConnection is owned by WindowTreeHostImpl.
27 // associated root is closed, the WindowTreeHostConnection will inform the 26 class WindowTreeHostConnection {
28 // ConnectionManager to destroy the root and its associated window tree.
29 class WindowTreeHostConnection : public WindowTreeHostDelegate {
30 public: 27 public:
31 WindowTreeHostConnection(scoped_ptr<WindowTreeHostImpl> host_impl, 28 virtual ~WindowTreeHostConnection() {}
32 ConnectionManager* connection_manager);
33 29
34 void set_window_tree(WindowTreeImpl* tree) { tree_ = tree; } 30 virtual WindowTreeImpl* CreateWindowTree(ServerWindow* root) = 0;
35
36 WindowTreeHostImpl* window_tree_host() { return host_.get(); }
37 const WindowTreeHostImpl* window_tree_host() const { return host_.get(); }
38
39 ConnectionManager* connection_manager() { return connection_manager_; }
40 const ConnectionManager* connection_manager() const {
41 return connection_manager_;
42 }
43
44 void CloseConnection();
45
46 protected:
47 ~WindowTreeHostConnection() override;
48
49 // WindowTreeHostDelegate:
50 void OnDisplayInitialized() override;
51 void OnDisplayClosed() override;
52 const WindowTreeImpl* GetWindowTree() const override;
53
54 private:
55 scoped_ptr<WindowTreeHostImpl> host_;
56 WindowTreeImpl* tree_;
57 ConnectionManager* connection_manager_;
58 bool connection_closed_;
59
60 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostConnection);
61 }; 31 };
62 32
63 // Live implementation of WindowTreeHostConnection. 33 // Live implementation of WindowTreeHostConnection.
64 class WindowTreeHostConnectionImpl : public WindowTreeHostConnection { 34 class WindowTreeHostConnectionImpl : public WindowTreeHostConnection {
65 public: 35 public:
66 WindowTreeHostConnectionImpl( 36 WindowTreeHostConnectionImpl(
67 mojo::InterfaceRequest<mojom::WindowTreeHost> request, 37 mojo::InterfaceRequest<mojom::WindowTreeHost> request,
68 scoped_ptr<WindowTreeHostImpl> host_impl, 38 WindowTreeHostImpl* host_impl,
69 mojom::WindowTreeClientPtr client, 39 mojom::WindowTreeClientPtr client,
70 ConnectionManager* connection_manager); 40 ConnectionManager* connection_manager);
41 ~WindowTreeHostConnectionImpl() override;
71 42
72 private: 43 private:
73 ~WindowTreeHostConnectionImpl() override; 44 // WindowTreeHostConnection:
45 WindowTreeImpl* CreateWindowTree(ServerWindow* root) override;
74 46
75 // WindowTreeHostDelegate: 47 ConnectionManager* connection_manager_;
76 void OnDisplayInitialized() override;
77
78 mojo::Binding<mojom::WindowTreeHost> binding_; 48 mojo::Binding<mojom::WindowTreeHost> binding_;
79 mojom::WindowTreeClientPtr client_; 49 mojom::WindowTreeClientPtr client_;
80 50
81 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostConnectionImpl); 51 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostConnectionImpl);
82 }; 52 };
83 53
84 } // namespace ws 54 } // namespace ws
85
86 } // namespace mus 55 } // namespace mus
87 56
88 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_HOST_CONNECTION_H_ 57 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_HOST_CONNECTION_H_
OLDNEW
« no previous file with comments | « components/mus/ws/connection_manager.cc ('k') | components/mus/ws/window_tree_host_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698