OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 class Blob; | 50 class Blob; |
51 class ExceptionState; | 51 class ExceptionState; |
52 class ScheduledAction; | 52 class ScheduledAction; |
53 class WorkerClients; | 53 class WorkerClients; |
54 class WorkerConsole; | 54 class WorkerConsole; |
55 class WorkerInspectorController; | 55 class WorkerInspectorController; |
56 class WorkerLocation; | 56 class WorkerLocation; |
57 class WorkerNavigator; | 57 class WorkerNavigator; |
58 class WorkerThread; | 58 class WorkerThread; |
59 | 59 |
60 class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public Scrip
tWrappable, public SecurityContext, public ExecutionContext, public ExecutionCon
textClient, public WorkerSupplementable, public EventTargetWithInlineData { | 60 class WorkerGlobalScope : public RefCountedWillBeRefCountedGarbageCollected<
WorkerGlobalScope>, public ScriptWrappable, public SecurityContext, public Execu
tionContext, public ExecutionContextClient, public WorkerSupplementable, public
EventTargetWithInlineData { |
61 REFCOUNTED_EVENT_TARGET(WorkerGlobalScope); | 61 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollect
ed<WorkerGlobalScope>); |
62 public: | 62 public: |
63 virtual ~WorkerGlobalScope(); | 63 virtual ~WorkerGlobalScope(); |
64 | 64 |
65 virtual bool isWorkerGlobalScope() const OVERRIDE FINAL { return true; } | 65 virtual bool isWorkerGlobalScope() const OVERRIDE FINAL { return true; } |
66 | 66 |
67 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; | 67 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; |
68 | 68 |
69 virtual bool isSharedWorkerGlobalScope() const { return false; } | 69 virtual bool isSharedWorkerGlobalScope() const { return false; } |
70 virtual bool isDedicatedWorkerGlobalScope() const { return false; } | 70 virtual bool isDedicatedWorkerGlobalScope() const { return false; } |
71 virtual bool isServiceWorkerGlobalScope() const { return false; } | 71 virtual bool isServiceWorkerGlobalScope() const { return false; } |
72 | 72 |
73 const KURL& url() const { return m_url; } | 73 const KURL& url() const { return m_url; } |
74 KURL completeURL(const String&) const; | 74 KURL completeURL(const String&) const; |
75 | 75 |
76 virtual String userAgent(const KURL&) const OVERRIDE FINAL; | 76 virtual String userAgent(const KURL&) const OVERRIDE FINAL; |
77 virtual void disableEval(const String& errorMessage) OVERRIDE FINAL; | 77 virtual void disableEval(const String& errorMessage) OVERRIDE FINAL; |
78 | 78 |
79 WorkerScriptController* script() { return m_script.get(); } | 79 WorkerScriptController* script() { return m_script.get(); } |
80 void clearScript() { m_script.clear(); } | 80 void clearScript() { m_script.clear(); } |
81 void clearInspector(); | 81 void clearInspector(); |
82 | 82 |
| 83 void detach(); |
| 84 |
83 WorkerThread* thread() const { return m_thread; } | 85 WorkerThread* thread() const { return m_thread; } |
| 86 void clearThread() { m_thread = 0; } |
84 | 87 |
85 virtual void postTask(PassOwnPtr<ExecutionContextTask>) OVERRIDE FINAL;
// Executes the task on context's thread asynchronously. | 88 virtual void postTask(PassOwnPtr<ExecutionContextTask>) OVERRIDE FINAL;
// Executes the task on context's thread asynchronously. |
86 | 89 |
87 // WorkerGlobalScope | 90 // WorkerGlobalScope |
88 WorkerGlobalScope* self() { return this; } | 91 WorkerGlobalScope* self() { return this; } |
89 WorkerConsole* console(); | 92 WorkerConsole* console(); |
90 WorkerLocation* location() const; | 93 WorkerLocation* location() const; |
91 void close(); | 94 void close(); |
92 | 95 |
93 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
(...skipping 22 matching lines...) Expand all Loading... |
116 | 119 |
117 bool idleNotification(); | 120 bool idleNotification(); |
118 | 121 |
119 double timeOrigin() const { return m_timeOrigin; } | 122 double timeOrigin() const { return m_timeOrigin; } |
120 | 123 |
121 WorkerClients* clients() { return m_workerClients.get(); } | 124 WorkerClients* clients() { return m_workerClients.get(); } |
122 | 125 |
123 using SecurityContext::securityOrigin; | 126 using SecurityContext::securityOrigin; |
124 using SecurityContext::contentSecurityPolicy; | 127 using SecurityContext::contentSecurityPolicy; |
125 | 128 |
| 129 virtual void trace(Visitor*); |
| 130 |
126 protected: | 131 protected: |
127 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, d
ouble timeOrigin, PassOwnPtr<WorkerClients>); | 132 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, d
ouble timeOrigin, PassOwnPtr<WorkerClients>); |
128 void applyContentSecurityPolicyFromString(const String& contentSecurityP
olicy, ContentSecurityPolicy::HeaderType); | 133 void applyContentSecurityPolicyFromString(const String& contentSecurityP
olicy, ContentSecurityPolicy::HeaderType); |
129 | 134 |
130 virtual void logExceptionToConsole(const String& errorMessage, const Str
ing& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) O
VERRIDE; | 135 virtual void logExceptionToConsole(const String& errorMessage, const Str
ing& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) O
VERRIDE; |
131 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String
& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallSt
ack>, ScriptState*); | 136 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String
& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallSt
ack>, ScriptState*); |
132 | 137 |
133 private: | 138 private: |
134 virtual void refExecutionContext() OVERRIDE FINAL { ref(); } | 139 virtual void refExecutionContext() OVERRIDE FINAL { ref(); } |
135 virtual void derefExecutionContext() OVERRIDE FINAL { deref(); } | 140 virtual void derefExecutionContext() OVERRIDE FINAL { deref(); } |
136 | 141 |
137 virtual const KURL& virtualURL() const OVERRIDE FINAL; | 142 virtual const KURL& virtualURL() const OVERRIDE FINAL; |
138 virtual KURL virtualCompleteURL(const String&) const OVERRIDE FINAL; | 143 virtual KURL virtualCompleteURL(const String&) const OVERRIDE FINAL; |
139 | 144 |
140 virtual void reportBlockedScriptExecutionToInspector(const String& direc
tiveText) OVERRIDE FINAL; | 145 virtual void reportBlockedScriptExecutionToInspector(const String& direc
tiveText) OVERRIDE FINAL; |
141 virtual void addMessage(MessageSource, MessageLevel, const String& messa
ge, const String& sourceURL, unsigned lineNumber, ScriptState* = 0) OVERRIDE FIN
AL; | 146 virtual void addMessage(MessageSource, MessageLevel, const String& messa
ge, const String& sourceURL, unsigned lineNumber, ScriptState* = 0) OVERRIDE FIN
AL; |
142 | 147 |
143 virtual EventTarget* errorEventTarget() OVERRIDE FINAL; | 148 virtual EventTarget* errorEventTarget() OVERRIDE FINAL; |
144 virtual void didUpdateSecurityOrigin() OVERRIDE FINAL { } | 149 virtual void didUpdateSecurityOrigin() OVERRIDE FINAL { } |
145 | 150 |
146 KURL m_url; | 151 KURL m_url; |
147 String m_userAgent; | 152 String m_userAgent; |
148 | 153 |
149 mutable RefPtr<WorkerConsole> m_console; | 154 mutable RefPtrWillBeMember<WorkerConsole> m_console; |
150 mutable RefPtr<WorkerLocation> m_location; | 155 mutable RefPtrWillBeMember<WorkerLocation> m_location; |
151 mutable RefPtr<WorkerNavigator> m_navigator; | 156 mutable RefPtrWillBeMember<WorkerNavigator> m_navigator; |
152 | 157 |
153 OwnPtr<WorkerScriptController> m_script; | 158 OwnPtr<WorkerScriptController> m_script; |
154 WorkerThread* m_thread; | 159 WorkerThread* m_thread; |
155 | 160 |
156 OwnPtr<WorkerInspectorController> m_workerInspectorController; | 161 OwnPtr<WorkerInspectorController> m_workerInspectorController; |
157 bool m_closing; | 162 bool m_closing; |
158 | 163 |
159 HashSet<Observer*> m_workerObservers; | |
160 | |
161 OwnPtr<WorkerEventQueue> m_eventQueue; | 164 OwnPtr<WorkerEventQueue> m_eventQueue; |
162 | 165 |
163 OwnPtr<WorkerClients> m_workerClients; | 166 OwnPtr<WorkerClients> m_workerClients; |
164 | 167 |
165 double m_timeOrigin; | 168 double m_timeOrigin; |
166 }; | 169 }; |
167 | 170 |
168 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke
rGlobalScope(), context.isWorkerGlobalScope()); | 171 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke
rGlobalScope(), context.isWorkerGlobalScope()); |
169 | 172 |
170 } // namespace WebCore | 173 } // namespace WebCore |
171 | 174 |
172 #endif // WorkerGlobalScope_h | 175 #endif // WorkerGlobalScope_h |
OLD | NEW |