Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h |
| diff --git a/third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h b/third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h |
| index 7f6923722be0f5a61b696cc9520f5689e13cf73b..b5fb5ed1f10f325404ed33711311b470b1f5dd22 100644 |
| --- a/third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h |
| +++ b/third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h |
| @@ -17,32 +17,17 @@ class ScopedWindowFocusAllowedIndicator final { |
| public: |
| explicit ScopedWindowFocusAllowedIndicator(ExecutionContext* executionContext) |
| - : m_observer(new Observer(executionContext)) {} |
| - ~ScopedWindowFocusAllowedIndicator() { m_observer->dispose(); } |
| + : m_executionContext(executionContext) { |
| + executionContext->allowWindowInteraction(); |
| + } |
| + ~ScopedWindowFocusAllowedIndicator() { |
| + m_executionContext->consumeWindowInteraction(); |
| + } |
| private: |
| - class Observer final : public GarbageCollected<Observer>, |
| - public ContextLifecycleObserver { |
| - USING_GARBAGE_COLLECTED_MIXIN(Observer); |
| - |
| - public: |
| - explicit Observer(ExecutionContext* executionContext) |
| - : ContextLifecycleObserver(executionContext) { |
| - if (executionContext) |
| - executionContext->allowWindowInteraction(); |
| - } |
| - |
| - void dispose() { |
| - if (getExecutionContext()) |
| - getExecutionContext()->consumeWindowInteraction(); |
| - } |
| - }; |
| - |
| - // In Oilpan, destructors are not allowed to touch other on-heap objects. |
| - // The Observer indirection is needed to keep |
| - // ScopedWindowFocusAllowedIndicator off-heap and thus allows its destructor |
| - // to call getExecutionContext()->consumeWindowInteraction(). |
|
haraken
2016/12/07 07:49:17
I don't understand this comment. The observer indi
sof
2016/12/07 08:02:18
We need(ed) to inject an on-heap ContextLifecycleO
|
| - Persistent<Observer> m_observer; |
| + // This doesn't create a cycle because ScopedWindowFocusAllowedIndicator |
| + // is used only on a machine stack. |
|
haraken
2016/12/07 07:49:17
But we cannot use STACK_ALLOCATED because the obje
sof
2016/12/07 08:02:18
Having a Persistent<ExecutionContext> is scary (wr
|
| + Persistent<ExecutionContext> m_executionContext; |
| }; |
| } // namespace blink |