OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef SERVICES_VIEW_MANAGER_SERVER_VIEW_DRAWN_TRACKER_H_ |
| 6 #define SERVICES_VIEW_MANAGER_SERVER_VIEW_DRAWN_TRACKER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "mojo/services/view_manager/server_view_observer.h" |
| 12 |
| 13 namespace view_manager { |
| 14 |
| 15 class ServerViewDrawnTrackerObserver; |
| 16 |
| 17 // ServerViewDrawnTracker notifies its observer any time the drawn state of |
| 18 // the supplied view changes. |
| 19 // |
| 20 // NOTE: you must ensure this class is destroyed before the root. |
| 21 class ServerViewDrawnTracker : public ServerViewObserver { |
| 22 public: |
| 23 ServerViewDrawnTracker(ServerView* root, |
| 24 ServerView* view, |
| 25 ServerViewDrawnTrackerObserver* observer); |
| 26 ~ServerViewDrawnTracker() override; |
| 27 |
| 28 ServerView* view() { return view_; } |
| 29 |
| 30 private: |
| 31 void SetDrawn(ServerView* ancestor, bool drawn); |
| 32 |
| 33 // Adds |this| as an observer to |view_| and its ancestors. |
| 34 void AddObservers(); |
| 35 |
| 36 // Stops observerving any views we added as an observer in AddObservers(). |
| 37 void RemoveObservers(); |
| 38 |
| 39 // ServerViewObserver: |
| 40 void OnViewDestroyed(ServerView* view) override; |
| 41 void OnViewHierarchyChanged(ServerView* view, |
| 42 ServerView* new_parent, |
| 43 ServerView* old_parent) override; |
| 44 void OnViewVisibilityChanged(ServerView* view) override; |
| 45 |
| 46 ServerView* root_; |
| 47 ServerView* view_; |
| 48 ServerViewDrawnTrackerObserver* observer_; |
| 49 bool drawn_; |
| 50 // Set of views we're observing. This is |view_| and all its ancestors. |
| 51 std::set<ServerView*> views_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(ServerViewDrawnTracker); |
| 54 }; |
| 55 |
| 56 } // namespace view_manager |
| 57 |
| 58 #endif // SERVICES_VIEW_MANAGER_SERVER_VIEW_DRAWN_TRACKER_H_ |
OLD | NEW |