| Index: content/public/renderer/platform_event_observer.h
|
| diff --git a/content/public/renderer/platform_event_observer.h b/content/public/renderer/platform_event_observer.h
|
| index a67cbec1a060e50220585be2cef13d9fae78552b..e14263ecbd2a6df9f13e6c5a8edc6bbc482f87d1 100644
|
| --- a/content/public/renderer/platform_event_observer.h
|
| +++ b/content/public/renderer/platform_event_observer.h
|
| @@ -60,11 +60,13 @@ class PlatformEventObserver : public PlatformEventObserverBase,
|
| thread->AddObserver(this);
|
| }
|
|
|
| - // The observer will automatically stop observing when destroyed in case it
|
| - // did not stop before.
|
| + // The observer must automatically stop observing when destroyed in case it
|
| + // did not stop before. Implementations of PlatformEventObserver must do
|
| + // so by calling StopIfObserving() from their destructors.
|
| virtual ~PlatformEventObserver() {
|
| - if (is_observing())
|
| - Stop();
|
| + // If this assert fails, the derived destructor failed to invoke
|
| + // StopIfObserving().
|
| + DCHECK(!is_observing());
|
| }
|
|
|
| // Called when a new IPC message is received. Must be used to listen to the
|
| @@ -105,6 +107,15 @@ class PlatformEventObserver : public PlatformEventObserverBase,
|
| // It is expected for subclasses to override it.
|
| virtual void SendStopMessage() = 0;
|
|
|
| + // Implementations of PlatformEventObserver must call StopIfObserving()
|
| + // from their destructor to shutdown in an orderly manner.
|
| + // (As Stop() calls a virtual method, it cannot be handled by
|
| + // ~PlatformEventObserver.)
|
| + void StopIfObserving() {
|
| + if (is_observing())
|
| + Stop();
|
| + }
|
| +
|
| bool is_observing() const {
|
| return is_observing_;
|
| }
|
|
|