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

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2696573003: Have WindowTreeClient detect error state earlier (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | 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 #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
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 DCHECK(windows_.empty());
sky 2017/02/13 23:16:15 I'm ok with making this a CHECK as I suspect this
jonross 2017/02/14 20:35:21 Done.
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 188
206 for (WindowTreeClientObserver& observer : observers_) 189 for (WindowTreeClientObserver& observer : observers_)
sky 2017/02/13 23:16:15 At this point we don't need be OnWillDestroyClient
jonross 2017/02/14 20:35:21 Done.
207 observer.OnDidDestroyClient(this); 190 observer.OnDidDestroyClient(this);
208 191
209 capture_synchronizer_.reset(); 192 capture_synchronizer_.reset();
210 193
211 client::GetTransientWindowClient()->RemoveObserver(this); 194 client::GetTransientWindowClient()->RemoveObserver(this);
212 } 195 }
213 196
214 void WindowTreeClient::ConnectViaWindowTreeFactory() { 197 void WindowTreeClient::ConnectViaWindowTreeFactory() {
215 // The client id doesn't really matter, we use 101 purely for debugging. 198 // The client id doesn't really matter, we use 101 purely for debugging.
216 client_id_ = 101; 199 client_id_ = 101;
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1801 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1819 this, capture_synchronizer_.get(), window)); 1802 this, capture_synchronizer_.get(), window));
1820 } 1803 }
1821 1804
1822 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1805 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1823 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1806 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1824 this, focus_synchronizer_.get(), window)); 1807 this, focus_synchronizer_.get(), window));
1825 } 1808 }
1826 1809
1827 } // namespace aura 1810 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698