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) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 , m_timeOrigin(timeOrigin) | 86 , m_timeOrigin(timeOrigin) |
87 { | 87 { |
88 ScriptWrappable::init(this); | 88 ScriptWrappable::init(this); |
89 setClient(this); | 89 setClient(this); |
90 setSecurityOrigin(SecurityOrigin::create(url)); | 90 setSecurityOrigin(SecurityOrigin::create(url)); |
91 m_workerClients->reattachThread(); | 91 m_workerClients->reattachThread(); |
92 } | 92 } |
93 | 93 |
94 WorkerGlobalScope::~WorkerGlobalScope() | 94 WorkerGlobalScope::~WorkerGlobalScope() |
95 { | 95 { |
96 ASSERT(thread()->isCurrentThread()); | 96 #if !ENABLE(OILPAN) |
97 | 97 dispose(); |
98 // Notify proxy that we are going away. This can free the WorkerThread objec
t, so do not access it after this. | 98 #endif |
99 thread()->workerReportingProxy().workerGlobalScopeDestroyed(); | |
100 | |
101 setClient(0); | |
102 } | 99 } |
103 | 100 |
104 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic
y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) | 101 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic
y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) |
105 { | 102 { |
106 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); | 103 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
107 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType,
ContentSecurityPolicyHeaderSourceHTTP); | 104 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType,
ContentSecurityPolicyHeaderSourceHTTP); |
108 } | 105 } |
109 | 106 |
110 ExecutionContext* WorkerGlobalScope::executionContext() const | 107 ExecutionContext* WorkerGlobalScope::executionContext() const |
111 { | 108 { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) | 180 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) |
184 { | 181 { |
185 thread()->runLoop().postTask(task); | 182 thread()->runLoop().postTask(task); |
186 } | 183 } |
187 | 184 |
188 void WorkerGlobalScope::clearInspector() | 185 void WorkerGlobalScope::clearInspector() |
189 { | 186 { |
190 m_workerInspectorController.clear(); | 187 m_workerInspectorController.clear(); |
191 } | 188 } |
192 | 189 |
| 190 void WorkerGlobalScope::dispose() |
| 191 { |
| 192 ASSERT(thread()->isCurrentThread()); |
| 193 |
| 194 // Notify proxy that we are going away. This can free the WorkerThread objec
t, so do not access it after this. |
| 195 thread()->workerReportingProxy().workerGlobalScopeDestroyed(); |
| 196 |
| 197 clearScript(); |
| 198 clearInspector(); |
| 199 setClient(0); |
| 200 |
| 201 // The thread reference isn't currently cleared, as the execution |
| 202 // context's thread is accessed by GCed lifetime objects when |
| 203 // they're finalized. |
| 204 // FIXME: oilpan: avoid by explicitly removing the WorkerGlobalScope |
| 205 // as an observable context right here. |
| 206 } |
| 207 |
193 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) | 208 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) |
194 { | 209 { |
195 ASSERT(contentSecurityPolicy()); | 210 ASSERT(contentSecurityPolicy()); |
196 Vector<String>::const_iterator urlsEnd = urls.end(); | 211 Vector<String>::const_iterator urlsEnd = urls.end(); |
197 Vector<KURL> completedURLs; | 212 Vector<KURL> completedURLs; |
198 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ | 213 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ |
199 const KURL& url = executionContext()->completeURL(*it); | 214 const KURL& url = executionContext()->completeURL(*it); |
200 if (!url.isValid()) { | 215 if (!url.isValid()) { |
201 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "'
is invalid."); | 216 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "'
is invalid."); |
202 return; | 217 return; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 bool WorkerGlobalScope::idleNotification() | 289 bool WorkerGlobalScope::idleNotification() |
275 { | 290 { |
276 return script()->idleNotification(); | 291 return script()->idleNotification(); |
277 } | 292 } |
278 | 293 |
279 WorkerEventQueue* WorkerGlobalScope::eventQueue() const | 294 WorkerEventQueue* WorkerGlobalScope::eventQueue() const |
280 { | 295 { |
281 return m_eventQueue.get(); | 296 return m_eventQueue.get(); |
282 } | 297 } |
283 | 298 |
| 299 void WorkerGlobalScope::trace(Visitor* visitor) |
| 300 { |
| 301 visitor->trace(m_console); |
| 302 visitor->trace(m_location); |
| 303 visitor->trace(m_navigator); |
| 304 WillBeHeapSupplementable<WorkerGlobalScope>::trace(visitor); |
| 305 } |
| 306 |
284 } // namespace WebCore | 307 } // namespace WebCore |
OLD | NEW |