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 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ASSERT((m_executionContext->isDocument() && isMainThread()) | 99 ASSERT((m_executionContext->isDocument() && isMainThread()) |
100 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); | 100 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); |
101 m_workerInspectorProxy->setWorkerGlobalScopeProxy(this); | 101 m_workerInspectorProxy->setWorkerGlobalScopeProxy(this); |
102 } | 102 } |
103 | 103 |
104 WorkerMessagingProxy::~WorkerMessagingProxy() | 104 WorkerMessagingProxy::~WorkerMessagingProxy() |
105 { | 105 { |
106 ASSERT(!m_workerObject); | 106 ASSERT(!m_workerObject); |
107 ASSERT((m_executionContext->isDocument() && isMainThread()) | 107 ASSERT((m_executionContext->isDocument() && isMainThread()) |
108 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); | 108 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e
xecutionContext.get())->thread()->isCurrentThread())); |
| 109 if (m_loaderProxy) |
| 110 m_loaderProxy->detachProvider(this); |
109 } | 111 } |
110 | 112 |
111 void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S
tring& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) | 113 void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S
tring& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) |
112 { | 114 { |
113 // FIXME: This need to be revisited when we support nested worker one day | 115 // FIXME: This need to be revisited when we support nested worker one day |
114 ASSERT(m_executionContext->isDocument()); | 116 ASSERT(m_executionContext->isDocument()); |
115 if (m_askedToTerminate) { | 117 if (m_askedToTerminate) { |
116 // Worker.terminate() could be called from JS before the thread was crea
ted. | 118 // Worker.terminate() could be called from JS before the thread was crea
ted. |
117 return; | 119 return; |
118 } | 120 } |
119 Document* document = toDocument(m_executionContext.get()); | 121 Document* document = toDocument(m_executionContext.get()); |
120 SecurityOrigin* starterOrigin = document->securityOrigin(); | 122 SecurityOrigin* starterOrigin = document->securityOrigin(); |
121 | 123 |
122 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(scriptURL, userAgent, sourceCode, startMode, document->contentSecu
rityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedH
eaderType(), starterOrigin, m_workerClients.release()); | 124 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(scriptURL, userAgent, sourceCode, startMode, document->contentSecu
rityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedH
eaderType(), starterOrigin, m_workerClients.release()); |
123 double originTime = document->loader() ? document->loader()->timing()->refer
enceMonotonicTime() : monotonicallyIncreasingTime(); | 125 double originTime = document->loader() ? document->loader()->timing()->refer
enceMonotonicTime() : monotonicallyIncreasingTime(); |
124 | 126 |
125 RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(*this,
*m_workerObjectProxy.get(), originTime, startupData.release()); | 127 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 128 RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(m_loade
rProxy, *m_workerObjectProxy.get(), originTime, startupData.release()); |
126 thread->start(); | 129 thread->start(); |
127 workerThreadCreated(thread); | 130 workerThreadCreated(thread); |
128 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work
erThread.get(), scriptURL); | 131 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work
erThread.get(), scriptURL); |
129 } | 132 } |
130 | 133 |
131 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) | 134 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) |
132 { | 135 { |
133 if (!m_workerObject || m_askedToTerminate) | 136 if (!m_workerObject || m_askedToTerminate) |
134 return; | 137 return; |
135 | 138 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 299 |
297 // FIXME: This need to be revisited when we support nested worker one day | 300 // FIXME: This need to be revisited when we support nested worker one day |
298 ASSERT(m_executionContext->isDocument()); | 301 ASSERT(m_executionContext->isDocument()); |
299 Document* document = toDocument(m_executionContext.get()); | 302 Document* document = toDocument(m_executionContext.get()); |
300 LocalFrame* frame = document->frame(); | 303 LocalFrame* frame = document->frame(); |
301 if (frame) | 304 if (frame) |
302 frame->console().adoptWorkerMessagesAfterTermination(this); | 305 frame->console().adoptWorkerMessagesAfterTermination(this); |
303 } | 306 } |
304 | 307 |
305 } // namespace blink | 308 } // namespace blink |
OLD | NEW |