diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/loader/WorkerThreadableLoader.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/loader/WorkerThreadableLoader.h')
-rw-r--r-- | Source/WebCore/loader/WorkerThreadableLoader.h | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/Source/WebCore/loader/WorkerThreadableLoader.h b/Source/WebCore/loader/WorkerThreadableLoader.h index 4db0f4534..c0a570527 100644 --- a/Source/WebCore/loader/WorkerThreadableLoader.h +++ b/Source/WebCore/loader/WorkerThreadableLoader.h @@ -28,41 +28,35 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WorkerThreadableLoader_h -#define WorkerThreadableLoader_h +#pragma once #include "ThreadableLoader.h" #include "ThreadableLoaderClient.h" #include "ThreadableLoaderClientWrapper.h" - -#include <wtf/PassOwnPtr.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> #include <wtf/Threading.h> #include <wtf/text/WTFString.h> namespace WebCore { + class ContentSecurityPolicy; class ResourceError; class ResourceRequest; + class SecurityOrigin; class WorkerGlobalScope; class WorkerLoaderProxy; - struct CrossThreadResourceResponseData; - struct CrossThreadResourceRequestData; class WorkerThreadableLoader : public RefCounted<WorkerThreadableLoader>, public ThreadableLoader { WTF_MAKE_FAST_ALLOCATED; public: - static void loadResourceSynchronously(WorkerGlobalScope*, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); - static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope* workerGlobalScope, ThreadableLoaderClient* client, const String& taskMode, const ResourceRequest& request, const ThreadableLoaderOptions& options) + static void loadResourceSynchronously(WorkerGlobalScope&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); + static Ref<WorkerThreadableLoader> create(WorkerGlobalScope& workerGlobalScope, ThreadableLoaderClient& client, const String& taskMode, ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& referrer) { - return adoptRef(new WorkerThreadableLoader(workerGlobalScope, client, taskMode, request, options)); + return adoptRef(*new WorkerThreadableLoader(workerGlobalScope, client, taskMode, WTFMove(request), options, referrer)); } ~WorkerThreadableLoader(); - virtual void cancel() override; + void cancel() override; bool done() const { return m_workerClientWrapper->done(); } @@ -70,8 +64,8 @@ namespace WebCore { using RefCounted<WorkerThreadableLoader>::deref; protected: - virtual void refThreadableLoader() override { ref(); } - virtual void derefThreadableLoader() override { deref(); } + void refThreadableLoader() override { ref(); } + void derefThreadableLoader() override { deref(); } private: // Creates a loader on the main thread and bridges communication between @@ -90,13 +84,12 @@ namespace WebCore { // case 2. xhr gets aborted and the worker context continues running. // The ThreadableLoaderClientWrapper has the underlying client cleared, so no more calls // go through it. All tasks posted from the worker object's thread to the worker context's - // thread do "ThreadableLoaderClientWrapper::ref" (automatically inside of the cross thread copy - // done in createCallbackTask), so the ThreadableLoaderClientWrapper instance is there until all - // tasks are executed. + // thread contain the RefPtr<ThreadableLoaderClientWrapper> object, so the + // ThreadableLoaderClientWrapper instance is there until all tasks are executed. class MainThreadBridge : public ThreadableLoaderClient { public: // All executed on the worker context's thread. - MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, WorkerLoaderProxy&, const String& taskMode, const ResourceRequest&, const ThreadableLoaderOptions&, const String& outgoingReferrer); + MainThreadBridge(ThreadableLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& outgoingReferrer, const SecurityOrigin*, const ContentSecurityPolicy*); void cancel(); void destroy(); @@ -105,21 +98,19 @@ namespace WebCore { void clearClientWrapper(); // All executed on the main thread. - static void mainThreadDestroy(ScriptExecutionContext*, MainThreadBridge*); - ~MainThreadBridge(); - - static void mainThreadCreateLoader(ScriptExecutionContext*, MainThreadBridge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, const String& outgoingReferrer); - static void mainThreadCancel(ScriptExecutionContext*, MainThreadBridge*); - virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override; - virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override; - virtual void didReceiveData(const char*, int dataLength) override; - virtual void didFinishLoading(unsigned long identifier, double finishTime) override; - virtual void didFail(const ResourceError&) override; - virtual void didFailAccessControlCheck(const ResourceError&) override; - virtual void didFailRedirectCheck() override; + void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override; + void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override; + void didReceiveData(const char*, int dataLength) override; + void didFinishLoading(unsigned long identifier, double finishTime) override; + void didFail(const ResourceError&) override; + +#if ENABLE(WEB_TIMING) + void didFinishTiming(const ResourceTiming&) override; +#endif // Only to be used on the main thread. RefPtr<ThreadableLoader> m_mainThreadLoader; + bool m_loadingFinished { false }; // ThreadableLoaderClientWrapper is to be used on the worker context thread. // The ref counting is done on either thread. @@ -132,13 +123,11 @@ namespace WebCore { String m_taskMode; }; - WorkerThreadableLoader(WorkerGlobalScope*, ThreadableLoaderClient*, const String& taskMode, const ResourceRequest&, const ThreadableLoaderOptions&); + WorkerThreadableLoader(WorkerGlobalScope&, ThreadableLoaderClient&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& referrer); - RefPtr<WorkerGlobalScope> m_workerGlobalScope; - RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; + Ref<WorkerGlobalScope> m_workerGlobalScope; + Ref<ThreadableLoaderClientWrapper> m_workerClientWrapper; MainThreadBridge& m_bridge; }; } // namespace WebCore - -#endif // WorkerThreadableLoader_h |