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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "core/workers/WorkerReportingProxy.h" | 61 #include "core/workers/WorkerReportingProxy.h" |
62 #include "core/workers/WorkerScriptLoader.h" | 62 #include "core/workers/WorkerScriptLoader.h" |
63 #include "core/workers/WorkerThread.h" | 63 #include "core/workers/WorkerThread.h" |
64 #include "platform/network/ContentSecurityPolicyParsers.h" | 64 #include "platform/network/ContentSecurityPolicyParsers.h" |
65 #include "platform/weborigin/KURL.h" | 65 #include "platform/weborigin/KURL.h" |
66 #include "platform/weborigin/SecurityOrigin.h" | 66 #include "platform/weborigin/SecurityOrigin.h" |
67 #include "public/platform/WebURLRequest.h" | 67 #include "public/platform/WebURLRequest.h" |
68 | 68 |
69 namespace blink { | 69 namespace blink { |
70 | 70 |
71 class CloseWorkerGlobalScopeTask : public ExecutionContextTask { | |
72 public: | |
73 static PassOwnPtr<CloseWorkerGlobalScopeTask> create() | |
74 { | |
75 return adoptPtr(new CloseWorkerGlobalScopeTask); | |
76 } | |
77 | |
78 virtual void performTask(ExecutionContext *context) | |
79 { | |
80 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | |
81 // Notify parent that this context is closed. Parent is responsible for
calling WorkerThread::stop(). | |
82 workerGlobalScope->thread()->workerReportingProxy().workerGlobalScopeClo
sed(); | |
83 } | |
84 | |
85 virtual bool isCleanupTask() const { return true; } | |
86 }; | |
87 | |
88 WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, W
orkerThread* thread, double timeOrigin, const SecurityOrigin* starterOrigin, Pas
sOwnPtrWillBeRawPtr<WorkerClients> workerClients) | 71 WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, W
orkerThread* thread, double timeOrigin, const SecurityOrigin* starterOrigin, Pas
sOwnPtrWillBeRawPtr<WorkerClients> workerClients) |
89 : m_url(url) | 72 : m_url(url) |
90 , m_userAgent(userAgent) | 73 , m_userAgent(userAgent) |
91 , m_v8CacheOptions(V8CacheOptionsDefault) | 74 , m_v8CacheOptions(V8CacheOptionsDefault) |
92 , m_script(adoptPtr(new WorkerScriptController(*this, thread->isolate()))) | 75 , m_script(adoptPtr(new WorkerScriptController(*this, thread->isolate()))) |
93 , m_thread(thread) | 76 , m_thread(thread) |
94 , m_workerInspectorController(adoptRefWillBeNoop(new WorkerInspectorControll
er(this))) | 77 , m_workerInspectorController(adoptRefWillBeNoop(new WorkerInspectorControll
er(this))) |
95 , m_closing(false) | 78 , m_closing(false) |
96 , m_eventQueue(WorkerEventQueue::create(this)) | 79 , m_eventQueue(WorkerEventQueue::create(this)) |
97 , m_workerClients(workerClients) | 80 , m_workerClients(workerClients) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 152 |
170 WorkerLocation* WorkerGlobalScope::location() const | 153 WorkerLocation* WorkerGlobalScope::location() const |
171 { | 154 { |
172 if (!m_location) | 155 if (!m_location) |
173 m_location = WorkerLocation::create(m_url); | 156 m_location = WorkerLocation::create(m_url); |
174 return m_location.get(); | 157 return m_location.get(); |
175 } | 158 } |
176 | 159 |
177 void WorkerGlobalScope::close() | 160 void WorkerGlobalScope::close() |
178 { | 161 { |
179 if (m_closing) | 162 // Let current script run to completion, but tell the worker thread to shut
down after the script exits. |
180 return; | |
181 | |
182 // Let current script run to completion but prevent future script evaluation
s. | |
183 // After m_closing is set, all the tasks in the queue continue to be fetched
but only | |
184 // tasks with isCleanupTask()==true will be executed. | |
185 m_closing = true; | 163 m_closing = true; |
186 postTask(FROM_HERE, CloseWorkerGlobalScopeTask::create()); | |
187 } | 164 } |
188 | 165 |
189 WorkerConsole* WorkerGlobalScope::console() | 166 WorkerConsole* WorkerGlobalScope::console() |
190 { | 167 { |
191 if (!m_console) | 168 if (!m_console) |
192 m_console = WorkerConsole::create(this); | 169 m_console = WorkerConsole::create(this); |
193 return m_console.get(); | 170 return m_console.get(); |
194 } | 171 } |
195 | 172 |
196 WorkerNavigator* WorkerGlobalScope::navigator() const | 173 WorkerNavigator* WorkerGlobalScope::navigator() const |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 visitor->trace(m_timers); | 387 visitor->trace(m_timers); |
411 visitor->trace(m_messageStorage); | 388 visitor->trace(m_messageStorage); |
412 visitor->trace(m_pendingMessages); | 389 visitor->trace(m_pendingMessages); |
413 HeapSupplementable<WorkerGlobalScope>::trace(visitor); | 390 HeapSupplementable<WorkerGlobalScope>::trace(visitor); |
414 #endif | 391 #endif |
415 ExecutionContext::trace(visitor); | 392 ExecutionContext::trace(visitor); |
416 EventTargetWithInlineData::trace(visitor); | 393 EventTargetWithInlineData::trace(visitor); |
417 } | 394 } |
418 | 395 |
419 } // namespace blink | 396 } // namespace blink |
OLD | NEW |