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 #if !ENABLE(OILPAN) | |
97 dispose(); | |
98 #endif | |
99 } | 96 } |
100 | 97 |
101 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic
y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) | 98 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic
y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) |
102 { | 99 { |
103 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); | 100 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
104 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType,
ContentSecurityPolicyHeaderSourceHTTP); | 101 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType,
ContentSecurityPolicyHeaderSourceHTTP); |
105 } | 102 } |
106 | 103 |
107 ExecutionContext* WorkerGlobalScope::executionContext() const | 104 ExecutionContext* WorkerGlobalScope::executionContext() const |
108 { | 105 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 186 |
190 void WorkerGlobalScope::willStopActiveDOMObjects() | 187 void WorkerGlobalScope::willStopActiveDOMObjects() |
191 { | 188 { |
192 lifecycleNotifier().notifyWillStopActiveDOMObjects(); | 189 lifecycleNotifier().notifyWillStopActiveDOMObjects(); |
193 } | 190 } |
194 | 191 |
195 void WorkerGlobalScope::dispose() | 192 void WorkerGlobalScope::dispose() |
196 { | 193 { |
197 ASSERT(thread()->isCurrentThread()); | 194 ASSERT(thread()->isCurrentThread()); |
198 | 195 |
199 // Notify proxy that we are going away. This can free the WorkerThread objec
t, so do not access it after this. | |
200 thread()->workerReportingProxy().workerGlobalScopeDestroyed(); | |
201 | |
202 clearScript(); | 196 clearScript(); |
203 clearInspector(); | 197 clearInspector(); |
204 setClient(0); | 198 setClient(0); |
205 | 199 |
206 // The thread reference isn't currently cleared, as the execution | 200 // Observers must not access the context of a disposed WorkerGlobalScope |
207 // context's thread is accessed by GCed lifetime objects when | 201 // lacking a thread object. |
208 // they're finalized. | 202 // |
209 // FIXME: oilpan: avoid by explicitly removing the WorkerGlobalScope | 203 // Notify them now that the context has been destroyed and explicitly remove |
210 // as an observable context right here. | 204 // them as observers. If this is delayed until the LifecycleNotifier of the |
| 205 // WorkerGlobalScope is garbage collected and destructed, some observers |
| 206 // may have access to the disposed object (it all depends on the order |
| 207 // the garbage collector finalizes these objects.) Prevent that situation fr
om |
| 208 // arising here. |
| 209 removeAllLifecycleObservers(); |
| 210 clearThread(); |
211 } | 211 } |
212 | 212 |
213 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) | 213 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState
& exceptionState) |
214 { | 214 { |
215 ASSERT(contentSecurityPolicy()); | 215 ASSERT(contentSecurityPolicy()); |
216 Vector<String>::const_iterator urlsEnd = urls.end(); | 216 Vector<String>::const_iterator urlsEnd = urls.end(); |
217 Vector<KURL> completedURLs; | 217 Vector<KURL> completedURLs; |
218 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ | 218 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it)
{ |
219 const KURL& url = executionContext()->completeURL(*it); | 219 const KURL& url = executionContext()->completeURL(*it); |
220 if (!url.isValid()) { | 220 if (!url.isValid()) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 { | 305 { |
306 visitor->trace(m_console); | 306 visitor->trace(m_console); |
307 visitor->trace(m_location); | 307 visitor->trace(m_location); |
308 visitor->trace(m_navigator); | 308 visitor->trace(m_navigator); |
309 #if ENABLE(OILPAN) | 309 #if ENABLE(OILPAN) |
310 HeapSupplementable<WorkerGlobalScope>::trace(visitor); | 310 HeapSupplementable<WorkerGlobalScope>::trace(visitor); |
311 #endif | 311 #endif |
312 } | 312 } |
313 | 313 |
314 } // namespace WebCore | 314 } // namespace WebCore |
OLD | NEW |