| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/loader/DocumentThreadableLoader.h" | 37 #include "core/loader/DocumentThreadableLoader.h" |
| 38 #include "core/loader/WorkerLoaderClientBridgeSyncHelper.h" | 38 #include "core/loader/WorkerLoaderClientBridgeSyncHelper.h" |
| 39 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
| 40 #include "core/workers/WorkerLoaderProxy.h" | 40 #include "core/workers/WorkerLoaderProxy.h" |
| 41 #include "core/workers/WorkerThread.h" | 41 #include "core/workers/WorkerThread.h" |
| 42 #include "platform/heap/SafePoint.h" | 42 #include "platform/heap/SafePoint.h" |
| 43 #include "platform/network/ResourceError.h" | 43 #include "platform/network/ResourceError.h" |
| 44 #include "platform/network/ResourceRequest.h" | 44 #include "platform/network/ResourceRequest.h" |
| 45 #include "platform/network/ResourceResponse.h" | 45 #include "platform/network/ResourceResponse.h" |
| 46 #include "platform/weborigin/Referrer.h" | |
| 47 #include "platform/weborigin/SecurityPolicy.h" | 46 #include "platform/weborigin/SecurityPolicy.h" |
| 48 #include "public/platform/Platform.h" | 47 #include "public/platform/Platform.h" |
| 49 #include "public/platform/WebWaitableEvent.h" | 48 #include "public/platform/WebWaitableEvent.h" |
| 50 #include "wtf/MainThread.h" | 49 #include "wtf/MainThread.h" |
| 51 #include "wtf/OwnPtr.h" | 50 #include "wtf/OwnPtr.h" |
| 52 #include "wtf/Vector.h" | 51 #include "wtf/Vector.h" |
| 53 | 52 |
| 54 namespace blink { | 53 namespace blink { |
| 55 | 54 |
| 56 WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalSc
ope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<Threada
bleLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableL
oaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) | 55 WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalSc
ope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<Threada
bleLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableL
oaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) |
| 57 : m_workerGlobalScope(&workerGlobalScope) | 56 : m_workerGlobalScope(&workerGlobalScope) |
| 58 , m_workerClientWrapper(clientWrapper) | 57 , m_workerClientWrapper(clientWrapper) |
| 59 , m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, worke
rGlobalScope.thread()->workerLoaderProxy(), request, options, resourceLoaderOpti
ons, workerGlobalScope.url().strippedForUseAsReferrer()))) | 58 , m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, worke
rGlobalScope.thread()->workerLoaderProxy(), request, options, resourceLoaderOpti
ons, workerGlobalScope.referrerPolicy(), workerGlobalScope.url().strippedForUseA
sReferrer()))) |
| 60 { | 59 { |
| 61 } | 60 } |
| 62 | 61 |
| 63 WorkerThreadableLoader::~WorkerThreadableLoader() | 62 WorkerThreadableLoader::~WorkerThreadableLoader() |
| 64 { | 63 { |
| 65 m_bridge.destroy(); | 64 m_bridge.destroy(); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& worker
GlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, con
st ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoader
Options) | 67 void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& worker
GlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, con
st ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoader
Options) |
| 69 { | 68 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 m_bridge.cancel(); | 106 m_bridge.cancel(); |
| 108 } | 107 } |
| 109 | 108 |
| 110 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge( | 109 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge( |
| 111 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, | 110 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, |
| 112 PassOwnPtr<ThreadableLoaderClient> clientBridge, | 111 PassOwnPtr<ThreadableLoaderClient> clientBridge, |
| 113 PassRefPtr<WorkerLoaderProxy> loaderProxy, | 112 PassRefPtr<WorkerLoaderProxy> loaderProxy, |
| 114 const ResourceRequest& request, | 113 const ResourceRequest& request, |
| 115 const ThreadableLoaderOptions& options, | 114 const ThreadableLoaderOptions& options, |
| 116 const ResourceLoaderOptions& resourceLoaderOptions, | 115 const ResourceLoaderOptions& resourceLoaderOptions, |
| 116 const ReferrerPolicy referrerPolicy, |
| 117 const String& outgoingReferrer) | 117 const String& outgoingReferrer) |
| 118 : m_clientBridge(clientBridge) | 118 : m_clientBridge(clientBridge) |
| 119 , m_workerClientWrapper(workerClientWrapper) | 119 , m_workerClientWrapper(workerClientWrapper) |
| 120 , m_loaderProxy(loaderProxy) | 120 , m_loaderProxy(loaderProxy) |
| 121 { | 121 { |
| 122 ASSERT(m_workerClientWrapper.get()); | 122 ASSERT(m_workerClientWrapper.get()); |
| 123 ASSERT(m_clientBridge.get()); | 123 ASSERT(m_clientBridge.get()); |
| 124 m_loaderProxy->postTaskToLoader( | 124 m_loaderProxy->postTaskToLoader( |
| 125 createCrossThreadTask(&MainThreadBridge::mainThreadCreateLoader, this, r
equest, options, resourceLoaderOptions, outgoingReferrer)); | 125 createCrossThreadTask(&MainThreadBridge::mainThreadCreateLoader, this, r
equest, options, resourceLoaderOptions, referrerPolicy, outgoingReferrer)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge() | 128 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge() |
| 129 { | 129 { |
| 130 } | 130 } |
| 131 | 131 |
| 132 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(PassOwnPtr
<CrossThreadResourceRequestData> requestData, ThreadableLoaderOptions options, R
esourceLoaderOptions resourceLoaderOptions, const String& outgoingReferrer, Exec
utionContext* context) | 132 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(PassOwnPtr
<CrossThreadResourceRequestData> requestData, ThreadableLoaderOptions options, R
esourceLoaderOptions resourceLoaderOptions, const ReferrerPolicy referrerPolicy,
const String& outgoingReferrer, ExecutionContext* context) |
| 133 { | 133 { |
| 134 ASSERT(isMainThread()); | 134 ASSERT(isMainThread()); |
| 135 Document* document = toDocument(context); | 135 Document* document = toDocument(context); |
| 136 | 136 |
| 137 OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData)); | 137 OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData)); |
| 138 request->setHTTPReferrer(SecurityPolicy::generateReferrer(ReferrerPolicyDefa
ult, request->url(), outgoingReferrer)); | 138 request->setHTTPReferrer(SecurityPolicy::generateReferrer(referrerPolicy, re
quest->url(), outgoingReferrer)); |
| 139 resourceLoaderOptions.requestInitiatorContext = WorkerContext; | 139 resourceLoaderOptions.requestInitiatorContext = WorkerContext; |
| 140 m_mainThreadLoader = DocumentThreadableLoader::create(*document, this, *requ
est, options, resourceLoaderOptions); | 140 m_mainThreadLoader = DocumentThreadableLoader::create(*document, this, *requ
est, options, resourceLoaderOptions); |
| 141 if (!m_mainThreadLoader) { | 141 if (!m_mainThreadLoader) { |
| 142 // DocumentThreadableLoader::create may return 0 when the document loade
r has been already changed. | 142 // DocumentThreadableLoader::create may return 0 when the document loade
r has been already changed. |
| 143 didFail(ResourceError(errorDomainBlinkInternal, 0, request->url().string
(), "Can't create DocumentThreadableLoader")); | 143 didFail(ResourceError(errorDomainBlinkInternal, 0, request->url().string
(), "Can't create DocumentThreadableLoader")); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void WorkerThreadableLoader::MainThreadBridge::mainThreadDestroy(ExecutionContex
t* context) | 147 void WorkerThreadableLoader::MainThreadBridge::mainThreadDestroy(ExecutionContex
t* context) |
| 148 { | 148 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 { | 248 { |
| 249 m_clientBridge->didFailAccessControlCheck(error); | 249 m_clientBridge->didFailAccessControlCheck(error); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() | 252 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() |
| 253 { | 253 { |
| 254 m_clientBridge->didFailRedirectCheck(); | 254 m_clientBridge->didFailRedirectCheck(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace blink | 257 } // namespace blink |
| OLD | NEW |