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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); | 176 Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 WindowTreeClient::~WindowTreeClient() { | 180 WindowTreeClient::~WindowTreeClient() { |
181 in_destructor_ = true; | 181 in_destructor_ = true; |
182 | 182 |
183 for (WindowTreeClientObserver& observer : observers_) | 183 for (WindowTreeClientObserver& observer : observers_) |
184 observer.OnWillDestroyClient(this); | 184 observer.OnWillDestroyClient(this); |
185 | 185 |
186 std::vector<Window*> non_owned; | 186 // Clients should properly delete all of their windows before shutdown. |
187 WindowTracker tracker; | 187 CHECK(windows_.empty()); |
188 while (!windows_.empty()) { | |
189 IdToWindowMap::iterator it = windows_.begin(); | |
190 if (WasCreatedByThisClient(it->second)) { | |
191 const Id window_id = it->second->server_id(); | |
192 delete it->second->GetWindow(); | |
193 DCHECK_EQ(0u, windows_.count(window_id)); | |
194 } else { | |
195 tracker.Add(it->second->GetWindow()); | |
196 windows_.erase(it); | |
197 } | |
198 } | |
199 | |
200 // Delete the non-owned windows last. In the typical case these are roots. The | |
201 // exception is the window manager and embed roots, which may know about | |
202 // other random windows that it doesn't own. | |
203 while (!tracker.windows().empty()) | |
204 delete tracker.windows().front(); | |
205 | |
206 for (WindowTreeClientObserver& observer : observers_) | |
207 observer.OnDidDestroyClient(this); | |
208 | 188 |
209 capture_synchronizer_.reset(); | 189 capture_synchronizer_.reset(); |
210 | 190 |
211 client::GetTransientWindowClient()->RemoveObserver(this); | 191 client::GetTransientWindowClient()->RemoveObserver(this); |
212 } | 192 } |
213 | 193 |
214 void WindowTreeClient::ConnectViaWindowTreeFactory() { | 194 void WindowTreeClient::ConnectViaWindowTreeFactory() { |
215 // The client id doesn't really matter, we use 101 purely for debugging. | 195 // The client id doesn't really matter, we use 101 purely for debugging. |
216 client_id_ = 101; | 196 client_id_ = 101; |
217 | 197 |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1798 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1819 this, capture_synchronizer_.get(), window)); | 1799 this, capture_synchronizer_.get(), window)); |
1820 } | 1800 } |
1821 | 1801 |
1822 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1802 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1823 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1803 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1824 this, focus_synchronizer_.get(), window)); | 1804 this, focus_synchronizer_.get(), window)); |
1825 } | 1805 } |
1826 | 1806 |
1827 } // namespace aura | 1807 } // namespace aura |
OLD | NEW |