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 #include "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "ui/aura/mus/window_mus.h" | 44 #include "ui/aura/mus/window_mus.h" |
45 #include "ui/aura/mus/window_port_mus.h" | 45 #include "ui/aura/mus/window_port_mus.h" |
46 #include "ui/aura/mus/window_tree_client_delegate.h" | 46 #include "ui/aura/mus/window_tree_client_delegate.h" |
47 #include "ui/aura/mus/window_tree_client_observer.h" | 47 #include "ui/aura/mus/window_tree_client_observer.h" |
48 #include "ui/aura/mus/window_tree_client_test_observer.h" | 48 #include "ui/aura/mus/window_tree_client_test_observer.h" |
49 #include "ui/aura/mus/window_tree_host_mus.h" | 49 #include "ui/aura/mus/window_tree_host_mus.h" |
50 #include "ui/aura/mus/window_tree_host_mus_init_params.h" | 50 #include "ui/aura/mus/window_tree_host_mus_init_params.h" |
51 #include "ui/aura/window.h" | 51 #include "ui/aura/window.h" |
52 #include "ui/aura/window_delegate.h" | 52 #include "ui/aura/window_delegate.h" |
53 #include "ui/aura/window_event_dispatcher.h" | 53 #include "ui/aura/window_event_dispatcher.h" |
| 54 #include "ui/aura/window_port_for_shutdown.h" |
54 #include "ui/aura/window_tracker.h" | 55 #include "ui/aura/window_tracker.h" |
55 #include "ui/base/layout.h" | 56 #include "ui/base/layout.h" |
56 #include "ui/base/ui_base_types.h" | 57 #include "ui/base/ui_base_types.h" |
57 #include "ui/display/screen.h" | 58 #include "ui/display/screen.h" |
58 #include "ui/events/event.h" | 59 #include "ui/events/event.h" |
59 #include "ui/gfx/geometry/dip_util.h" | 60 #include "ui/gfx/geometry/dip_util.h" |
60 #include "ui/gfx/geometry/insets.h" | 61 #include "ui/gfx/geometry/insets.h" |
61 #include "ui/gfx/geometry/size.h" | 62 #include "ui/gfx/geometry/size.h" |
62 | 63 |
63 #if defined(HiWord) | 64 #if defined(HiWord) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 255 |
255 WindowTreeClient::~WindowTreeClient() { | 256 WindowTreeClient::~WindowTreeClient() { |
256 in_destructor_ = true; | 257 in_destructor_ = true; |
257 | 258 |
258 if (discardable_shared_memory_manager_) | 259 if (discardable_shared_memory_manager_) |
259 base::DiscardableMemoryAllocator::SetInstance(nullptr); | 260 base::DiscardableMemoryAllocator::SetInstance(nullptr); |
260 | 261 |
261 for (WindowTreeClientObserver& observer : observers_) | 262 for (WindowTreeClientObserver& observer : observers_) |
262 observer.OnWillDestroyClient(this); | 263 observer.OnWillDestroyClient(this); |
263 | 264 |
264 // Clients should properly delete all of their windows before shutdown. | |
265 CHECK(windows_.empty()); | |
266 | |
267 capture_synchronizer_.reset(); | 265 capture_synchronizer_.reset(); |
268 | 266 |
269 client::GetTransientWindowClient()->RemoveObserver(this); | 267 client::GetTransientWindowClient()->RemoveObserver(this); |
270 | 268 |
271 Env* env = Env::GetInstance(); | 269 Env* env = Env::GetInstance(); |
272 if (compositor_context_factory_ && | 270 if (compositor_context_factory_ && |
273 env->context_factory() == compositor_context_factory_.get()) { | 271 env->context_factory() == compositor_context_factory_.get()) { |
274 env->set_context_factory(initial_context_factory_); | 272 env->set_context_factory(initial_context_factory_); |
275 } | 273 } |
| 274 |
| 275 // Allow for windows to exist (and be created) after we are destroyed. This |
| 276 // is necessary because of shutdown ordering (WindowTreeClient is destroyed |
| 277 // before windows). |
| 278 in_shutdown_ = true; |
| 279 IdToWindowMap windows; |
| 280 std::swap(windows, windows_); |
| 281 for (auto& pair : windows) |
| 282 WindowPortForShutdown::Install(pair.second->GetWindow()); |
| 283 |
| 284 env->WindowTreeClientDestroyed(this); |
| 285 CHECK(windows_.empty()); |
276 } | 286 } |
277 | 287 |
278 void WindowTreeClient::ConnectViaWindowTreeFactory() { | 288 void WindowTreeClient::ConnectViaWindowTreeFactory() { |
279 // The client id doesn't really matter, we use 101 purely for debugging. | 289 // The client id doesn't really matter, we use 101 purely for debugging. |
280 client_id_ = 101; | 290 client_id_ = 101; |
281 | 291 |
282 ui::mojom::WindowTreeFactoryPtr factory; | 292 ui::mojom::WindowTreeFactoryPtr factory; |
283 connector_->BindInterface(ui::mojom::kServiceName, &factory); | 293 connector_->BindInterface(ui::mojom::kServiceName, &factory); |
284 ui::mojom::WindowTreePtr window_tree; | 294 ui::mojom::WindowTreePtr window_tree; |
285 factory->CreateWindowTree(MakeRequest(&window_tree), | 295 factory->CreateWindowTree(MakeRequest(&window_tree), |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 base::Bind(&WindowTreeClient::OnSetDisplayRootDone, | 747 base::Bind(&WindowTreeClient::OnSetDisplayRootDone, |
738 base::Unretained(this))); | 748 base::Unretained(this))); |
739 } | 749 } |
740 } | 750 } |
741 } | 751 } |
742 | 752 |
743 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) { | 753 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) { |
744 if (focus_synchronizer_->focused_window() == window) | 754 if (focus_synchronizer_->focused_window() == window) |
745 focus_synchronizer_->OnFocusedWindowDestroyed(); | 755 focus_synchronizer_->OnFocusedWindowDestroyed(); |
746 | 756 |
| 757 // If we're |in_shutdown_| there is no point in telling the server about the |
| 758 // deletion. The connection to the server is about to be dropped and the |
| 759 // server will take appropriate action. |
747 // TODO: decide how to deal with windows not owned by this client. | 760 // TODO: decide how to deal with windows not owned by this client. |
748 if (origin == Origin::CLIENT && | 761 if (!in_shutdown_ && origin == Origin::CLIENT && |
749 (WasCreatedByThisClient(window) || IsRoot(window))) { | 762 (WasCreatedByThisClient(window) || IsRoot(window))) { |
750 const uint32_t change_id = | 763 const uint32_t change_id = |
751 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( | 764 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( |
752 window, ChangeType::DELETE_WINDOW)); | 765 window, ChangeType::DELETE_WINDOW)); |
753 tree_->DeleteWindow(change_id, window->server_id()); | 766 tree_->DeleteWindow(change_id, window->server_id()); |
754 } | 767 } |
755 | 768 |
756 windows_.erase(window->server_id()); | 769 windows_.erase(window->server_id()); |
757 | 770 |
758 for (auto& entry : embedded_windows_) { | 771 for (auto& entry : embedded_windows_) { |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 } | 2092 } |
2080 | 2093 |
2081 void WindowTreeClient::OnCompositingLockStateChanged( | 2094 void WindowTreeClient::OnCompositingLockStateChanged( |
2082 ui::Compositor* compositor) {} | 2095 ui::Compositor* compositor) {} |
2083 | 2096 |
2084 void WindowTreeClient::OnCompositingShuttingDown(ui::Compositor* compositor) { | 2097 void WindowTreeClient::OnCompositingShuttingDown(ui::Compositor* compositor) { |
2085 compositor->RemoveObserver(this); | 2098 compositor->RemoveObserver(this); |
2086 } | 2099 } |
2087 | 2100 |
2088 } // namespace aura | 2101 } // namespace aura |
OLD | NEW |