diff options
Diffstat (limited to 'WebCore/dom/ScriptExecutionContext.h')
-rw-r--r-- | WebCore/dom/ScriptExecutionContext.h | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/WebCore/dom/ScriptExecutionContext.h b/WebCore/dom/ScriptExecutionContext.h index 565dbe0..6f09e1a 100644 --- a/WebCore/dom/ScriptExecutionContext.h +++ b/WebCore/dom/ScriptExecutionContext.h @@ -27,17 +27,26 @@ #ifndef ScriptExecutionContext_h #define ScriptExecutionContext_h +#include "Console.h" +#include "KURL.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> +#include <wtf/PassRefPtr.h> +#include <wtf/Threading.h> namespace WebCore { class ActiveDOMObject; class MessagePort; - class KURL; class SecurityOrigin; + class ScriptString; class String; + enum MessageDestination { + InspectorControllerDestination, + ConsoleDestination, + }; + class ScriptExecutionContext { public: ScriptExecutionContext(); @@ -47,14 +56,27 @@ namespace WebCore { virtual bool isWorkerContext() const { return false; } const KURL& url() const { return virtualURL(); } + KURL completeURL(const String& url) const { return virtualCompleteURL(url); } + + SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } + + virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0; + virtual void addMessage(MessageDestination, MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL) = 0; + virtual void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString) = 0; // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked. + bool canSuspendActiveDOMObjects(); + // Active objects can be asked to suspend even if canSuspendActiveDOMObjects() returns 'false' - + // step-by-step JS debugging is one example. + void suspendActiveDOMObjects(); + void resumeActiveDOMObjects(); void stopActiveDOMObjects(); void createdActiveDOMObject(ActiveDOMObject*, void* upcastPointer); void destroyedActiveDOMObject(ActiveDOMObject*); - const HashMap<ActiveDOMObject*, void*>& activeDOMObjects() const { return m_activeDOMObjects; } + typedef const HashMap<ActiveDOMObject*, void*> ActiveDOMObjectsMap; + ActiveDOMObjectsMap& activeDOMObjects() const { return m_activeDOMObjects; } - // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be tracked separately for message dispatch, and for cross-heap GC support. + // MessagePort is conceptually a kind of ActiveDOMObject, but it needs to be tracked separately for message dispatch. void processMessagePortMessagesSoon(); void dispatchMessagePortEvents(); void createdMessagePort(MessagePort*); @@ -64,10 +86,26 @@ namespace WebCore { void ref() { refScriptExecutionContext(); } void deref() { derefScriptExecutionContext(); } + class Task : public ThreadSafeShared<Task> { + public: + virtual ~Task(); + virtual void performTask(ScriptExecutionContext*) = 0; + }; + + virtual void postTask(PassRefPtr<Task>) = 0; // Executes the task on context's thread asynchronously. + + protected: + // Explicitly override the security origin for this script context. + // Note: It is dangerous to change the security origin of a script context + // that already contains content. + void setSecurityOrigin(PassRefPtr<SecurityOrigin>); + private: virtual const KURL& virtualURL() const = 0; + virtual KURL virtualCompleteURL(const String&) const = 0; + + RefPtr<SecurityOrigin> m_securityOrigin; - bool m_firedMessagePortTimer; HashSet<MessagePort*> m_messagePorts; HashMap<ActiveDOMObject*, void*> m_activeDOMObjects; |