Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1512)

Unified Diff: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp

Issue 1675613002: service worker: use 200 OK for update requests even in the no update case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asan and fix win compile? Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp b/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
index 303b19e23f291aed8f8284c243a84ac51b70e6dc..a933efb7ed5e498c903ac7b50f3f1aa6ac22c9d2 100644
--- a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
+++ b/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
@@ -88,6 +88,7 @@ WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextC
, m_mainFrame(nullptr)
, m_loadingShadowPage(false)
, m_askedToTerminate(false)
+ , m_pauseAfterDownloadState(DontPauseAfterDownload)
, m_waitingForDebuggerState(NotWaitingForDebugger)
{
runningWorkerInstances().add(this);
@@ -124,7 +125,10 @@ void WebEmbeddedWorkerImpl::startWorkerContext(
{
ASSERT(!m_askedToTerminate);
ASSERT(!m_mainScriptLoader);
+ ASSERT(m_pauseAfterDownloadState == DontPauseAfterDownload);
m_workerStartData = data;
+ if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDownload)
+ m_pauseAfterDownloadState = DoPauseAfterDownload;
prepareShadowPageForLoader();
}
@@ -147,8 +151,8 @@ void WebEmbeddedWorkerImpl::terminateWorkerContext()
}
if (!m_workerThread) {
// The worker thread has not been created yet if the worker is asked to
- // terminate during waiting for debugger.
- ASSERT(m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::WaitForDebugger);
+ // terminate during waiting for debugger or paused after download.
+ ASSERT(m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::WaitForDebugger || m_pauseAfterDownloadState == IsPausedAfterDownload);
// This deletes 'this'.
m_workerContextClient->workerContextFailedToStart();
return;
@@ -157,6 +161,15 @@ void WebEmbeddedWorkerImpl::terminateWorkerContext()
m_workerInspectorProxy->workerThreadTerminated();
}
+void WebEmbeddedWorkerImpl::resumeAfterDownload()
+{
+ ASSERT(!m_askedToTerminate);
+ ASSERT(m_pauseAfterDownloadState == IsPausedAfterDownload);
+
+ m_pauseAfterDownloadState = DontPauseAfterDownload;
+ startWorkerThread();
+}
+
void WebEmbeddedWorkerImpl::attachDevTools(const WebString& hostId, int sessionId)
{
WebDevToolsAgent* devtoolsAgent = m_mainFrame->devToolsAgent();
@@ -237,7 +250,7 @@ void WebEmbeddedWorkerImpl::prepareShadowPageForLoader()
// If we were asked to wait for debugger then it is the good time to do that.
m_workerContextClient->workerReadyForInspection();
if (m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::WaitForDebugger) {
- m_waitingForDebuggerState = WaitingForDebuggerBeforeLoadingScript;
+ m_waitingForDebuggerState = WaitingForDebugger;
return;
}
@@ -291,18 +304,15 @@ void WebEmbeddedWorkerImpl::sendProtocolMessage(int sessionId, int callId, const
void WebEmbeddedWorkerImpl::resumeStartup()
{
- WaitingForDebuggerState waitingForDebuggerState = m_waitingForDebuggerState;
+ bool wasWaiting = (m_waitingForDebuggerState == WaitingForDebugger);
m_waitingForDebuggerState = NotWaitingForDebugger;
- if (waitingForDebuggerState == WaitingForDebuggerBeforeLoadingScript)
+ if (wasWaiting)
loadShadowPage();
- else if (waitingForDebuggerState == WaitingForDebuggerAfterScriptLoaded)
- startWorkerThread();
}
void WebEmbeddedWorkerImpl::onScriptLoaderFinished()
{
ASSERT(m_mainScriptLoader);
-
if (m_askedToTerminate)
return;
@@ -321,11 +331,16 @@ void WebEmbeddedWorkerImpl::onScriptLoaderFinished()
scriptCachedMetadataSizeHistogram.count(m_mainScriptLoader->cachedMetadata()->size());
}
+ if (m_pauseAfterDownloadState == DoPauseAfterDownload) {
+ m_pauseAfterDownloadState = IsPausedAfterDownload;
+ return;
+ }
startWorkerThread();
}
void WebEmbeddedWorkerImpl::startWorkerThread()
{
+ ASSERT(m_pauseAfterDownloadState == DontPauseAfterDownload);
ASSERT(!m_askedToTerminate);
Document* document = m_mainFrame->frame()->document();
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h ('k') | third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698