OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 10 matching lines...) Expand all Loading... |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #ifndef ExecutionContext_h | 28 #ifndef ExecutionContext_h |
29 #define ExecutionContext_h | 29 #define ExecutionContext_h |
30 | 30 |
31 #include "core/dom/ContextLifecycleNotifier.h" | |
32 #include "core/dom/SecurityContext.h" | 31 #include "core/dom/SecurityContext.h" |
33 #include "core/fetch/AccessControlStatus.h" | 32 #include "core/fetch/AccessControlStatus.h" |
| 33 #include "platform/LifecycleContext.h" |
34 #include "platform/Supplementable.h" | 34 #include "platform/Supplementable.h" |
35 #include "platform/heap/Handle.h" | 35 #include "platform/heap/Handle.h" |
36 #include "platform/weborigin/KURL.h" | 36 #include "platform/weborigin/KURL.h" |
37 #include "wtf/OwnPtr.h" | 37 #include "wtf/OwnPtr.h" |
38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class ActiveDOMObject; | 42 class ActiveDOMObject; |
43 class ConsoleMessage; | 43 class ConsoleMessage; |
| 44 class ContextLifecycleNotifier; |
44 class DOMTimerCoordinator; | 45 class DOMTimerCoordinator; |
45 class ErrorEvent; | 46 class ErrorEvent; |
46 class EventQueue; | 47 class EventQueue; |
47 class EventTarget; | 48 class EventTarget; |
48 class ExecutionContextTask; | 49 class ExecutionContextTask; |
49 class LocalDOMWindow; | 50 class LocalDOMWindow; |
50 class PublicURLManager; | 51 class PublicURLManager; |
51 class SecurityOrigin; | 52 class SecurityOrigin; |
52 class ScriptCallStack; | 53 class ScriptCallStack; |
53 | 54 |
54 class ExecutionContext | 55 class ExecutionContext |
55 : public ContextLifecycleNotifier, public WillBeHeapSupplementable<Execution
Context> { | 56 : public LifecycleContext<ExecutionContext> |
| 57 , public WillBeHeapSupplementable<ExecutionContext> { |
56 public: | 58 public: |
57 virtual void trace(Visitor*) override; | 59 virtual void trace(Visitor*) override; |
58 | 60 |
59 virtual bool isDocument() const { return false; } | 61 virtual bool isDocument() const { return false; } |
60 virtual bool isWorkerGlobalScope() const { return false; } | 62 virtual bool isWorkerGlobalScope() const { return false; } |
61 virtual bool isDedicatedWorkerGlobalScope() const { return false; } | 63 virtual bool isDedicatedWorkerGlobalScope() const { return false; } |
62 virtual bool isSharedWorkerGlobalScope() const { return false; } | 64 virtual bool isSharedWorkerGlobalScope() const { return false; } |
63 virtual bool isServiceWorkerGlobalScope() const { return false; } | 65 virtual bool isServiceWorkerGlobalScope() const { return false; } |
64 virtual bool isJSExecutionForbidden() const { return false; } | 66 virtual bool isJSExecutionForbidden() const { return false; } |
65 SecurityOrigin* securityOrigin(); | 67 SecurityOrigin* securityOrigin(); |
(...skipping 19 matching lines...) Expand all Loading... |
85 KURL contextCompleteURL(const String& url) const { return virtualCompleteURL
(url); } | 87 KURL contextCompleteURL(const String& url) const { return virtualCompleteURL
(url); } |
86 | 88 |
87 bool shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus)
; | 89 bool shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus)
; |
88 void reportException(PassRefPtrWillBeRawPtr<ErrorEvent>, int scriptId, PassR
efPtrWillBeRawPtr<ScriptCallStack>, AccessControlStatus); | 90 void reportException(PassRefPtrWillBeRawPtr<ErrorEvent>, int scriptId, PassR
efPtrWillBeRawPtr<ScriptCallStack>, AccessControlStatus); |
89 | 91 |
90 virtual void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) = 0; | 92 virtual void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) = 0; |
91 virtual void logExceptionToConsole(const String& errorMessage, int scriptId,
const String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawP
tr<ScriptCallStack>) = 0; | 93 virtual void logExceptionToConsole(const String& errorMessage, int scriptId,
const String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawP
tr<ScriptCallStack>) = 0; |
92 | 94 |
93 PublicURLManager& publicURLManager(); | 95 PublicURLManager& publicURLManager(); |
94 | 96 |
| 97 // Active objects are not garbage collected even if inaccessible, e.g. becau
se their activity may result in callbacks being invoked. |
| 98 bool hasPendingActivity(); |
| 99 |
95 void suspendActiveDOMObjects(); | 100 void suspendActiveDOMObjects(); |
96 void resumeActiveDOMObjects(); | 101 void resumeActiveDOMObjects(); |
97 void stopActiveDOMObjects(); | 102 void stopActiveDOMObjects(); |
98 unsigned activeDOMObjectCount(); | 103 unsigned activeDOMObjectCount(); |
99 | 104 |
100 virtual void suspendScheduledTasks(); | 105 virtual void suspendScheduledTasks(); |
101 virtual void resumeScheduledTasks(); | 106 virtual void resumeScheduledTasks(); |
102 virtual bool tasksNeedSuspension() { return false; } | 107 virtual bool tasksNeedSuspension() { return false; } |
103 virtual void tasksWereSuspended() { } | 108 virtual void tasksWereSuspended() { } |
104 virtual void tasksWereResumed() { } | 109 virtual void tasksWereResumed() { } |
(...skipping 13 matching lines...) Expand all Loading... |
118 int circularSequentialID(); | 123 int circularSequentialID(); |
119 | 124 |
120 PassOwnPtr<LifecycleNotifier<ExecutionContext> > createLifecycleNotifier(); | 125 PassOwnPtr<LifecycleNotifier<ExecutionContext> > createLifecycleNotifier(); |
121 | 126 |
122 virtual EventTarget* errorEventTarget() = 0; | 127 virtual EventTarget* errorEventTarget() = 0; |
123 virtual EventQueue* eventQueue() const = 0; | 128 virtual EventQueue* eventQueue() const = 0; |
124 | 129 |
125 void enforceStrictMixedContentChecking() { m_strictMixedContentCheckingEnfor
ced = true; } | 130 void enforceStrictMixedContentChecking() { m_strictMixedContentCheckingEnfor
ced = true; } |
126 bool shouldEnforceStrictMixedContentChecking() const { return m_strictMixedC
ontentCheckingEnforced; } | 131 bool shouldEnforceStrictMixedContentChecking() const { return m_strictMixedC
ontentCheckingEnforced; } |
127 | 132 |
128 // Methods related to window interaction. It should be used to manage window | 133 void allowWindowFocus(); |
129 // focusing and window creation permission for an ExecutionContext. | 134 void consumeWindowFocus(); |
130 void allowWindowInteraction(); | 135 bool isWindowFocusAllowed() const; |
131 void consumeWindowInteraction(); | |
132 bool isWindowInteractionAllowed() const; | |
133 | 136 |
134 protected: | 137 protected: |
135 ExecutionContext(); | 138 ExecutionContext(); |
136 virtual ~ExecutionContext(); | 139 virtual ~ExecutionContext(); |
137 | 140 |
138 virtual const KURL& virtualURL() const = 0; | 141 virtual const KURL& virtualURL() const = 0; |
139 virtual KURL virtualCompleteURL(const String&) const = 0; | 142 virtual KURL virtualCompleteURL(const String&) const = 0; |
140 | 143 |
141 ContextLifecycleNotifier& lifecycleNotifier(); | 144 ContextLifecycleNotifier& lifecycleNotifier(); |
142 | 145 |
(...skipping 12 matching lines...) Expand all Loading... |
155 class PendingException; | 158 class PendingException; |
156 OwnPtrWillBeMember<WillBeHeapVector<OwnPtrWillBeMember<PendingException> > >
m_pendingExceptions; | 159 OwnPtrWillBeMember<WillBeHeapVector<OwnPtrWillBeMember<PendingException> > >
m_pendingExceptions; |
157 | 160 |
158 bool m_activeDOMObjectsAreSuspended; | 161 bool m_activeDOMObjectsAreSuspended; |
159 bool m_activeDOMObjectsAreStopped; | 162 bool m_activeDOMObjectsAreStopped; |
160 | 163 |
161 OwnPtrWillBeMember<PublicURLManager> m_publicURLManager; | 164 OwnPtrWillBeMember<PublicURLManager> m_publicURLManager; |
162 | 165 |
163 bool m_strictMixedContentCheckingEnforced; | 166 bool m_strictMixedContentCheckingEnforced; |
164 | 167 |
165 // Counter that keeps track of how many window interaction calls are allowed | 168 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; |
166 // for this ExecutionContext. Callers are expected to call | 169 |
167 // |allowWindowInteraction()| and |consumeWindowInteraction()| in order to | 170 // Counter that keeps track of how many window focus calls are allowed for |
168 // increment and decrement the counter. | 171 // this ExecutionContext. Callers are expected to call |allowWindowFocus()| |
169 int m_windowInteractionTokens; | 172 // and |consumeWindowFocus()| in order to increment and decrement the |
| 173 // counter. |
| 174 int m_windowFocusTokens; |
170 }; | 175 }; |
171 | 176 |
172 } // namespace blink | 177 } // namespace blink |
173 | 178 |
174 #endif // ExecutionContext_h | 179 #endif // ExecutionContext_h |
OLD | NEW |