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 11 matching lines...) Expand all Loading... |
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 ScriptExecutionContext_h | 28 #ifndef ScriptExecutionContext_h |
29 #define ScriptExecutionContext_h | 29 #define ScriptExecutionContext_h |
30 | 30 |
31 #include "core/dom/ActiveDOMObject.h" | 31 #include "core/dom/ActiveDOMObject.h" |
| 32 #include "core/dom/LifecycleContext.h" |
32 #include "core/dom/SecurityContext.h" | 33 #include "core/dom/SecurityContext.h" |
33 #include "core/page/ConsoleTypes.h" | 34 #include "core/page/ConsoleTypes.h" |
34 #include "core/platform/Supplementable.h" | 35 #include "core/platform/Supplementable.h" |
35 #include "weborigin/KURL.h" | 36 #include "weborigin/KURL.h" |
36 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
37 | 38 |
38 namespace WebCore { | 39 namespace WebCore { |
39 | 40 |
40 class CachedScript; | 41 class CachedScript; |
41 class ContextLifecycleNotifier; | 42 class ContextLifecycleNotifier; |
42 class DatabaseContext; | 43 class DatabaseContext; |
43 class DOMTimer; | 44 class DOMTimer; |
44 class EventListener; | 45 class EventListener; |
45 class EventQueue; | 46 class EventQueue; |
46 class EventTarget; | 47 class EventTarget; |
47 class MessagePort; | 48 class MessagePort; |
48 class PublicURLManager; | 49 class PublicURLManager; |
49 class ScriptCallStack; | 50 class ScriptCallStack; |
50 class ScriptState; | 51 class ScriptState; |
51 | 52 |
52 class ScriptExecutionContext : public SecurityContext, public Supplementable<Scr
iptExecutionContext> { | 53 class ScriptExecutionContext : public LifecycleContext, public SecurityContext,
public Supplementable<ScriptExecutionContext> { |
53 public: | 54 public: |
54 ScriptExecutionContext(); | 55 ScriptExecutionContext(); |
55 virtual ~ScriptExecutionContext(); | 56 virtual ~ScriptExecutionContext(); |
56 | 57 |
57 virtual bool isDocument() const { return false; } | 58 virtual bool isDocument() const { return false; } |
58 virtual bool isWorkerGlobalScope() const { return false; } | 59 virtual bool isWorkerGlobalScope() const { return false; } |
59 | 60 |
60 virtual bool isContextThread() const { return true; } | |
61 virtual bool isJSExecutionForbidden() const = 0; | 61 virtual bool isJSExecutionForbidden() const = 0; |
62 | 62 |
63 const KURL& url() const { return virtualURL(); } | 63 const KURL& url() const { return virtualURL(); } |
64 KURL completeURL(const String& url) const { return virtualCompleteURL(url);
} | 64 KURL completeURL(const String& url) const { return virtualCompleteURL(url);
} |
65 | 65 |
66 virtual String userAgent(const KURL&) const = 0; | 66 virtual String userAgent(const KURL&) const = 0; |
67 | 67 |
68 virtual void disableEval(const String& errorMessage) = 0; | 68 virtual void disableEval(const String& errorMessage) = 0; |
69 | 69 |
70 bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sour
ceURL, CachedScript* = 0); | 70 bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sour
ceURL, CachedScript* = 0); |
(...skipping 15 matching lines...) Expand all Loading... |
86 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); | 86 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); |
87 virtual void resumeActiveDOMObjects(); | 87 virtual void resumeActiveDOMObjects(); |
88 virtual void stopActiveDOMObjects(); | 88 virtual void stopActiveDOMObjects(); |
89 | 89 |
90 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp
ended; } | 90 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp
ended; } |
91 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe
d; } | 91 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe
d; } |
92 | 92 |
93 // Called after the construction of an ActiveDOMObject to synchronize suspen
d state. | 93 // Called after the construction of an ActiveDOMObject to synchronize suspen
d state. |
94 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); | 94 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); |
95 | 95 |
96 // Called from the constructor and destructors of ContextLifecycleObserver | |
97 void wasObservedBy(ContextLifecycleObserver*, ContextLifecycleObserver::Type
as); | |
98 void wasUnobservedBy(ContextLifecycleObserver*, ContextLifecycleObserver::Ty
pe as); | |
99 | |
100 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be
tracked separately for message dispatch. | 96 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be
tracked separately for message dispatch. |
101 void processMessagePortMessagesSoon(); | 97 void processMessagePortMessagesSoon(); |
102 void dispatchMessagePortEvents(); | 98 void dispatchMessagePortEvents(); |
103 void createdMessagePort(MessagePort*); | 99 void createdMessagePort(MessagePort*); |
104 void destroyedMessagePort(MessagePort*); | 100 void destroyedMessagePort(MessagePort*); |
105 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; } | 101 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; } |
106 | 102 |
107 void ref() { refScriptExecutionContext(); } | 103 void ref() { refScriptExecutionContext(); } |
108 void deref() { derefScriptExecutionContext(); } | 104 void deref() { derefScriptExecutionContext(); } |
109 | 105 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 160 |
165 virtual void addMessage(MessageSource, MessageLevel, const String& message,
const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip
tState* = 0, unsigned long requestIdentifier = 0) = 0; | 161 virtual void addMessage(MessageSource, MessageLevel, const String& message,
const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip
tState* = 0, unsigned long requestIdentifier = 0) = 0; |
166 virtual EventTarget* errorEventTarget() = 0; | 162 virtual EventTarget* errorEventTarget() = 0; |
167 virtual void logExceptionToConsole(const String& errorMessage, const String&
sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0; | 163 virtual void logExceptionToConsole(const String& errorMessage, const String&
sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0; |
168 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const St
ring& sourceURL, CachedScript*); | 164 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const St
ring& sourceURL, CachedScript*); |
169 | 165 |
170 void closeMessagePorts(); | 166 void closeMessagePorts(); |
171 | 167 |
172 virtual void refScriptExecutionContext() = 0; | 168 virtual void refScriptExecutionContext() = 0; |
173 virtual void derefScriptExecutionContext() = 0; | 169 virtual void derefScriptExecutionContext() = 0; |
174 virtual PassOwnPtr<ContextLifecycleNotifier> createLifecycleNotifier(); | 170 virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE; |
175 | 171 |
176 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; | |
177 HashSet<MessagePort*> m_messagePorts; | 172 HashSet<MessagePort*> m_messagePorts; |
178 | 173 |
179 int m_circularSequentialID; | 174 int m_circularSequentialID; |
180 typedef HashMap<int, DOMTimer*> TimeoutMap; | 175 typedef HashMap<int, DOMTimer*> TimeoutMap; |
181 TimeoutMap m_timeouts; | 176 TimeoutMap m_timeouts; |
182 | 177 |
183 bool m_inDispatchErrorEvent; | 178 bool m_inDispatchErrorEvent; |
184 class PendingException; | 179 class PendingException; |
185 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions; | 180 OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions; |
186 | 181 |
187 bool m_activeDOMObjectsAreSuspended; | 182 bool m_activeDOMObjectsAreSuspended; |
188 ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects; | 183 ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects; |
189 bool m_activeDOMObjectsAreStopped; | 184 bool m_activeDOMObjectsAreStopped; |
190 | 185 |
191 OwnPtr<PublicURLManager> m_publicURLManager; | 186 OwnPtr<PublicURLManager> m_publicURLManager; |
192 | 187 |
193 RefPtr<DatabaseContext> m_databaseContext; | 188 RefPtr<DatabaseContext> m_databaseContext; |
194 }; | 189 }; |
195 | 190 |
196 } // namespace WebCore | 191 } // namespace WebCore |
197 | 192 |
198 #endif // ScriptExecutionContext_h | 193 #endif // ScriptExecutionContext_h |
OLD | NEW |