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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 virtual bool isCleanupTask() const { return true; } | 77 virtual bool isCleanupTask() const { return true; } |
78 }; | 78 }; |
79 | 79 |
80 WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, W
orkerThread* thread, double timeOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> wo
rkerClients) | 80 WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, W
orkerThread* thread, double timeOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> wo
rkerClients) |
81 : m_url(url) | 81 : m_url(url) |
82 , m_userAgent(userAgent) | 82 , m_userAgent(userAgent) |
83 , m_script(adoptPtr(new WorkerScriptController(*this))) | 83 , m_script(adoptPtr(new WorkerScriptController(*this))) |
84 , m_thread(thread) | 84 , m_thread(thread) |
85 , m_workerInspectorController(adoptPtr(new WorkerInspectorController(this))) | 85 , m_workerInspectorController(adoptRefWillBeNoop(new WorkerInspectorControll
er(this))) |
86 , m_closing(false) | 86 , m_closing(false) |
87 , m_eventQueue(WorkerEventQueue::create(this)) | 87 , m_eventQueue(WorkerEventQueue::create(this)) |
88 , m_workerClients(workerClients) | 88 , m_workerClients(workerClients) |
89 , m_timeOrigin(timeOrigin) | 89 , m_timeOrigin(timeOrigin) |
90 , m_terminationObserver(0) | 90 , m_terminationObserver(0) |
91 { | 91 { |
92 ScriptWrappable::init(this); | 92 ScriptWrappable::init(this); |
93 setClient(this); | 93 setClient(this); |
94 setSecurityOrigin(SecurityOrigin::create(url)); | 94 setSecurityOrigin(SecurityOrigin::create(url)); |
95 m_workerClients->reattachThread(); | 95 m_workerClients->reattachThread(); |
| 96 m_thread->setWorkerInspectorController(m_workerInspectorController.get()); |
96 } | 97 } |
97 | 98 |
98 WorkerGlobalScope::~WorkerGlobalScope() | 99 WorkerGlobalScope::~WorkerGlobalScope() |
99 { | 100 { |
100 } | 101 } |
101 | 102 |
102 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic
y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) | 103 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic
y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) |
103 { | 104 { |
104 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); | 105 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
105 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType,
ContentSecurityPolicyHeaderSourceHTTP); | 106 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType,
ContentSecurityPolicyHeaderSourceHTTP); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if (!m_navigator) | 177 if (!m_navigator) |
177 m_navigator = WorkerNavigator::create(m_userAgent); | 178 m_navigator = WorkerNavigator::create(m_userAgent); |
178 return m_navigator.get(); | 179 return m_navigator.get(); |
179 } | 180 } |
180 | 181 |
181 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) | 182 void WorkerGlobalScope::postTask(PassOwnPtr<ExecutionContextTask> task) |
182 { | 183 { |
183 thread()->postTask(task); | 184 thread()->postTask(task); |
184 } | 185 } |
185 | 186 |
| 187 // FIXME: Called twice, from WorkerThreadShutdownFinishTask and WorkerGlobalScop
e::dispose. |
186 void WorkerGlobalScope::clearInspector() | 188 void WorkerGlobalScope::clearInspector() |
187 { | 189 { |
| 190 if (!m_workerInspectorController) |
| 191 return; |
| 192 thread()->setWorkerInspectorController(nullptr); |
| 193 m_workerInspectorController->dispose(); |
188 m_workerInspectorController.clear(); | 194 m_workerInspectorController.clear(); |
189 } | 195 } |
190 | 196 |
191 void WorkerGlobalScope::registerTerminationObserver(TerminationObserver* observe
r) | 197 void WorkerGlobalScope::registerTerminationObserver(TerminationObserver* observe
r) |
192 { | 198 { |
193 ASSERT(!m_terminationObserver); | 199 ASSERT(!m_terminationObserver); |
194 ASSERT(observer); | 200 ASSERT(observer); |
195 m_terminationObserver = observer; | 201 m_terminationObserver = observer; |
196 } | 202 } |
197 | 203 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 void WorkerGlobalScope::countDeprecation(UseCounter::Feature) const | 338 void WorkerGlobalScope::countDeprecation(UseCounter::Feature) const |
333 { | 339 { |
334 // FIXME: How should we count features for shared/service workers? | 340 // FIXME: How should we count features for shared/service workers? |
335 } | 341 } |
336 | 342 |
337 void WorkerGlobalScope::trace(Visitor* visitor) | 343 void WorkerGlobalScope::trace(Visitor* visitor) |
338 { | 344 { |
339 visitor->trace(m_console); | 345 visitor->trace(m_console); |
340 visitor->trace(m_location); | 346 visitor->trace(m_location); |
341 visitor->trace(m_navigator); | 347 visitor->trace(m_navigator); |
| 348 visitor->trace(m_workerInspectorController); |
342 visitor->trace(m_eventQueue); | 349 visitor->trace(m_eventQueue); |
343 visitor->trace(m_workerClients); | 350 visitor->trace(m_workerClients); |
344 WillBeHeapSupplementable<WorkerGlobalScope>::trace(visitor); | 351 WillBeHeapSupplementable<WorkerGlobalScope>::trace(visitor); |
345 ExecutionContext::trace(visitor); | 352 ExecutionContext::trace(visitor); |
346 EventTargetWithInlineData::trace(visitor); | 353 EventTargetWithInlineData::trace(visitor); |
347 } | 354 } |
348 | 355 |
349 } // namespace blink | 356 } // namespace blink |
OLD | NEW |