OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const KURL& url() const { return m_scriptLoader->responseURL(); } | 116 const KURL& url() const { return m_scriptLoader->responseURL(); } |
117 String script() const { return m_scriptLoader->script(); } | 117 String script() const { return m_scriptLoader->script(); } |
118 unsigned long identifier() const { return m_identifier; } | 118 unsigned long identifier() const { return m_identifier; } |
119 long long appCacheID() const { return m_appCacheID; } | 119 long long appCacheID() const { return m_appCacheID; } |
120 | 120 |
121 private: | 121 private: |
122 Loader() : m_scriptLoader(WorkerScriptLoader::create()), m_identifier(0), m_
appCacheID(0) | 122 Loader() : m_scriptLoader(WorkerScriptLoader::create()), m_identifier(0), m_
appCacheID(0) |
123 { | 123 { |
124 } | 124 } |
125 | 125 |
126 RefPtr<WorkerScriptLoader> m_scriptLoader; | 126 RefPtrWillBePersistent<WorkerScriptLoader> m_scriptLoader; |
127 unsigned long m_identifier; | 127 unsigned long m_identifier; |
128 long long m_appCacheID; | 128 long long m_appCacheID; |
129 Closure m_receiveResponseCallback; | 129 Closure m_receiveResponseCallback; |
130 Closure m_finishCallback; | 130 Closure m_finishCallback; |
131 }; | 131 }; |
132 | 132 |
133 // This function is called on the main thread to force to initialize some static | 133 // This function is called on the main thread to force to initialize some static |
134 // values used in WebKit before any worker thread is started. This is because in | 134 // values used in WebKit before any worker thread is started. This is because in |
135 // our worker processs, we do not run any WebKit code in main thread and thus | 135 // our worker processs, we do not run any WebKit code in main thread and thus |
136 // when multiple workers try to start at the same time, we might hit crash due | 136 // when multiple workers try to start at the same time, we might hit crash due |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) | 300 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) |
301 { | 301 { |
302 workerThread()->runLoop().postTask( | 302 workerThread()->runLoop().postTask( |
303 createCallbackTask(&connectTask, adoptPtr(webChannel))); | 303 createCallbackTask(&connectTask, adoptPtr(webChannel))); |
304 } | 304 } |
305 | 305 |
306 void WebSharedWorkerImpl::connectTask(ExecutionContext* context, PassOwnPtr<WebM
essagePortChannel> channel) | 306 void WebSharedWorkerImpl::connectTask(ExecutionContext* context, PassOwnPtr<WebM
essagePortChannel> channel) |
307 { | 307 { |
308 // Wrap the passed-in channel in a MessagePort, and send it off via a connec
t event. | 308 // Wrap the passed-in channel in a MessagePort, and send it off via a connec
t event. |
309 RefPtr<MessagePort> port = MessagePort::create(*context); | 309 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(*context); |
310 port->entangle(channel); | 310 port->entangle(channel); |
311 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 311 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
312 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop
e()); | 312 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop
e()); |
313 workerGlobalScope->dispatchEvent(createConnectEvent(port)); | 313 workerGlobalScope->dispatchEvent(createConnectEvent(port)); |
314 } | 314 } |
315 | 315 |
316 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString&
name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType poli
cyType) | 316 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString&
name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType poli
cyType) |
317 { | 317 { |
318 m_url = url; | 318 m_url = url; |
319 m_name = name; | 319 m_name = name; |
(...skipping 23 matching lines...) Expand all Loading... |
343 if (client()) | 343 if (client()) |
344 client()->workerScriptLoadFailed(); | 344 client()->workerScriptLoadFailed(); |
345 return; | 345 return; |
346 } | 346 } |
347 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG
lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; | 347 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG
lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; |
348 OwnPtr<WorkerClients> workerClients = WorkerClients::create(); | 348 OwnPtr<WorkerClients> workerClients = WorkerClients::create(); |
349 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); | 349 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c
reate()); |
350 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat
e()); | 350 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat
e()); |
351 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); | 351 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); |
352 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea
teWorkerPermissionClientProxy(webSecurityOrigin))); | 352 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea
teWorkerPermissionClientProxy(webSecurityOrigin))); |
353 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), star
tMode, m_contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::Head
erType>(m_policyType), workerClients.release()); | 353 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->sc
ript(), startMode, m_contentSecurityPolicy, static_cast<WebCore::ContentSecurity
Policy::HeaderType>(m_policyType), workerClients.release()); |
354 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData
.release())); | 354 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData
.release())); |
355 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); | 355 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri
ptLoader->identifier(), m_mainScriptLoader->script()); |
356 m_mainScriptLoader.clear(); | 356 m_mainScriptLoader.clear(); |
357 | 357 |
358 if (m_attachDevToolsOnStart) | 358 if (m_attachDevToolsOnStart) |
359 workerThread()->runLoop().postDebuggerTask(createCallbackTask(connectToW
orkerContextInspectorTask, true)); | 359 workerThread()->runLoop().postDebuggerTask(createCallbackTask(connectToW
orkerContextInspectorTask, true)); |
360 | 360 |
361 workerThread()->start(); | 361 workerThread()->start(); |
362 if (client()) | 362 if (client()) |
363 client()->workerScriptLoaded(); | 363 client()->workerScriptLoaded(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 workerThread()->runLoop().postDebuggerTask(createCallbackTask(dispatchOnInsp
ectorBackendTask, String(message))); | 431 workerThread()->runLoop().postDebuggerTask(createCallbackTask(dispatchOnInsp
ectorBackendTask, String(message))); |
432 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread()); | 432 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread()); |
433 } | 433 } |
434 | 434 |
435 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 435 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
436 { | 436 { |
437 return new WebSharedWorkerImpl(client); | 437 return new WebSharedWorkerImpl(client); |
438 } | 438 } |
439 | 439 |
440 } // namespace blink | 440 } // namespace blink |
OLD | NEW |