Chromium Code Reviews| Index: ui/aura/window_destruction_observer.h |
| diff --git a/ui/aura/window_destruction_observer.h b/ui/aura/window_destruction_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..53c4a05bcaef182a55a4d8b98d241541475cb1d9 |
| --- /dev/null |
| +++ b/ui/aura/window_destruction_observer.h |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_AURA_WINDOW_DESTRUCTION_OBSERVER_H_ |
| +#define UI_AURA_WINDOW_DESTRUCTION_OBSERVER_H_ |
| + |
| +#include <set> |
| + |
| +#include "ui/aura/aura_export.h" |
| +#include "ui/aura/window.h" |
| +#include "ui/aura/window_observer.h" |
| + |
| +namespace aura { |
| + |
| +// A class for observing window (self) destruction. A side effect of a |
| +// window member funtion may be that the object, i.e. |this|, gets |
| +// deleted. This class can be used to detect such cases and to exit |
| +// the member function without any further access to member data. See |
| +// for example: aura::Window::NotifyWindowVisibilityChangedAtReceiver. |
| + |
| +class AURA_EXPORT WindowDestructionObserver : public WindowObserver { |
| + public: |
| + // Addes this observer to window. |
| + WindowDestructionObserver(aura::Window* window); |
|
Ben Goodger (Google)
2013/03/19 22:55:58
explicit
sschmitz
2013/03/19 23:11:06
Done.
|
| + |
| + // Removes this observer from |window_| unless |window_| has been |
| + // observed to be destroyed. |
| + virtual ~WindowDestructionObserver(); |
| + |
| + // Returns true if |window_| has been observed to be destroyed. |
| + bool destroyed() const; |
|
Ben Goodger (Google)
2013/03/19 22:55:58
you can just inline this impl here
sschmitz
2013/03/19 23:11:06
Done.
|
| + |
| + private: |
| + // aura::WindowObserver overrides: |
| + virtual void OnWindowDestroyed(Window* window) OVERRIDE; |
| + |
| + Window* window_; |
| + bool destroyed_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WindowDestructionObserver); |
| +}; |
| + |
| +} // namespace aura |
| + |
| +#endif |