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

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

Issue 2585143002: Introduce ContextObserver (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 | third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/ContextLifecycleObserver.h
diff --git a/third_party/WebKit/Source/core/dom/ContextLifecycleObserver.h b/third_party/WebKit/Source/core/dom/ContextLifecycleObserver.h
index a2fddd3a8a0a455b98b1fea132826f8ded0d4213..91eb2cdebf97e5276e260b3cda0d8bc58f363d0b 100644
--- a/third_party/WebKit/Source/core/dom/ContextLifecycleObserver.h
+++ b/third_party/WebKit/Source/core/dom/ContextLifecycleObserver.h
@@ -35,6 +35,31 @@ namespace blink {
class LocalFrame;
+// ContextClient is a lightweight version of ContextLifecycleObserver.
+// If you just want to use getExecutionContext() and frame(), use
dcheng 2016/12/20 07:20:43 Nit: I've heard some people prefer to avoid pronou
+// ContextClient. If you need to listen contextDestroyed() notifications,
+// use ContextLifecycleObserver.
+class CORE_EXPORT ContextClient : public GarbageCollectedMixin {
+ public:
+ // Returns null after the observing context is detached.
+ ExecutionContext* getExecutionContext() const;
+
+ // Returns null after the observing context is detached or if the context
+ // doesn't have a frame (i.e., if the context is not a Document).
+ LocalFrame* frame() const;
+
+ DECLARE_VIRTUAL_TRACE();
+
+ protected:
+ explicit ContextClient(ExecutionContext* executionContext)
+ : m_executionContext(executionContext) {}
+
+ explicit ContextClient(LocalFrame*);
+
+ private:
+ WeakMember<ExecutionContext> m_executionContext;
+};
+
class CORE_EXPORT ContextLifecycleObserver
: public LifecycleObserver<ExecutionContext, ContextLifecycleObserver> {
public:
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698