Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h

Issue 2555113002: Remove ContextLifecycleObserver from ScopedWindowFocusAllowedIndicator (Closed)
Patch Set: temp Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b52a3313727b235004b510230d481f1acd8a48f2 100644
--- a/third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h
+++ b/third_party/WebKit/Source/core/dom/ScopedWindowFocusAllowedIndicator.h
@@ -5,7 +5,6 @@
#ifndef ScopedWindowFocusAllowedIndicator_h
#define ScopedWindowFocusAllowedIndicator_h
-#include "core/dom/ContextLifecycleObserver.h"
#include "core/dom/ExecutionContext.h"
#include "wtf/Noncopyable.h"
@@ -17,32 +16,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().
- Persistent<Observer> m_observer;
+ // This doesn't create a cycle because ScopedWindowFocusAllowedIndicator
+ // is used only on a machine stack.
+ Persistent<ExecutionContext> m_executionContext;
};
} // namespace blink
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698