OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 UI_AURA_WINDOW_DESTRUCTION_OBSERVER_H_ |
| 6 #define UI_AURA_WINDOW_DESTRUCTION_OBSERVER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "ui/aura/aura_export.h" |
| 11 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_observer.h" |
| 13 |
| 14 namespace aura { |
| 15 |
| 16 // A class for observing window (self) destruction. A side effect of a |
| 17 // window member funtion may be that the object, i.e. |this|, gets |
| 18 // deleted. This class can be used to detect such cases and to exit |
| 19 // the member function without any further access to member data. See |
| 20 // for example: aura::Window::NotifyWindowVisibilityChangedAtReceiver. |
| 21 |
| 22 class AURA_EXPORT WindowDestructionObserver : public WindowObserver { |
| 23 public: |
| 24 // Addes this observer to window. |
| 25 explicit WindowDestructionObserver(aura::Window* window); |
| 26 |
| 27 // Removes this observer from |window_| unless |window_| has been |
| 28 // observed to be destroyed. |
| 29 virtual ~WindowDestructionObserver(); |
| 30 |
| 31 // Returns true if |window_| has been observed to be destroyed. |
| 32 bool destroyed() const { return destroyed_; } |
| 33 |
| 34 private: |
| 35 // aura::WindowObserver overrides: |
| 36 virtual void OnWindowDestroyed(Window* window) OVERRIDE; |
| 37 |
| 38 Window* window_; |
| 39 bool destroyed_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(WindowDestructionObserver); |
| 42 }; |
| 43 |
| 44 } // namespace aura |
| 45 |
| 46 #endif |
OLD | NEW |