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

Side by Side Diff: ui/aura/window_tracker.h

Issue 1484383003: Use WindowTracker when resizing root window as it may delete other window in unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « ui/aura/test/test_windows.cc ('k') | ui/aura/window_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef UI_AURA_WINDOW_TRACKER_H_ 5 #ifndef UI_AURA_WINDOW_TRACKER_H_
6 #define UI_AURA_WINDOW_TRACKER_H_ 6 #define UI_AURA_WINDOW_TRACKER_H_
7 7
8 #include <set> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "ui/aura/aura_export.h" 12 #include "ui/aura/aura_export.h"
13 #include "ui/aura/window_observer.h" 13 #include "ui/aura/window_observer.h"
14 14
15 namespace aura { 15 namespace aura {
16 16
17 // This class keeps track of a set of windows. A Window is removed either 17 // This class keeps track of a set of windows. A Window is removed either
18 // explicitly by Remove(), or implicitly when the window is destroyed. 18 // explicitly by Remove() or Pop(), or implicitly when the window is destroyed.
19 class AURA_EXPORT WindowTracker : public WindowObserver { 19 class AURA_EXPORT WindowTracker : public WindowObserver {
20 public: 20 public:
21 typedef std::set<Window*> Windows; 21 using WindowList = std::vector<Window*>;
22 22
23 WindowTracker(); 23 WindowTracker();
24 explicit WindowTracker(const WindowList& windows);
24 ~WindowTracker() override; 25 ~WindowTracker() override;
25 26
27 bool has_windows() const { return !windows_.empty(); }
28
26 // Returns the set of windows being observed. 29 // Returns the set of windows being observed.
27 const std::set<Window*>& windows() const { return windows_; } 30 const std::vector<Window*>& windows() const { return windows_; }
28 31
29 // Adds |window| to the set of Windows being tracked. 32 // Adds |window| to the set of Windows being tracked.
30 void Add(Window* window); 33 void Add(Window* window);
31 34
32 // Removes |window| from the set of windows being tracked. 35 // Removes |window| from the set of windows being tracked.
33 void Remove(Window* window); 36 void Remove(Window* window);
34 37
35 // Returns true if |window| was previously added and has not been removed or 38 // Returns true if |window| was previously added and has not been removed or
36 // deleted. 39 // deleted.
37 bool Contains(Window* window); 40 bool Contains(Window* window);
38 41
42 // Removes and returns the window object from the tracking windows.
43 aura::Window* Pop();
44
39 // WindowObserver overrides: 45 // WindowObserver overrides:
40 void OnWindowDestroying(Window* window) override; 46 void OnWindowDestroying(Window* window) override;
41 47
42 private: 48 private:
43 Windows windows_; 49 WindowList windows_;
44 50
45 DISALLOW_COPY_AND_ASSIGN(WindowTracker); 51 DISALLOW_COPY_AND_ASSIGN(WindowTracker);
46 }; 52 };
47 53
48 } // namespace aura 54 } // namespace aura
49 55
50 #endif // UI_AURA_WINDOW_TRACKER_H_ 56 #endif // UI_AURA_WINDOW_TRACKER_H_
OLDNEW
« no previous file with comments | « ui/aura/test/test_windows.cc ('k') | ui/aura/window_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698