| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 , m_workerInspectorProxy(WorkerInspectorProxy::create()) | 85 , m_workerInspectorProxy(WorkerInspectorProxy::create()) |
| 86 , m_client(client) | 86 , m_client(client) |
| 87 , m_pauseWorkerContextOnStart(false) | 87 , m_pauseWorkerContextOnStart(false) |
| 88 , m_isPausedOnStart(false) | 88 , m_isPausedOnStart(false) |
| 89 , m_creationAddressSpace(WebAddressSpacePublic) | 89 , m_creationAddressSpace(WebAddressSpacePublic) |
| 90 { | 90 { |
| 91 } | 91 } |
| 92 | 92 |
| 93 WebSharedWorkerImpl::~WebSharedWorkerImpl() | 93 WebSharedWorkerImpl::~WebSharedWorkerImpl() |
| 94 { | 94 { |
| 95 ASSERT(m_webView); | 95 DCHECK(m_webView); |
| 96 // Detach the client before closing the view to avoid getting called back. | 96 // Detach the client before closing the view to avoid getting called back. |
| 97 m_mainFrame->setClient(0); | 97 m_mainFrame->setClient(0); |
| 98 | 98 |
| 99 m_webView->close(); | 99 m_webView->close(); |
| 100 m_mainFrame->close(); | 100 m_mainFrame->close(); |
| 101 if (m_loaderProxy) | 101 if (m_loaderProxy) |
| 102 m_loaderProxy->detachProvider(this); | 102 m_loaderProxy->detachProvider(this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void WebSharedWorkerImpl::terminateWorkerThread() | 105 void WebSharedWorkerImpl::terminateWorkerThread() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 117 if (m_workerThread) | 117 if (m_workerThread) |
| 118 m_workerThread->terminate(); | 118 m_workerThread->terminate(); |
| 119 m_workerInspectorProxy->workerThreadTerminated(); | 119 m_workerInspectorProxy->workerThreadTerminated(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void WebSharedWorkerImpl::initializeLoader() | 122 void WebSharedWorkerImpl::initializeLoader() |
| 123 { | 123 { |
| 124 // Create 'shadow page'. This page is never displayed, it is used to proxy t
he | 124 // Create 'shadow page'. This page is never displayed, it is used to proxy t
he |
| 125 // loading requests from the worker context to the rest of WebKit and Chromi
um | 125 // loading requests from the worker context to the rest of WebKit and Chromi
um |
| 126 // infrastructure. | 126 // infrastructure. |
| 127 ASSERT(!m_webView); | 127 DCHECK(!m_webView); |
| 128 m_webView = WebView::create(0); | 128 m_webView = WebView::create(0); |
| 129 // FIXME: http://crbug.com/363843. This needs to find a better way to | 129 // FIXME: http://crbug.com/363843. This needs to find a better way to |
| 130 // not create graphics layers. | 130 // not create graphics layers. |
| 131 m_webView->settings()->setAcceleratedCompositingEnabled(false); | 131 m_webView->settings()->setAcceleratedCompositingEnabled(false); |
| 132 // FIXME: Settings information should be passed to the Worker process from B
rowser process when the worker | 132 // FIXME: Settings information should be passed to the Worker process from B
rowser process when the worker |
| 133 // is created (similar to RenderThread::OnCreateNewView). | 133 // is created (similar to RenderThread::OnCreateNewView). |
| 134 m_mainFrame = toWebLocalFrameImpl(WebLocalFrame::create(WebTreeScopeType::Do
cument, this)); | 134 m_mainFrame = toWebLocalFrameImpl(WebLocalFrame::create(WebTreeScopeType::Do
cument, this)); |
| 135 m_webView->setMainFrame(m_mainFrame.get()); | 135 m_webView->setMainFrame(m_mainFrame.get()); |
| 136 m_mainFrame->setDevToolsAgentClient(this); | 136 m_mainFrame->setDevToolsAgentClient(this); |
| 137 | 137 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 161 void WebSharedWorkerImpl::willSendRequest( | 161 void WebSharedWorkerImpl::willSendRequest( |
| 162 WebLocalFrame* frame, unsigned, WebURLRequest& request, | 162 WebLocalFrame* frame, unsigned, WebURLRequest& request, |
| 163 const WebURLResponse& redirectResponse) | 163 const WebURLResponse& redirectResponse) |
| 164 { | 164 { |
| 165 if (m_networkProvider) | 165 if (m_networkProvider) |
| 166 m_networkProvider->willSendRequest(frame->dataSource(), request); | 166 m_networkProvider->willSendRequest(frame->dataSource(), request); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) | 169 void WebSharedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) |
| 170 { | 170 { |
| 171 ASSERT(!m_loadingDocument); | 171 DCHECK(!m_loadingDocument); |
| 172 ASSERT(!m_mainScriptLoader); | 172 DCHECK(!m_mainScriptLoader); |
| 173 m_networkProvider = adoptPtr(m_client->createServiceWorkerNetworkProvider(fr
ame->dataSource())); | 173 m_networkProvider = adoptPtr(m_client->createServiceWorkerNetworkProvider(fr
ame->dataSource())); |
| 174 m_mainScriptLoader = WorkerScriptLoader::create(); | 174 m_mainScriptLoader = WorkerScriptLoader::create(); |
| 175 m_mainScriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); | 175 m_mainScriptLoader->setRequestContext(WebURLRequest::RequestContextSharedWor
ker); |
| 176 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); | 176 m_loadingDocument = toWebLocalFrameImpl(frame)->frame()->document(); |
| 177 m_mainScriptLoader->loadAsynchronously( | 177 m_mainScriptLoader->loadAsynchronously( |
| 178 *m_loadingDocument.get(), | 178 *m_loadingDocument.get(), |
| 179 m_url, | 179 m_url, |
| 180 DenyCrossOriginRequests, | 180 DenyCrossOriginRequests, |
| 181 m_creationAddressSpace, | 181 m_creationAddressSpace, |
| 182 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, this), | 182 bind(&WebSharedWorkerImpl::didReceiveScriptLoaderResponse, this), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() | 300 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() |
| 301 { | 301 { |
| 302 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(),
m_mainScriptLoader->identifier()); | 302 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(),
m_mainScriptLoader->identifier()); |
| 303 m_client->selectAppCacheID(m_mainScriptLoader->appCacheID()); | 303 m_client->selectAppCacheID(m_mainScriptLoader->appCacheID()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void WebSharedWorkerImpl::onScriptLoaderFinished() | 306 void WebSharedWorkerImpl::onScriptLoaderFinished() |
| 307 { | 307 { |
| 308 ASSERT(m_loadingDocument); | 308 DCHECK(m_loadingDocument); |
| 309 ASSERT(m_mainScriptLoader); | 309 DCHECK(m_mainScriptLoader); |
| 310 if (m_askedToTerminate) | 310 if (m_askedToTerminate) |
| 311 return; | 311 return; |
| 312 if (m_mainScriptLoader->failed()) { | 312 if (m_mainScriptLoader->failed()) { |
| 313 m_mainScriptLoader->cancel(); | 313 m_mainScriptLoader->cancel(); |
| 314 m_client->workerScriptLoadFailed(); | 314 m_client->workerScriptLoadFailed(); |
| 315 | 315 |
| 316 // The SharedWorker was unable to load the initial script, so | 316 // The SharedWorker was unable to load the initial script, so |
| 317 // shut it down right here. | 317 // shut it down right here. |
| 318 delete this; | 318 delete this; |
| 319 return; | 319 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 if (devtoolsAgent) | 389 if (devtoolsAgent) |
| 390 devtoolsAgent->dispatchOnInspectorBackend(sessionId, message); | 390 devtoolsAgent->dispatchOnInspectorBackend(sessionId, message); |
| 391 } | 391 } |
| 392 | 392 |
| 393 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) | 393 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) |
| 394 { | 394 { |
| 395 return new WebSharedWorkerImpl(client); | 395 return new WebSharedWorkerImpl(client); |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace blink | 398 } // namespace blink |
| OLD | NEW |