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

Side by Side Diff: third_party/WebKit/Source/core/dom/ContextLifecycleObserver.h

Issue 2585143002: Introduce ContextObserver (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 #define ContextLifecycleObserver_h 28 #define ContextLifecycleObserver_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
32 #include "platform/LifecycleObserver.h" 32 #include "platform/LifecycleObserver.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 class LocalFrame; 36 class LocalFrame;
37 37
38 // ContextObserver is a lightweight version of ContextLifecycleObserver.
39 // If you just want to use getExecutionContext() and frame(), use
40 // ContextObserver. If you need to listen contextDestroyed() notifications,
41 // use ContextLifecycleObserver.
42 class CORE_EXPORT ContextObserver : public GarbageCollectedMixin {
43 public:
44 // Returns null after the observing context is detached.
45 ExecutionContext* getExecutionContext() const;
46
47 // Returns null after the observing context is detached or if the context
48 // doesn't have a frame (i.e., if the context is not a Document).
49 LocalFrame* frame() const;
50
51 DECLARE_VIRTUAL_TRACE();
52
53 protected:
54 explicit ContextObserver(ExecutionContext* executionContext)
55 : m_executionContext(executionContext) {}
56
57 explicit ContextObserver(LocalFrame*);
58
59 private:
60 Member<ExecutionContext> m_executionContext;
haraken 2016/12/19 02:09:25 I don't think this needs to be a weak member becau
61 };
62
38 class CORE_EXPORT ContextLifecycleObserver 63 class CORE_EXPORT ContextLifecycleObserver
39 : public LifecycleObserver<ExecutionContext, ContextLifecycleObserver> { 64 : public LifecycleObserver<ExecutionContext, ContextLifecycleObserver> {
40 public: 65 public:
41 // Returns null after the observing context is detached. 66 // Returns null after the observing context is detached.
42 ExecutionContext* getExecutionContext() const { return lifecycleContext(); } 67 ExecutionContext* getExecutionContext() const { return lifecycleContext(); }
43 68
44 // Returns null after the observing context is detached or if the context 69 // Returns null after the observing context is detached or if the context
45 // doesn't have a frame (i.e., if the context is not a Document). 70 // doesn't have a frame (i.e., if the context is not a Document).
46 LocalFrame* frame() const; 71 LocalFrame* frame() const;
47 72
48 enum Type { 73 enum Type {
49 GenericType, 74 GenericType,
50 SuspendableObjectType, 75 SuspendableObjectType,
51 }; 76 };
52 77
53 Type observerType() const { return m_observerType; } 78 Type observerType() const { return m_observerType; }
54 79
55 protected: 80 protected:
56 explicit ContextLifecycleObserver(ExecutionContext* executionContext, 81 explicit ContextLifecycleObserver(ExecutionContext* executionContext,
57 Type type = GenericType) 82 Type type = GenericType)
58 : LifecycleObserver(executionContext), m_observerType(type) {} 83 : LifecycleObserver(executionContext), m_observerType(type) {}
59 84
60 private: 85 private:
61 Type m_observerType; 86 Type m_observerType;
62 }; 87 };
63 88
64 } // namespace blink 89 } // namespace blink
65 90
66 #endif // ContextLifecycleObserver_h 91 #endif // ContextLifecycleObserver_h
OLDNEW
« 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