Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 #include "platform/heap/Handle.h" | 53 #include "platform/heap/Handle.h" |
| 54 #include "platform/network/ContentSecurityPolicyParsers.h" | 54 #include "platform/network/ContentSecurityPolicyParsers.h" |
| 55 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" | 55 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" |
| 56 #include "platform/network/NetworkUtils.h" | 56 #include "platform/network/NetworkUtils.h" |
| 57 #include "platform/weborigin/SecurityOrigin.h" | 57 #include "platform/weborigin/SecurityOrigin.h" |
| 58 #include "public/platform/Platform.h" | 58 #include "public/platform/Platform.h" |
| 59 #include "public/platform/WebURLRequest.h" | 59 #include "public/platform/WebURLRequest.h" |
| 60 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" | 60 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" |
| 61 #include "public/web/WebConsoleMessage.h" | 61 #include "public/web/WebConsoleMessage.h" |
| 62 #include "public/web/WebDevToolsAgent.h" | 62 #include "public/web/WebDevToolsAgent.h" |
| 63 #include "public/web/WebFrameWidget.h" | |
| 63 #include "public/web/WebSettings.h" | 64 #include "public/web/WebSettings.h" |
| 64 #include "public/web/WebView.h" | 65 #include "public/web/WebView.h" |
| 65 #include "public/web/WebWorkerContentSettingsClientProxy.h" | 66 #include "public/web/WebWorkerContentSettingsClientProxy.h" |
| 66 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" | 67 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" |
| 67 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" | 68 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" |
| 68 #include "web/IndexedDBClientImpl.h" | 69 #include "web/IndexedDBClientImpl.h" |
| 69 #include "web/ServiceWorkerGlobalScopeClientImpl.h" | 70 #include "web/ServiceWorkerGlobalScopeClientImpl.h" |
| 70 #include "web/ServiceWorkerGlobalScopeProxy.h" | 71 #include "web/ServiceWorkerGlobalScopeProxy.h" |
| 71 #include "web/WebDataSourceImpl.h" | 72 #include "web/WebDataSourceImpl.h" |
| 72 #include "web/WebLocalFrameImpl.h" | 73 #include "web/WebLocalFrameImpl.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 86 { | 87 { |
| 87 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); | 88 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); |
| 88 return set; | 89 return set; |
| 89 } | 90 } |
| 90 | 91 |
| 91 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(std::unique_ptr<WebServiceWorkerCon textClient> client, std::unique_ptr<WebWorkerContentSettingsClientProxy> content SettingsClient) | 92 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(std::unique_ptr<WebServiceWorkerCon textClient> client, std::unique_ptr<WebWorkerContentSettingsClientProxy> content SettingsClient) |
| 92 : m_workerContextClient(std::move(client)) | 93 : m_workerContextClient(std::move(client)) |
| 93 , m_contentSettingsClient(std::move(contentSettingsClient)) | 94 , m_contentSettingsClient(std::move(contentSettingsClient)) |
| 94 , m_workerInspectorProxy(WorkerInspectorProxy::create()) | 95 , m_workerInspectorProxy(WorkerInspectorProxy::create()) |
| 95 , m_webView(nullptr) | 96 , m_webView(nullptr) |
| 97 , m_webFrameWidget(nullptr) | |
| 96 , m_mainFrame(nullptr) | 98 , m_mainFrame(nullptr) |
| 97 , m_loadingShadowPage(false) | 99 , m_loadingShadowPage(false) |
| 98 , m_askedToTerminate(false) | 100 , m_askedToTerminate(false) |
| 99 , m_pauseAfterDownloadState(DontPauseAfterDownload) | 101 , m_pauseAfterDownloadState(DontPauseAfterDownload) |
| 100 , m_waitingForDebuggerState(NotWaitingForDebugger) | 102 , m_waitingForDebuggerState(NotWaitingForDebugger) |
| 101 { | 103 { |
| 102 runningWorkerInstances().add(this); | 104 runningWorkerInstances().add(this); |
| 103 } | 105 } |
| 104 | 106 |
| 105 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() | 107 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() |
| 106 { | 108 { |
| 107 // Prevent onScriptLoaderFinished from deleting 'this'. | 109 // Prevent onScriptLoaderFinished from deleting 'this'. |
| 108 m_askedToTerminate = true; | 110 m_askedToTerminate = true; |
| 109 | 111 |
| 110 if (m_workerThread) | 112 if (m_workerThread) |
| 111 m_workerThread->terminateAndWait(); | 113 m_workerThread->terminateAndWait(); |
| 112 | 114 |
| 113 DCHECK(runningWorkerInstances().contains(this)); | 115 DCHECK(runningWorkerInstances().contains(this)); |
| 114 runningWorkerInstances().remove(this); | 116 runningWorkerInstances().remove(this); |
| 115 DCHECK(m_webView); | 117 DCHECK(m_webView); |
| 116 | 118 |
| 117 // Detach the client before closing the view to avoid getting called back. | 119 // Detach the client before closing the view to avoid getting called back. |
| 118 m_mainFrame->setClient(0); | 120 m_mainFrame->setClient(0); |
| 119 | 121 |
| 120 if (m_workerGlobalScopeProxy) { | 122 if (m_workerGlobalScopeProxy) { |
| 121 m_workerGlobalScopeProxy->detach(); | 123 m_workerGlobalScopeProxy->detach(); |
| 122 m_workerGlobalScopeProxy.clear(); | 124 m_workerGlobalScopeProxy.clear(); |
| 123 } | 125 } |
| 124 | 126 |
| 127 m_webFrameWidget->close(); | |
| 125 m_webView->close(); | 128 m_webView->close(); |
| 126 m_mainFrame->close(); | 129 m_mainFrame->close(); |
| 127 if (m_loaderProxy) | 130 if (m_loaderProxy) |
| 128 m_loaderProxy->detachProvider(this); | 131 m_loaderProxy->detachProvider(this); |
| 129 } | 132 } |
| 130 | 133 |
| 131 void WebEmbeddedWorkerImpl::startWorkerContext( | 134 void WebEmbeddedWorkerImpl::startWorkerContext( |
| 132 const WebEmbeddedWorkerStartData& data) | 135 const WebEmbeddedWorkerStartData& data) |
| 133 { | 136 { |
| 134 DCHECK(!m_askedToTerminate); | 137 DCHECK(!m_askedToTerminate); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 // Currently we block all mixed-content requests from a ServiceWorker. | 289 // Currently we block all mixed-content requests from a ServiceWorker. |
| 287 // FIXME: When we support FetchEvent.default(), we should relax this | 290 // FIXME: When we support FetchEvent.default(), we should relax this |
| 288 // restriction. | 291 // restriction. |
| 289 settings->setStrictMixedContentChecking(true); | 292 settings->setStrictMixedContentChecking(true); |
| 290 settings->setAllowDisplayOfInsecureContent(false); | 293 settings->setAllowDisplayOfInsecureContent(false); |
| 291 settings->setAllowRunningOfInsecureContent(false); | 294 settings->setAllowRunningOfInsecureContent(false); |
| 292 settings->setDataSaverEnabled(m_workerStartData.dataSaverEnabled); | 295 settings->setDataSaverEnabled(m_workerStartData.dataSaverEnabled); |
| 293 m_mainFrame = toWebLocalFrameImpl(WebLocalFrame::create(WebTreeScopeType::Do cument, this)); | 296 m_mainFrame = toWebLocalFrameImpl(WebLocalFrame::create(WebTreeScopeType::Do cument, this)); |
| 294 m_webView->setMainFrame(m_mainFrame.get()); | 297 m_webView->setMainFrame(m_mainFrame.get()); |
| 295 m_mainFrame->setDevToolsAgentClient(this); | 298 m_mainFrame->setDevToolsAgentClient(this); |
| 299 m_webFrameWidget = WebFrameWidget::create(nullptr, m_webView, m_mainFrame); | |
|
dcheng
2016/09/08 05:25:47
I would /really/ like to disallow null clients, be
falken
2016/09/08 05:50:39
I don't totally understand why webFrameWidget is n
lfg
2016/09/08 21:40:43
I think for now we can use a WebViewFrameWidget, b
| |
| 296 | 300 |
| 297 // If we were asked to wait for debugger then it is the good time to do that . | 301 // If we were asked to wait for debugger then it is the good time to do that . |
| 298 m_workerContextClient->workerReadyForInspection(); | 302 m_workerContextClient->workerReadyForInspection(); |
| 299 if (m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::Wai tForDebugger) { | 303 if (m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::Wai tForDebugger) { |
| 300 m_waitingForDebuggerState = WaitingForDebugger; | 304 m_waitingForDebuggerState = WaitingForDebugger; |
| 301 return; | 305 return; |
| 302 } | 306 } |
| 303 | 307 |
| 304 loadShadowPage(); | 308 loadShadowPage(); |
| 305 } | 309 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr); | 448 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr); |
| 445 | 449 |
| 446 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); | 450 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); |
| 447 m_loaderProxy = WorkerLoaderProxy::create(this); | 451 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 448 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); | 452 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); |
| 449 m_workerThread->start(std::move(startupData)); | 453 m_workerThread->start(std::move(startupData)); |
| 450 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); | 454 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); |
| 451 } | 455 } |
| 452 | 456 |
| 453 } // namespace blink | 457 } // namespace blink |
| OLD | NEW |