| Index: ui/aura/window_tracker.cc
|
| diff --git a/ui/aura/window_tracker.cc b/ui/aura/window_tracker.cc
|
| index 9653e5fcf9ea57dc2b147e0e2f34b6d041cdef9b..5ff1a0fc429e842a1102296d74657a8249263a63 100644
|
| --- a/ui/aura/window_tracker.cc
|
| +++ b/ui/aura/window_tracker.cc
|
| @@ -11,9 +11,15 @@ namespace aura {
|
| WindowTracker::WindowTracker() {
|
| }
|
|
|
| +WindowTracker::WindowTracker(const WindowList& windows) {
|
| + // |windows| may contain dups, so call Add() instead of insert().
|
| + for (auto iter = windows.begin(); iter != windows.end(); iter++)
|
| + Add(*iter);
|
| +}
|
| +
|
| WindowTracker::~WindowTracker() {
|
| - for (Windows::iterator i = windows_.begin(); i != windows_.end(); ++i)
|
| - (*i)->RemoveObserver(this);
|
| + while (has_windows())
|
| + Pop()->RemoveObserver(this);
|
| }
|
|
|
| void WindowTracker::Add(Window* window) {
|
| @@ -35,6 +41,13 @@ bool WindowTracker::Contains(Window* window) {
|
| return windows_.count(window) > 0;
|
| }
|
|
|
| +aura::Window* WindowTracker::Pop() {
|
| + DCHECK(!windows_.empty());
|
| + aura::Window* window = *windows_.begin();
|
| + Remove(window);
|
| + return window;
|
| +}
|
| +
|
| void WindowTracker::OnWindowDestroying(Window* window) {
|
| DCHECK_GT(windows_.count(window), 0u);
|
| Remove(window);
|
|
|