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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 void WebSharedWorkerImpl::initializeLoader() { | 121 void WebSharedWorkerImpl::initializeLoader() { |
122 // Create 'shadow page'. This page is never displayed, it is used to proxy the | 122 // Create 'shadow page'. This page is never displayed, it is used to proxy the |
123 // loading requests from the worker context to the rest of WebKit and Chromium | 123 // loading requests from the worker context to the rest of WebKit and Chromium |
124 // infrastructure. | 124 // infrastructure. |
125 DCHECK(!m_webView); | 125 DCHECK(!m_webView); |
126 m_webView = WebView::create(nullptr, WebPageVisibilityStateVisible); | 126 m_webView = WebView::create(nullptr, WebPageVisibilityStateVisible); |
127 // FIXME: http://crbug.com/363843. This needs to find a better way to | 127 // FIXME: http://crbug.com/363843. This needs to find a better way to |
128 // not create graphics layers. | 128 // not create graphics layers. |
129 m_webView->settings()->setAcceleratedCompositingEnabled(false); | 129 m_webView->settings()->setAcceleratedCompositingEnabled(false); |
130 // FIXME: Settings information should be passed to the Worker process from Bro
wser process when the worker | 130 // FIXME: Settings information should be passed to the Worker process from |
131 // is created (similar to RenderThread::OnCreateNewView). | 131 // Browser process when the worker is created (similar to |
| 132 // RenderThread::OnCreateNewView). |
132 m_mainFrame = toWebLocalFrameImpl( | 133 m_mainFrame = toWebLocalFrameImpl( |
133 WebLocalFrame::create(WebTreeScopeType::Document, this)); | 134 WebLocalFrame::create(WebTreeScopeType::Document, this)); |
134 m_webView->setMainFrame(m_mainFrame.get()); | 135 m_webView->setMainFrame(m_mainFrame.get()); |
135 m_mainFrame->setDevToolsAgentClient(this); | 136 m_mainFrame->setDevToolsAgentClient(this); |
136 | 137 |
137 // If we were asked to pause worker context on start and wait for debugger the
n it is the good time to do that. | 138 // If we were asked to pause worker context on start and wait for debugger |
| 139 // then it is the good time to do that. |
138 m_client->workerReadyForInspection(); | 140 m_client->workerReadyForInspection(); |
139 if (m_pauseWorkerContextOnStart) { | 141 if (m_pauseWorkerContextOnStart) { |
140 m_isPausedOnStart = true; | 142 m_isPausedOnStart = true; |
141 return; | 143 return; |
142 } | 144 } |
143 loadShadowPage(); | 145 loadShadowPage(); |
144 } | 146 } |
145 | 147 |
146 WebApplicationCacheHost* WebSharedWorkerImpl::createApplicationCacheHost( | 148 WebApplicationCacheHost* WebSharedWorkerImpl::createApplicationCacheHost( |
147 WebApplicationCacheHostClient* appcacheHostClient) { | 149 WebApplicationCacheHostClient* appcacheHostClient) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 &WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread, | 271 &WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread, |
270 crossThreadUnretained(this))); | 272 crossThreadUnretained(this))); |
271 } | 273 } |
272 | 274 |
273 void WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread() { | 275 void WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread() { |
274 m_client->workerContextDestroyed(); | 276 m_client->workerContextDestroyed(); |
275 // The lifetime of this proxy is controlled by the worker context. | 277 // The lifetime of this proxy is controlled by the worker context. |
276 delete this; | 278 delete this; |
277 } | 279 } |
278 | 280 |
279 // WorkerLoaderProxyProvider ---------------------------------------------------
-------- | 281 // WorkerLoaderProxyProvider ------------------------------------------------- |
280 | 282 |
281 void WebSharedWorkerImpl::postTaskToLoader( | 283 void WebSharedWorkerImpl::postTaskToLoader( |
282 const WebTraceLocation& location, | 284 const WebTraceLocation& location, |
283 std::unique_ptr<ExecutionContextTask> task) { | 285 std::unique_ptr<ExecutionContextTask> task) { |
284 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and | 286 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and |
285 // consider using m_mainThreadTaskRunners->get(TaskType::Networking) | 287 // consider using m_mainThreadTaskRunners->get(TaskType::Networking) |
286 // instead. | 288 // instead. |
287 m_mainFrame->frame()->document()->postTask(location, std::move(task)); | 289 m_mainFrame->frame()->document()->postTask(location, std::move(task)); |
288 } | 290 } |
289 | 291 |
290 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( | 292 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( |
291 const WebTraceLocation& location, | 293 const WebTraceLocation& location, |
292 std::unique_ptr<ExecutionContextTask> task) { | 294 std::unique_ptr<ExecutionContextTask> task) { |
293 m_workerThread->postTask(location, std::move(task)); | 295 m_workerThread->postTask(location, std::move(task)); |
294 } | 296 } |
295 | 297 |
296 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { | 298 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { |
297 workerThread()->postTask( | 299 workerThread()->postTask( |
298 BLINK_FROM_HERE, | 300 BLINK_FROM_HERE, |
299 createCrossThreadTask( | 301 createCrossThreadTask( |
300 &connectTask, passed(WebMessagePortChannelUniquePtr(webChannel)))); | 302 &connectTask, passed(WebMessagePortChannelUniquePtr(webChannel)))); |
301 } | 303 } |
302 | 304 |
303 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel, | 305 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel, |
304 ExecutionContext* context) { | 306 ExecutionContext* context) { |
305 // Wrap the passed-in channel in a MessagePort, and send it off via a connect
event. | 307 // Wrap the passed-in channel in a MessagePort, and send it off via a connect |
| 308 // event. |
306 MessagePort* port = MessagePort::create(*context); | 309 MessagePort* port = MessagePort::create(*context); |
307 port->entangle(std::move(channel)); | 310 port->entangle(std::move(channel)); |
308 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 311 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
309 ASSERT_WITH_SECURITY_IMPLICATION( | 312 ASSERT_WITH_SECURITY_IMPLICATION( |
310 workerGlobalScope->isSharedWorkerGlobalScope()); | 313 workerGlobalScope->isSharedWorkerGlobalScope()); |
311 workerGlobalScope->dispatchEvent(createConnectEvent(port)); | 314 workerGlobalScope->dispatchEvent(createConnectEvent(port)); |
312 } | 315 } |
313 | 316 |
314 void WebSharedWorkerImpl::startWorkerContext( | 317 void WebSharedWorkerImpl::startWorkerContext( |
315 const WebURL& url, | 318 const WebURL& url, |
(...skipping 22 matching lines...) Expand all Loading... |
338 m_mainScriptLoader->cancel(); | 341 m_mainScriptLoader->cancel(); |
339 m_client->workerScriptLoadFailed(); | 342 m_client->workerScriptLoadFailed(); |
340 | 343 |
341 // The SharedWorker was unable to load the initial script, so | 344 // The SharedWorker was unable to load the initial script, so |
342 // shut it down right here. | 345 // shut it down right here. |
343 delete this; | 346 delete this; |
344 return; | 347 return; |
345 } | 348 } |
346 | 349 |
347 Document* document = m_mainFrame->frame()->document(); | 350 Document* document = m_mainFrame->frame()->document(); |
348 // FIXME: this document's origin is pristine and without any extra privileges.
(crbug.com/254993) | 351 // FIXME: this document's origin is pristine and without any extra privileges. |
| 352 // (crbug.com/254993) |
349 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); | 353 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); |
350 | 354 |
351 WorkerClients* workerClients = WorkerClients::create(); | 355 WorkerClients* workerClients = WorkerClients::create(); |
352 provideLocalFileSystemToWorker(workerClients, | 356 provideLocalFileSystemToWorker(workerClients, |
353 LocalFileSystemClient::create()); | 357 LocalFileSystemClient::create()); |
354 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); | 358 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->getSecurityOrigin()); |
355 provideContentSettingsClientToWorker( | 359 provideContentSettingsClientToWorker( |
356 workerClients, | 360 workerClients, |
357 wrapUnique( | 361 wrapUnique( |
358 m_client->createWorkerContentSettingsClientProxy(webSecurityOrigin))); | 362 m_client->createWorkerContentSettingsClientProxy(webSecurityOrigin))); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 if (devtoolsAgent) | 436 if (devtoolsAgent) |
433 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, | 437 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, |
434 message); | 438 message); |
435 } | 439 } |
436 | 440 |
437 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { | 441 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { |
438 return new WebSharedWorkerImpl(client); | 442 return new WebSharedWorkerImpl(client); |
439 } | 443 } |
440 | 444 |
441 } // namespace blink | 445 } // namespace blink |
OLD | NEW |