2
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
2
* Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4
4
* Redistribution and use in source and binary forms, with or without
5
5
* modification, are permitted provided that the following conditions
65
67
virtual String userAgent(const KURL&) const;
67
WorkerLocation* location() const { return m_location.get(); }
68
WorkerNavigator* navigator() const;
70
69
WorkerScriptController* script() { return m_script.get(); }
71
70
void clearScript() { return m_script.clear(); }
72
72
WorkerThread* thread() { return m_thread; }
74
74
bool hasPendingActivity() const;
78
78
virtual void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
79
79
virtual void scriptImported(unsigned long identifier, const String& sourceString);
81
virtual WorkerContext* toWorkerContext() { return this; }
81
virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously.
85
WorkerContext* self() { return this; }
86
WorkerLocation* location() const;
89
void importScripts(const Vector<String>& urls, const String& callerURL, int callerLine, ExceptionCode&);
90
WorkerNavigator* navigator() const;
93
// DedicatedWorkerGlobalScope
83
94
void postMessage(const String& message);
84
virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously.
95
void setOnmessage(PassRefPtr<EventListener> eventListener) { m_onmessageListener = eventListener; }
96
EventListener* onmessage() const { return m_onmessageListener.get(); }
87
99
int setTimeout(ScheduledAction*, int timeout);
89
101
int setInterval(ScheduledAction*, int timeout);
90
102
void clearInterval(int timeoutId);
92
void dispatchMessage(const String&);
94
105
virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
95
106
virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
96
107
virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);
98
void setOnmessage(PassRefPtr<EventListener> eventListener) { m_onmessageListener = eventListener; }
99
EventListener* onmessage() const { return m_onmessageListener.get(); }
101
109
typedef Vector<RefPtr<EventListener> > ListenerVector;
102
110
typedef HashMap<AtomicString, ListenerVector> EventListenersMap;
103
111
EventListenersMap& eventListeners() { return m_eventListeners; }
105
void importScripts(const Vector<String>& urls, const String& callerURL, int callerLine, ExceptionCode&);
113
void dispatchMessage(const String&);
115
// These methods are used for GC marking. See JSWorkerContext::mark() in
116
// JSWorkerContextCustom.cpp.
117
WorkerNavigator* optionalNavigator() const { return m_navigator.get(); }
118
WorkerLocation* optionalLocation() const { return m_location.get(); }
107
120
using RefCounted<WorkerContext>::ref;
108
121
using RefCounted<WorkerContext>::deref;
124
WorkerContext(const KURL&, const String&, WorkerThread*);
111
126
virtual void refScriptExecutionContext() { ref(); }
112
127
virtual void derefScriptExecutionContext() { deref(); }
113
128
virtual void refEventTarget() { ref(); }
114
129
virtual void derefEventTarget() { deref(); }
116
WorkerContext(const KURL&, const String&, WorkerThread*);
118
131
virtual const KURL& virtualURL() const;
119
132
virtual KURL virtualCompleteURL(const String&) const;
122
135
String m_userAgent;
123
RefPtr<WorkerLocation> m_location;
137
mutable RefPtr<WorkerLocation> m_location;
124
138
mutable RefPtr<WorkerNavigator> m_navigator;
126
140
OwnPtr<WorkerScriptController> m_script;