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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 void WebSharedWorkerImpl::willSendRequest(WebLocalFrame* frame, | 164 void WebSharedWorkerImpl::willSendRequest(WebLocalFrame* frame, |
165 WebURLRequest& request) { | 165 WebURLRequest& request) { |
166 if (m_networkProvider) | 166 if (m_networkProvider) |
167 m_networkProvider->willSendRequest(frame->dataSource(), request); | 167 m_networkProvider->willSendRequest(frame->dataSource(), request); |
168 } | 168 } |
169 | 169 |
170 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { | 170 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { |
171 DCHECK(!m_loadingDocument); | 171 DCHECK(!m_loadingDocument); |
172 DCHECK(!m_mainScriptLoader); | 172 DCHECK(!m_mainScriptLoader); |
173 m_networkProvider = wrapUnique( | 173 m_networkProvider = WTF::wrapUnique( |
174 m_client->createServiceWorkerNetworkProvider(frame->dataSource())); | 174 m_client->createServiceWorkerNetworkProvider(frame->dataSource())); |
175 m_mainScriptLoader = WorkerScriptLoader::create(); | 175 m_mainScriptLoader = WorkerScriptLoader::create(); |
176 m_mainScriptLoader->setRequestContext( | 176 m_mainScriptLoader->setRequestContext( |
177 WebURLRequest::RequestContextSharedWorker); | 177 WebURLRequest::RequestContextSharedWorker); |
178 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); | 178 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); |
179 m_mainScriptLoader->loadAsynchronously( | 179 m_mainScriptLoader->loadAsynchronously( |
180 *m_loadingDocument.get(), m_url, DenyCrossOriginRequests, | 180 *m_loadingDocument.get(), m_url, DenyCrossOriginRequests, |
181 m_creationAddressSpace, | 181 m_creationAddressSpace, |
182 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, | 182 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, |
183 WTF::unretained(this)), | 183 WTF::unretained(this)), |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( | 315 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( |
316 const WebTraceLocation& location, | 316 const WebTraceLocation& location, |
317 std::unique_ptr<ExecutionContextTask> task) { | 317 std::unique_ptr<ExecutionContextTask> task) { |
318 m_workerThread->postTask(location, std::move(task)); | 318 m_workerThread->postTask(location, std::move(task)); |
319 } | 319 } |
320 | 320 |
321 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { | 321 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { |
322 workerThread()->postTask( | 322 workerThread()->postTask( |
323 BLINK_FROM_HERE, | 323 BLINK_FROM_HERE, |
324 createCrossThreadTask( | 324 createCrossThreadTask( |
325 &connectTask, passed(WebMessagePortChannelUniquePtr(webChannel)))); | 325 &connectTask, |
| 326 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); |
326 } | 327 } |
327 | 328 |
328 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel, | 329 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel, |
329 ExecutionContext* context) { | 330 ExecutionContext* context) { |
330 // Wrap the passed-in channel in a MessagePort, and send it off via a connect | 331 // Wrap the passed-in channel in a MessagePort, and send it off via a connect |
331 // event. | 332 // event. |
332 MessagePort* port = MessagePort::create(*context); | 333 MessagePort* port = MessagePort::create(*context); |
333 port->entangle(std::move(channel)); | 334 port->entangle(std::move(channel)); |
334 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 335 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
335 SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope()); | 336 SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // FIXME: this document's origin is pristine and without any extra privileges. | 374 // FIXME: this document's origin is pristine and without any extra privileges. |
374 // (crbug.com/254993) | 375 // (crbug.com/254993) |
375 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); | 376 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); |
376 | 377 |
377 WorkerClients* workerClients = WorkerClients::create(); | 378 WorkerClients* workerClients = WorkerClients::create(); |
378 provideLocalFileSystemToWorker(workerClients, | 379 provideLocalFileSystemToWorker(workerClients, |
379 LocalFileSystemClient::create()); | 380 LocalFileSystemClient::create()); |
380 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); | 381 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); |
381 provideContentSettingsClientToWorker( | 382 provideContentSettingsClientToWorker( |
382 workerClients, | 383 workerClients, |
383 wrapUnique( | 384 WTF::wrapUnique( |
384 m_client->createWorkerContentSettingsClientProxy(webSecurityOrigin))); | 385 m_client->createWorkerContentSettingsClientProxy(webSecurityOrigin))); |
385 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()); | 386 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()); |
386 ContentSecurityPolicy* contentSecurityPolicy = | 387 ContentSecurityPolicy* contentSecurityPolicy = |
387 m_mainScriptLoader->releaseContentSecurityPolicy(); | 388 m_mainScriptLoader->releaseContentSecurityPolicy(); |
388 WorkerThreadStartMode startMode = | 389 WorkerThreadStartMode startMode = |
389 m_workerInspectorProxy->workerStartMode(document); | 390 m_workerInspectorProxy->workerStartMode(document); |
390 std::unique_ptr<WorkerSettings> workerSettings = | 391 std::unique_ptr<WorkerSettings> workerSettings = |
391 wrapUnique(new WorkerSettings(document->settings())); | 392 WTF::wrapUnique(new WorkerSettings(document->settings())); |
392 std::unique_ptr<WorkerThreadStartupData> startupData = | 393 std::unique_ptr<WorkerThreadStartupData> startupData = |
393 WorkerThreadStartupData::create( | 394 WorkerThreadStartupData::create( |
394 m_url, m_loadingDocument->userAgent(), m_mainScriptLoader->script(), | 395 m_url, m_loadingDocument->userAgent(), m_mainScriptLoader->script(), |
395 nullptr, startMode, | 396 nullptr, startMode, |
396 contentSecurityPolicy ? contentSecurityPolicy->headers().get() | 397 contentSecurityPolicy ? contentSecurityPolicy->headers().get() |
397 : nullptr, | 398 : nullptr, |
398 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients, | 399 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients, |
399 m_mainScriptLoader->responseAddressSpace(), | 400 m_mainScriptLoader->responseAddressSpace(), |
400 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings)); | 401 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings)); |
401 | 402 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 if (devtoolsAgent) | 461 if (devtoolsAgent) |
461 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, | 462 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, |
462 message); | 463 message); |
463 } | 464 } |
464 | 465 |
465 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { | 466 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { |
466 return new WebSharedWorkerImpl(client); | 467 return new WebSharedWorkerImpl(client); |
467 } | 468 } |
468 | 469 |
469 } // namespace blink | 470 } // namespace blink |
OLD | NEW |