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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 #include "core/workers/WorkerClients.h" | 49 #include "core/workers/WorkerClients.h" |
50 #include "core/workers/WorkerLocation.h" | 50 #include "core/workers/WorkerLocation.h" |
51 #include "core/workers/WorkerReportingProxy.h" | 51 #include "core/workers/WorkerReportingProxy.h" |
52 #include "core/workers/WorkerScriptLoader.h" | 52 #include "core/workers/WorkerScriptLoader.h" |
53 #include "core/workers/WorkerThread.h" | 53 #include "core/workers/WorkerThread.h" |
54 #include "platform/weborigin/KURL.h" | 54 #include "platform/weborigin/KURL.h" |
55 #include "platform/weborigin/SecurityOrigin.h" | 55 #include "platform/weborigin/SecurityOrigin.h" |
56 | 56 |
57 namespace WebCore { | 57 namespace WebCore { |
58 | 58 |
59 class CloseWorkerGlobalScopeTask : public ExecutionContextTask { | 59 class CloseWorkerGlobalScopeTask : public ExecutionContextTask { |
haraken
2014/02/27 02:46:01
Now that we call WorkerGlobalScope::detach() when
sof
2014/02/27 08:50:37
This is to handled script-initiated closing (via c
haraken
2014/02/27 09:07:20
Thanks for the clarification. Keeping the CloseWor
| |
60 public: | 60 public: |
61 static PassOwnPtr<CloseWorkerGlobalScopeTask> create() | 61 static PassOwnPtr<CloseWorkerGlobalScopeTask> create() |
62 { | 62 { |
63 return adoptPtr(new CloseWorkerGlobalScopeTask); | 63 return adoptPtr(new CloseWorkerGlobalScopeTask); |
64 } | 64 } |
65 | 65 |
66 virtual void performTask(ExecutionContext *context) | 66 virtual void performTask(ExecutionContext *context) |
67 { | 67 { |
68 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 68 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
69 // Notify parent that this context is closed. Parent is responsible for calling WorkerThread::stop(). | 69 // Notify parent that this context is closed. Parent is responsible for calling WorkerThread::stop(). |
(...skipping 15 matching lines...) Expand all Loading... | |
85 , m_timeOrigin(timeOrigin) | 85 , m_timeOrigin(timeOrigin) |
86 { | 86 { |
87 ScriptWrappable::init(this); | 87 ScriptWrappable::init(this); |
88 setClient(this); | 88 setClient(this); |
89 setSecurityOrigin(SecurityOrigin::create(url)); | 89 setSecurityOrigin(SecurityOrigin::create(url)); |
90 m_workerClients->reattachThread(); | 90 m_workerClients->reattachThread(); |
91 } | 91 } |
92 | 92 |
93 WorkerGlobalScope::~WorkerGlobalScope() | 93 WorkerGlobalScope::~WorkerGlobalScope() |
94 { | 94 { |
95 ASSERT(thread()->isCurrentThread()); | 95 ASSERT(!m_thread); |
96 | |
97 // Notify proxy that we are going away. This can free the WorkerThread objec t, so do not access it after this. | |
98 thread()->workerReportingProxy().workerGlobalScopeDestroyed(); | |
99 | |
100 setClient(0); | |
101 } | 96 } |
102 | 97 |
103 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic y, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) | 98 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic y, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) |
104 { | 99 { |
105 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); | 100 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
106 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType, ContentSecurityPolicy::HeaderSourceHTTP); | 101 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType, ContentSecurityPolicy::HeaderSourceHTTP); |
107 } | 102 } |
108 | 103 |
109 ExecutionContext* WorkerGlobalScope::executionContext() const | 104 ExecutionContext* WorkerGlobalScope::executionContext() const |
110 { | 105 { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) | 177 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) |
183 { | 178 { |
184 thread()->runLoop().postTask(task); | 179 thread()->runLoop().postTask(task); |
185 } | 180 } |
186 | 181 |
187 void WorkerGlobalScope::clearInspector() | 182 void WorkerGlobalScope::clearInspector() |
188 { | 183 { |
189 m_workerInspectorController.clear(); | 184 m_workerInspectorController.clear(); |
190 } | 185 } |
191 | 186 |
187 void WorkerGlobalScope::detach() | |
188 { | |
189 ASSERT(thread()->isCurrentThread()); | |
190 | |
191 // Notify proxy that we are going away. This can free the WorkerThread objec t, so do not access it after this. | |
192 thread()->workerReportingProxy().workerGlobalScopeDestroyed(); | |
193 | |
194 clearScript(); | |
195 clearInspector(); | |
196 setClient(0); | |
197 clearThread(); | |
198 } | |
199 | |
192 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState & exceptionState) | 200 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState & exceptionState) |
193 { | 201 { |
194 ASSERT(contentSecurityPolicy()); | 202 ASSERT(contentSecurityPolicy()); |
195 Vector<String>::const_iterator urlsEnd = urls.end(); | 203 Vector<String>::const_iterator urlsEnd = urls.end(); |
196 Vector<KURL> completedURLs; | 204 Vector<KURL> completedURLs; |
197 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) { | 205 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) { |
198 const KURL& url = executionContext()->completeURL(*it); | 206 const KURL& url = executionContext()->completeURL(*it); |
199 if (!url.isValid()) { | 207 if (!url.isValid()) { |
200 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "' is invalid."); | 208 exceptionState.throwDOMException(SyntaxError, "The URL '" + *it + "' is invalid."); |
201 return; | 209 return; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 bool WorkerGlobalScope::idleNotification() | 281 bool WorkerGlobalScope::idleNotification() |
274 { | 282 { |
275 return script()->idleNotification(); | 283 return script()->idleNotification(); |
276 } | 284 } |
277 | 285 |
278 WorkerEventQueue* WorkerGlobalScope::eventQueue() const | 286 WorkerEventQueue* WorkerGlobalScope::eventQueue() const |
279 { | 287 { |
280 return m_eventQueue.get(); | 288 return m_eventQueue.get(); |
281 } | 289 } |
282 | 290 |
291 void WorkerGlobalScope::trace(Visitor* visitor) | |
292 { | |
293 visitor->trace(m_console); | |
294 visitor->trace(m_location); | |
295 visitor->trace(m_navigator); | |
296 WorkerSupplementable::trace(visitor); | |
297 } | |
298 | |
283 } // namespace WebCore | 299 } // namespace WebCore |
OLD | NEW |