blob: 1fa1a4c83f6e0790c517b2cebd982f9405a6fed7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/public/cpp/window_tracker.h"
namespace mus {
WindowTracker::WindowTracker() {}
WindowTracker::~WindowTracker() {
for (Windows::iterator i = windows_.begin(); i != windows_.end(); ++i)
(*i)->RemoveObserver(this);
}
void WindowTracker::Add(Window* window) {
if (windows_.count(window))
return;
window->AddObserver(this);
windows_.insert(window);
}
void WindowTracker::Remove(Window* window) {
if (windows_.count(window)) {
windows_.erase(window);
window->RemoveObserver(this);
}
}
bool WindowTracker::Contains(Window* window) {
return windows_.count(window) > 0;
}
void WindowTracker::OnWindowDestroying(Window* window) {
DCHECK_GT(windows_.count(window), 0u);
Remove(window);
}
} // namespace mus
|