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

Side by Side Diff: services/ui/public/cpp/window_tree_client.h

Issue 2301353003: Changes ownership of WindowTreeClient (Closed)
Patch Set: fix navigation Created 4 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 SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_
6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 28 matching lines...) Expand all
39 39
40 namespace ui { 40 namespace ui {
41 class InFlightChange; 41 class InFlightChange;
42 class WindowTreeClientDelegate; 42 class WindowTreeClientDelegate;
43 class WindowTreeClientPrivate; 43 class WindowTreeClientPrivate;
44 class WindowTreeClientObserver; 44 class WindowTreeClientObserver;
45 enum class ChangeType; 45 enum class ChangeType;
46 46
47 // Manages the connection with mus. 47 // Manages the connection with mus.
48 // 48 //
49 // WindowTreeClient is deleted by any of the following: 49 // WindowTreeClient is owned by the creator. Generally when the delegate gets
50 // . If all the roots of the connection are destroyed and the connection is 50 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the
51 // configured to delete when there are no roots (true if the WindowTreeClient 51 // WindowTreeClient.
52 // is created with a mojom::WindowTreeClientRequest). This happens
53 // if the owner of the roots Embed()s another app in all the roots, or all
54 // the roots are explicitly deleted.
55 // . The connection to mus is lost.
56 // . Explicitly by way of calling delete.
57 // 52 //
58 // When WindowTreeClient is deleted all windows are deleted (and observers 53 // When WindowTreeClient is deleted all windows are deleted (and observers
59 // notified). This is followed by calling 54 // notified).
60 // WindowTreeClientDelegate::OnDidDestroyClient().
61 class WindowTreeClient : public mojom::WindowTreeClient, 55 class WindowTreeClient : public mojom::WindowTreeClient,
62 public mojom::WindowManager, 56 public mojom::WindowManager,
63 public WindowManagerClient { 57 public WindowManagerClient {
64 public: 58 public:
65 WindowTreeClient(WindowTreeClientDelegate* delegate, 59 explicit WindowTreeClient(
66 WindowManagerDelegate* window_manager_delegate, 60 WindowTreeClientDelegate* delegate,
67 mojom::WindowTreeClientRequest request); 61 WindowManagerDelegate* window_manager_delegate = nullptr,
62 mojom::WindowTreeClientRequest request = nullptr);
68 ~WindowTreeClient() override; 63 ~WindowTreeClient() override;
69 64
70 // Establishes the connection by way of the WindowTreeFactory. 65 // Establishes the connection by way of the WindowTreeFactory.
71 void ConnectViaWindowTreeFactory(shell::Connector* connector); 66 void ConnectViaWindowTreeFactory(shell::Connector* connector);
72 67
73 // Establishes the connection by way of WindowManagerWindowTreeFactory. 68 // Establishes the connection by way of WindowManagerWindowTreeFactory.
74 void ConnectAsWindowManager(shell::Connector* connector); 69 void ConnectAsWindowManager(shell::Connector* connector);
75 70
76 // Wait for OnEmbed(), returning when done. 71 // Wait for OnEmbed(), returning when done.
77 void WaitForEmbed(); 72 void WaitForEmbed();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 bool IsRoot(Window* window) const { return roots_.count(window) > 0; } 144 bool IsRoot(Window* window) const { return roots_.count(window) > 0; }
150 145
151 void OnWindowDestroying(Window* window); 146 void OnWindowDestroying(Window* window);
152 147
153 // Called after the window's observers have been notified of destruction (as 148 // Called after the window's observers have been notified of destruction (as
154 // the last step of ~Window). 149 // the last step of ~Window).
155 void OnWindowDestroyed(Window* window); 150 void OnWindowDestroyed(Window* window);
156 151
157 Window* GetWindowByServerId(Id id); 152 Window* GetWindowByServerId(Id id);
158 153
159 // Sets whether this is deleted when there are no roots. The default is to
160 // delete when there are no roots.
161 void SetDeleteOnNoRoots(bool value);
162
163 // Returns the root of this connection. 154 // Returns the root of this connection.
164 const std::set<Window*>& GetRoots(); 155 const std::set<Window*>& GetRoots();
165 156
166 // Returns the Window with input capture; null if no window has requested 157 // Returns the Window with input capture; null if no window has requested
167 // input capture, or if another app has capture. 158 // input capture, or if another app has capture.
168 Window* GetCaptureWindow(); 159 Window* GetCaptureWindow();
169 160
170 // Returns the focused window; null if focus is not yet known or another app 161 // Returns the focused window; null if focus is not yet known or another app
171 // is focused. 162 // is focused.
172 Window* GetFocusedWindow(); 163 Window* GetFocusedWindow();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 Window* capture_window_; 386 Window* capture_window_;
396 387
397 Window* focused_window_; 388 Window* focused_window_;
398 389
399 mojo::Binding<mojom::WindowTreeClient> binding_; 390 mojo::Binding<mojom::WindowTreeClient> binding_;
400 mojom::WindowTreePtr tree_ptr_; 391 mojom::WindowTreePtr tree_ptr_;
401 // Typically this is the value contained in |tree_ptr_|, but tests may 392 // Typically this is the value contained in |tree_ptr_|, but tests may
402 // directly set this. 393 // directly set this.
403 mojom::WindowTree* tree_; 394 mojom::WindowTree* tree_;
404 395
405 bool delete_on_no_roots_; 396 // Set to true if OnEmbed() was received.
397 bool is_from_embed_ = false;
406 398
407 bool in_destructor_; 399 bool in_destructor_;
408 400
409 // A mapping to shared memory that is one 32 bit integer long. The window 401 // A mapping to shared memory that is one 32 bit integer long. The window
410 // server uses this to let us synchronously read the cursor location. 402 // server uses this to let us synchronously read the cursor location.
411 mojo::ScopedSharedBufferMapping cursor_location_mapping_; 403 mojo::ScopedSharedBufferMapping cursor_location_mapping_;
412 404
413 base::ObserverList<WindowTreeClientObserver> observers_; 405 base::ObserverList<WindowTreeClientObserver> observers_;
414 406
415 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> 407 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>>
(...skipping 14 matching lines...) Expand all
430 base::Callback<void(bool)> on_current_move_finished_; 422 base::Callback<void(bool)> on_current_move_finished_;
431 423
432 base::WeakPtrFactory<WindowTreeClient> weak_factory_; 424 base::WeakPtrFactory<WindowTreeClient> weak_factory_;
433 425
434 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); 426 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient);
435 }; 427 };
436 428
437 } // namespace ui 429 } // namespace ui
438 430
439 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 431 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_
OLDNEW
« no previous file with comments | « services/ui/public/cpp/tests/window_tree_client_unittest.cc ('k') | services/ui/public/cpp/window_tree_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698