| 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 14 matching lines...) Expand all Loading... |
| 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/SecurityContext.h" | 32 #include "core/dom/SecurityContext.h" |
| 33 #include "core/page/ConsoleTypes.h" | 33 #include "core/page/ConsoleTypes.h" |
| 34 #include "core/page/DOMTimer.h" | 34 #include "core/page/DOMTimer.h" |
| 35 #include "core/platform/LifecycleContext.h" |
| 35 #include "core/platform/Supplementable.h" | 36 #include "core/platform/Supplementable.h" |
| 36 #include "weborigin/KURL.h" | 37 #include "weborigin/KURL.h" |
| 37 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
| 38 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
| 39 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
| 40 | 41 |
| 41 namespace WebCore { | 42 namespace WebCore { |
| 42 | 43 |
| 43 class CachedScript; | 44 class CachedScript; |
| 44 class ContextLifecycleNotifier; | 45 class ContextLifecycleNotifier; |
| 45 class DatabaseContext; | 46 class DatabaseContext; |
| 46 class EventListener; | 47 class EventListener; |
| 47 class EventQueue; | 48 class EventQueue; |
| 48 class EventTarget; | 49 class EventTarget; |
| 49 class MessagePort; | 50 class MessagePort; |
| 50 class PublicURLManager; | 51 class PublicURLManager; |
| 51 class ScriptCallStack; | 52 class ScriptCallStack; |
| 52 class ScriptState; | 53 class ScriptState; |
| 53 | 54 |
| 54 class ScriptExecutionContext : public SecurityContext, public Supplementable<Scr
iptExecutionContext> { | 55 class ScriptExecutionContext : public LifecycleContext, public SecurityContext,
public Supplementable<ScriptExecutionContext> { |
| 55 public: | 56 public: |
| 56 ScriptExecutionContext(); | 57 ScriptExecutionContext(); |
| 57 virtual ~ScriptExecutionContext(); | 58 virtual ~ScriptExecutionContext(); |
| 58 | 59 |
| 59 virtual bool isDocument() const { return false; } | 60 virtual bool isDocument() const { return false; } |
| 60 virtual bool isWorkerGlobalScope() const { return false; } | 61 virtual bool isWorkerGlobalScope() const { return false; } |
| 61 | 62 |
| 62 virtual bool isContextThread() const { return true; } | |
| 63 virtual bool isJSExecutionForbidden() const = 0; | 63 virtual bool isJSExecutionForbidden() const = 0; |
| 64 | 64 |
| 65 const KURL& url() const { return virtualURL(); } | 65 const KURL& url() const { return virtualURL(); } |
| 66 KURL completeURL(const String& url) const { return virtualCompleteURL(url);
} | 66 KURL completeURL(const String& url) const { return virtualCompleteURL(url);
} |
| 67 | 67 |
| 68 virtual String userAgent(const KURL&) const = 0; | 68 virtual String userAgent(const KURL&) const = 0; |
| 69 | 69 |
| 70 virtual void disableEval(const String& errorMessage) = 0; | 70 virtual void disableEval(const String& errorMessage) = 0; |
| 71 | 71 |
| 72 bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sour
ceURL, CachedScript* = 0); | 72 bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sour
ceURL, CachedScript* = 0); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 88 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); | 88 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); |
| 89 virtual void resumeActiveDOMObjects(); | 89 virtual void resumeActiveDOMObjects(); |
| 90 virtual void stopActiveDOMObjects(); | 90 virtual void stopActiveDOMObjects(); |
| 91 | 91 |
| 92 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp
ended; } | 92 bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSusp
ended; } |
| 93 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe
d; } | 93 bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStoppe
d; } |
| 94 | 94 |
| 95 // Called after the construction of an ActiveDOMObject to synchronize suspen
d state. | 95 // Called after the construction of an ActiveDOMObject to synchronize suspen
d state. |
| 96 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); | 96 void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); |
| 97 | 97 |
| 98 // Called from the constructor and destructors of ContextLifecycleObserver | |
| 99 void wasObservedBy(ContextLifecycleObserver*, ContextLifecycleObserver::Type
as); | |
| 100 void wasUnobservedBy(ContextLifecycleObserver*, ContextLifecycleObserver::Ty
pe as); | |
| 101 | |
| 102 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be
tracked separately for message dispatch. | 98 // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be
tracked separately for message dispatch. |
| 103 void processMessagePortMessagesSoon(); | 99 void processMessagePortMessagesSoon(); |
| 104 void dispatchMessagePortEvents(); | 100 void dispatchMessagePortEvents(); |
| 105 void createdMessagePort(MessagePort*); | 101 void createdMessagePort(MessagePort*); |
| 106 void destroyedMessagePort(MessagePort*); | 102 void destroyedMessagePort(MessagePort*); |
| 107 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; } | 103 const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; } |
| 108 | 104 |
| 109 void ref() { refScriptExecutionContext(); } | 105 void ref() { refScriptExecutionContext(); } |
| 110 void deref() { derefScriptExecutionContext(); } | 106 void deref() { derefScriptExecutionContext(); } |
| 111 | 107 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 158 |
| 163 virtual void addMessage(MessageSource, MessageLevel, const String& message,
const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip
tState* = 0, unsigned long requestIdentifier = 0) = 0; | 159 virtual void addMessage(MessageSource, MessageLevel, const String& message,
const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, Scrip
tState* = 0, unsigned long requestIdentifier = 0) = 0; |
| 164 virtual EventTarget* errorEventTarget() = 0; | 160 virtual EventTarget* errorEventTarget() = 0; |
| 165 virtual void logExceptionToConsole(const String& errorMessage, const String&
sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0; | 161 virtual void logExceptionToConsole(const String& errorMessage, const String&
sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0; |
| 166 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const St
ring& sourceURL, CachedScript*); | 162 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const St
ring& sourceURL, CachedScript*); |
| 167 | 163 |
| 168 void closeMessagePorts(); | 164 void closeMessagePorts(); |
| 169 | 165 |
| 170 virtual void refScriptExecutionContext() = 0; | 166 virtual void refScriptExecutionContext() = 0; |
| 171 virtual void derefScriptExecutionContext() = 0; | 167 virtual void derefScriptExecutionContext() = 0; |
| 172 virtual PassOwnPtr<ContextLifecycleNotifier> createLifecycleNotifier(); | 168 virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE; |
| 173 | 169 |
| 174 // Implementation details for DOMTimer. No other classes should call these f
unctions. | 170 // Implementation details for DOMTimer. No other classes should call these f
unctions. |
| 175 int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleS
hot); | 171 int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleS
hot); |
| 176 void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer ins
tance destructed. | 172 void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer ins
tance destructed. |
| 177 | 173 |
| 178 HashSet<MessagePort*> m_messagePorts; | 174 HashSet<MessagePort*> m_messagePorts; |
| 179 | 175 |
| 180 int m_circularSequentialID; | 176 int m_circularSequentialID; |
| 181 typedef HashMap<int, OwnPtr<DOMTimer> > TimeoutMap; | 177 typedef HashMap<int, OwnPtr<DOMTimer> > TimeoutMap; |
| 182 TimeoutMap m_timeouts; | 178 TimeoutMap m_timeouts; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 195 | 191 |
| 196 // The location of this member is important; to make sure contextDestroyed()
notification on | 192 // The location of this member is important; to make sure contextDestroyed()
notification on |
| 197 // ScriptExecutionContext's members (notably m_timeouts) is called before th
ey are destructed, | 193 // ScriptExecutionContext's members (notably m_timeouts) is called before th
ey are destructed, |
| 198 // m_lifecycleNotifer should be placed *after* such members. | 194 // m_lifecycleNotifer should be placed *after* such members. |
| 199 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; | 195 OwnPtr<ContextLifecycleNotifier> m_lifecycleNotifier; |
| 200 }; | 196 }; |
| 201 | 197 |
| 202 } // namespace WebCore | 198 } // namespace WebCore |
| 203 | 199 |
| 204 #endif // ScriptExecutionContext_h | 200 #endif // ScriptExecutionContext_h |
| OLD | NEW |