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

Unified Diff: Source/core/workers/WorkerScriptLoader.cpp

Issue 1190133002: Remove WorkerScriptLoaderClient and inheritances (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: no-refcounted Created 5 years, 6 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
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.h ('k') | Source/core/workers/WorkerScriptLoaderClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerScriptLoader.cpp
diff --git a/Source/core/workers/WorkerScriptLoader.cpp b/Source/core/workers/WorkerScriptLoader.cpp
index 7b30539fe2394cef581fe5adb8c8152f918f0853..363cb0b8634b67a52f0129fd4aa0ad3e53f835cb 100644
--- a/Source/core/workers/WorkerScriptLoader.cpp
+++ b/Source/core/workers/WorkerScriptLoader.cpp
@@ -32,7 +32,6 @@
#include "core/html/parser/TextResourceDecoder.h"
#include "core/loader/WorkerThreadableLoader.h"
#include "core/workers/WorkerGlobalScope.h"
-#include "core/workers/WorkerScriptLoaderClient.h"
#include "platform/network/ContentSecurityPolicyResponseHeaders.h"
#include "platform/network/ResourceResponse.h"
#include "public/platform/WebURLRequest.h"
@@ -43,17 +42,17 @@
namespace blink {
WorkerScriptLoader::WorkerScriptLoader()
- : m_client(nullptr)
+ : m_responseCallback(nullptr)
+ , m_finishedCallback(nullptr)
, m_failed(false)
, m_identifier(0)
+ , m_appCacheID(0)
, m_finishing(false)
, m_requestContext(WebURLRequest::RequestContextWorker)
{
}
-WorkerScriptLoader::~WorkerScriptLoader()
-{
-}
+WorkerScriptLoader::~WorkerScriptLoader() = default;
void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy)
{
@@ -76,10 +75,11 @@ void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, c
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(executionContext), *request, *this, options, resourceLoaderOptions);
}
-void WorkerScriptLoader::loadAsynchronously(ExecutionContext& executionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, WorkerScriptLoaderClient* client)
+void WorkerScriptLoader::loadAsynchronously(ExecutionContext& executionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, PassOwnPtr<Closure> responseCallback, PassOwnPtr<Closure> finishedCallback)
{
- ASSERT(client);
- m_client = client;
+ ASSERT(responseCallback || finishedCallback);
+ m_responseCallback = responseCallback;
+ m_finishedCallback = finishedCallback;
m_url = url;
OwnPtr<ResourceRequest> request(createResourceRequest());
@@ -92,8 +92,6 @@ void WorkerScriptLoader::loadAsynchronously(ExecutionContext& executionContext,
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
- // During create, callbacks may happen which remove the last reference to this object.
Takashi Toyoshima 2015/06/19 05:24:46 Note: This code was introduced by https://bugs.web
kinuko 2015/06/24 07:27:54 This looks to be ok, but can you make sure that Th
- RefPtr<WorkerScriptLoader> protect(this);
m_threadableLoader = ThreadableLoader::create(executionContext, this, *request, options, resourceLoaderOptions);
}
@@ -118,11 +116,13 @@ void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso
m_failed = true;
return;
}
+ m_identifier = identifier;
m_responseURL = response.url();
m_responseEncoding = response.textEncodingName();
+ m_appCacheID = response.appCacheID();
processContentSecurityPolicy(response);
- if (m_client)
- m_client->didReceiveResponse(identifier, response);
+ if (m_responseCallback)
+ (*m_responseCallback)();
}
void WorkerScriptLoader::didReceiveData(const char* data, unsigned len)
@@ -159,8 +159,8 @@ void WorkerScriptLoader::didFinishLoading(unsigned long identifier, double)
if (m_decoder)
m_script.append(m_decoder->flush());
- m_identifier = identifier;
- notifyFinished();
+ if (m_finishedCallback)
+ (*m_finishedCallback)();
}
void WorkerScriptLoader::didFail(const ResourceError&)
@@ -192,17 +192,18 @@ String WorkerScriptLoader::script()
void WorkerScriptLoader::notifyFinished()
{
- if (!m_client || m_finishing)
+ if (!m_finishedCallback || m_finishing)
return;
m_finishing = true;
- m_client->notifyFinished();
+ if (m_finishedCallback)
+ (*m_finishedCallback)();
}
void WorkerScriptLoader::processContentSecurityPolicy(const ResourceResponse& response)
{
+ m_contentSecurityPolicy = ContentSecurityPolicy::create();
if (!response.url().protocolIs("blob") && !response.url().protocolIs("file") && !response.url().protocolIs("filesystem")) {
- m_contentSecurityPolicy = ContentSecurityPolicy::create();
m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHeaders(response));
}
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.h ('k') | Source/core/workers/WorkerScriptLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698