1 // Copyright 2015 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_SERVER_VIEW_DRAWN_TRACKER_H_
6 #define COMPONENTS_MUS_SERVER_VIEW_DRAWN_TRACKER_H_
10 #include "base/basictypes.h"
11 #include "components/mus/server_view_observer.h"
15 class ServerViewDrawnTrackerObserver
;
17 // ServerViewDrawnTracker notifies its observer any time the drawn state of
18 // the supplied view changes.
20 // NOTE: you must ensure this class is destroyed before the root.
21 class ServerViewDrawnTracker
: public ServerViewObserver
{
23 ServerViewDrawnTracker(ServerView
* view
,
24 ServerViewDrawnTrackerObserver
* observer
);
25 ~ServerViewDrawnTracker() override
;
27 ServerView
* view() { return view_
; }
30 void SetDrawn(ServerView
* ancestor
, bool drawn
);
32 // Adds |this| as an observer to |view_| and its ancestors.
35 // Stops observerving any views we added as an observer in AddObservers().
36 void RemoveObservers();
38 // ServerViewObserver:
39 void OnViewDestroyed(ServerView
* view
) override
;
40 void OnViewHierarchyChanged(ServerView
* view
,
41 ServerView
* new_parent
,
42 ServerView
* old_parent
) override
;
43 void OnViewVisibilityChanged(ServerView
* view
) override
;
46 ServerViewDrawnTrackerObserver
* observer_
;
48 // Set of views we're observing. This is |view_| and all its ancestors.
49 std::set
<ServerView
*> views_
;
51 DISALLOW_COPY_AND_ASSIGN(ServerViewDrawnTracker
);
56 #endif // COMPONENTS_MUS_SERVER_VIEW_DRAWN_TRACKER_H_