Revert of Mandoline UI Process: Update namespaces and file names (patchset #9 id...
[chromium-blink-merge.git] / components / mus / public / cpp / view_tracker.h
blob39d715bc8fcef32cb6521a7ecf6d07a953044f29
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_
8 #include <stdint.h>
9 #include <set>
11 #include "components/mus/public/cpp/view_observer.h"
12 #include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
14 namespace mojo {
16 class ViewTracker : public ViewObserver {
17 public:
18 using Views = std::set<View*>;
20 ViewTracker();
21 ~ViewTracker() override;
23 // Returns the set of views being observed.
24 const std::set<View*>& views() const { return views_; }
26 // Adds |view| to the set of Views being tracked.
27 void Add(View* view);
29 // Removes |view| from the set of views being tracked.
30 void Remove(View* view);
32 // Returns true if |view| was previously added and has not been removed or
33 // deleted.
34 bool Contains(View* view);
36 // ViewObserver overrides:
37 void OnViewDestroying(View* view) override;
39 private:
40 Views views_;
42 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTracker);
45 } // namespace mojo
47 #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_