Changeset 220946 in webkit
- Timestamp:
- Aug 18, 2017 5:27:59 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r220944 r220946 1 2017-08-18 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Improve error reporting 4 https://bugs.webkit.org/show_bug.cgi?id=175723 5 6 Reviewed by Darin Adler. 7 8 Add layout test coverage. 9 10 * http/wpt/beacon/beacon-async-error-logging-expected.txt: Added. 11 * http/wpt/beacon/beacon-async-error-logging.html: Added. 12 1 13 2017-08-18 Matt Lewis <jlewis3@apple.com> 2 14 -
trunk/LayoutTests/http/wpt/beacon/beacon-quota-expected.txt
r220922 r220946 1 CONSOLE MESSAGE: line 44: Reached maximum amount of queued data of 64Kb for keepalive requests2 CONSOLE MESSAGE: line 52: Reached maximum amount of queued data of 64Kb for keepalive requests1 CONSOLE MESSAGE: line 44: Beacon API cannot load http://localhost:8800/. Reached maximum amount of queued data of 64Kb for keepalive requests 2 CONSOLE MESSAGE: line 52: Beacon API cannot load http://localhost:8800/. Reached maximum amount of queued data of 64Kb for keepalive requests 3 3 4 4 PASS Beacon with a body above the Quota Limit should fail. -
trunk/LayoutTests/http/wpt/beacon/beacon-quota.html
r220922 r220946 50 50 51 51 assert_true(navigator.sendBeacon(target, createPayload(expectedQuota)), "Beacon with a body at the Quota Limit should succeed."); 52 assert_false(navigator.sendBeacon( target, createPayload(1)), "Second beacon should not be sent because we reached the quota");52 assert_false(navigator.sendBeacon("/", createPayload(1)), "Second beacon should not be sent because we reached the quota"); 53 53 return waitForBeacon(id).then(function() { 54 54 assert_true(navigator.sendBeacon(target, createPayload(1)), "Allocated quota should be returned once the beacon is no longer in flight"); -
trunk/Source/WebCore/ChangeLog
r220941 r220946 1 2017-08-18 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Improve error reporting 4 https://bugs.webkit.org/show_bug.cgi?id=175723 5 6 Reviewed by Darin Adler. 7 8 Have Ping loads such as beacons report errors via their completion handler. 9 The Beacon API is using this error to log a console message when beacon loads 10 fail, provided that the page is still alive. 11 12 Test: http/wpt/beacon/beacon-async-error-logging.html 13 14 * Modules/beacon/NavigatorBeacon.cpp: 15 (WebCore::NavigatorBeacon::NavigatorBeacon): 16 (WebCore::NavigatorBeacon::~NavigatorBeacon): 17 (WebCore::NavigatorBeacon::from): 18 (WebCore::NavigatorBeacon::supplementName): 19 (WebCore::NavigatorBeacon::notifyFinished): 20 (WebCore::NavigatorBeacon::logError): 21 (WebCore::NavigatorBeacon::sendBeacon): 22 * Modules/beacon/NavigatorBeacon.h: 23 * loader/LoaderStrategy.h: 24 * loader/cache/CachedResource.cpp: 25 (WebCore::CachedResource::load): 26 * loader/cache/CachedResourceLoader.cpp: 27 (WebCore::CachedResourceLoader::requestBeaconResource): 28 * loader/cache/CachedResourceLoader.h: 29 * platform/network/PingHandle.h: 30 1 31 2017-08-18 Sam Weinig <sam@webkit.org> 2 32 -
trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp
r220928 r220946 27 27 #include "NavigatorBeacon.h" 28 28 29 #include "CachedRawResource.h" 29 30 #include "CachedResourceLoader.h" 30 31 #include "Document.h" 31 32 #include "FetchBody.h" 33 #include "Frame.h" 32 34 #include "HTTPParsers.h" 33 35 #include "Navigator.h" … … 36 38 namespace WebCore { 37 39 38 ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, const String& url, std::optional<FetchBody::Init>&& body) 40 NavigatorBeacon::NavigatorBeacon(Navigator& navigator) 41 : m_navigator(navigator) 42 { 43 } 44 45 NavigatorBeacon::~NavigatorBeacon() 46 { 47 for (auto& beacon : m_inflightBeacons) 48 beacon->removeClient(*this); 49 } 50 51 NavigatorBeacon* NavigatorBeacon::from(Navigator& navigator) 52 { 53 auto* supplement = static_cast<NavigatorBeacon*>(Supplement<Navigator>::from(&navigator, supplementName())); 54 if (!supplement) { 55 auto newSupplement = std::make_unique<NavigatorBeacon>(navigator); 56 supplement = newSupplement.get(); 57 provideTo(&navigator, supplementName(), WTFMove(newSupplement)); 58 } 59 return supplement; 60 } 61 62 const char* NavigatorBeacon::supplementName() 63 { 64 return "NavigatorBeacon"; 65 } 66 67 void NavigatorBeacon::notifyFinished(CachedResource& resource) 68 { 69 if (!resource.resourceError().isNull()) 70 logError(resource.resourceError()); 71 72 resource.removeClient(*this); 73 bool wasRemoved = m_inflightBeacons.removeFirst(&resource); 74 ASSERT_UNUSED(wasRemoved, wasRemoved); 75 ASSERT(!m_inflightBeacons.contains(&resource)); 76 } 77 78 void NavigatorBeacon::logError(const ResourceError& error) 79 { 80 ASSERT(!error.isNull()); 81 82 auto* frame = m_navigator.frame(); 83 if (!frame) 84 return; 85 86 auto* document = frame->document(); 87 if (!document) 88 return; 89 90 const char* messageMiddle = ". "; 91 String description = error.localizedDescription(); 92 if (description.isEmpty()) { 93 if (error.isAccessControl()) 94 messageMiddle = " due to access control checks."; 95 else 96 messageMiddle = "."; 97 } 98 99 document->addConsoleMessage(MessageSource::Network, MessageLevel::Error, makeString(ASCIILiteral("Beacon API cannot load "), error.failingURL().string(), ASCIILiteral(messageMiddle), description)); 100 } 101 102 ExceptionOr<bool> NavigatorBeacon::sendBeacon(Document& document, const String& url, std::optional<FetchBody::Init>&& body) 39 103 { 40 104 URL parsedUrl = document.completeURL(url); … … 74 138 } 75 139 } 140 76 141 auto cachedResource = document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options }); 77 if (cachedResource) 78 return true; 142 if (!cachedResource) { 143 logError(cachedResource.error()); 144 return false; 145 } 79 146 80 document.addConsoleMessage(MessageSource::Network, MessageLevel::Error, cachedResource.error().localizedDescription()); 81 return false; 147 ASSERT(!m_inflightBeacons.contains(cachedResource.value().get())); 148 m_inflightBeacons.append(cachedResource.value().get()); 149 cachedResource.value()->addClient(*this); 150 return true; 151 } 152 153 ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator& navigator, Document& document, const String& url, std::optional<FetchBody::Init>&& body) 154 { 155 return NavigatorBeacon::from(navigator)->sendBeacon(document, url, WTFMove(body)); 82 156 } 83 157 -
trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.h
r220303 r220946 26 26 #pragma once 27 27 28 #include "CachedRawResourceClient.h" 29 #include "CachedResourceHandle.h" 28 30 #include "ExceptionOr.h" 29 31 #include "FetchBody.h" 32 #include "Supplementable.h" 30 33 #include <wtf/Forward.h> 31 34 32 35 namespace WebCore { 33 36 37 class CachedRawResource; 34 38 class Document; 35 39 class Navigator; 40 class ResourceError; 36 41 37 class NavigatorBeacon {42 class NavigatorBeacon final : public Supplement<Navigator>, private CachedRawResourceClient { 38 43 public: 44 explicit NavigatorBeacon(Navigator&); 45 ~NavigatorBeacon(); 39 46 static ExceptionOr<bool> sendBeacon(Navigator&, Document&, const String& url, std::optional<FetchBody::Init>&&); 47 48 private: 49 ExceptionOr<bool> sendBeacon(Document&, const String& url, std::optional<FetchBody::Init>&&); 50 51 static NavigatorBeacon* from(Navigator&); 52 static const char* supplementName(); 53 54 void notifyFinished(CachedResource&) final; 55 void logError(const ResourceError&); 56 57 Navigator& m_navigator; 58 Vector<CachedResourceHandle<CachedRawResource>> m_inflightBeacons; 40 59 }; 41 60 -
trunk/Source/WebCore/loader/LoaderStrategy.h
r220922 r220946 65 65 virtual void resumePendingRequests() = 0; 66 66 67 virtual void startPingLoad(NetworkingContext*, ResourceRequest&, const HTTPHeaderMap& originalRequestHeaders, Ref<SecurityOrigin>&& sourceOrigin, ContentSecurityPolicy*, const FetchOptions&, WTF::Function<void()>&& completionHandler = { }) = 0; 67 using PingLoadCompletionHandler = WTF::Function<void(const ResourceError&)>; 68 virtual void startPingLoad(NetworkingContext*, ResourceRequest&, const HTTPHeaderMap& originalRequestHeaders, Ref<SecurityOrigin>&& sourceOrigin, ContentSecurityPolicy*, const FetchOptions&, PingLoadCompletionHandler&& = { }) = 0; 68 69 69 70 virtual void storeDerivedDataToCache(const SHA1::Digest& bodyKey, const String& type, const String& partition, WebCore::SharedBuffer&) = 0; -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r220922 r220946 275 275 ASSERT(m_originalRequestHeaders); 276 276 CachedResourceHandle<CachedResource> protectedThis(this); 277 platformStrategies()->loaderStrategy()->startPingLoad(frame.loader().networkingContext(), request, *m_originalRequestHeaders, *m_origin, contentSecurityPolicy, m_options, [this, protectedThis = WTFMove(protectedThis)] { 278 finishLoading(nullptr); 277 platformStrategies()->loaderStrategy()->startPingLoad(frame.loader().networkingContext(), request, *m_originalRequestHeaders, *m_origin, contentSecurityPolicy, m_options, [this, protectedThis = WTFMove(protectedThis)] (const ResourceError& error) { 278 if (error.isNull()) 279 finishLoading(nullptr); 280 else { 281 setResourceError(error); 282 this->error(LoadError); 283 } 279 284 }); 280 285 return; -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r220888 r220946 297 297 } 298 298 299 ResourceErrorOr<CachedResourceHandle<CachedR esource>> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request)300 { 301 return requestResource(CachedResource::Beacon, WTFMove(request));299 ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request) 300 { 301 return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Beacon, WTFMove(request))); 302 302 } 303 303 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r220857 r220946 84 84 ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestMedia(CachedResourceRequest&&); 85 85 ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestIcon(CachedResourceRequest&&); 86 ResourceErrorOr<CachedResourceHandle<CachedR esource>> requestBeaconResource(CachedResourceRequest&&);86 ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestBeaconResource(CachedResourceRequest&&); 87 87 ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestRawResource(CachedResourceRequest&&); 88 88 ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestMainResource(CachedResourceRequest&&); -
trunk/Source/WebCore/platform/network/PingHandle.h
r220922 r220946 44 44 }; 45 45 46 PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, UsesAsyncCallbacks useAsyncCallbacks, bool shouldFollowRedirects, WTF::Function<void()>&& completionHandler) 47 : m_timeoutTimer(*this, &PingHandle::timeoutTimerFired) 46 PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, UsesAsyncCallbacks useAsyncCallbacks, bool shouldFollowRedirects, WTF::Function<void(const ResourceError&)>&& completionHandler) 47 : m_currentRequest(request) 48 , m_timeoutTimer(*this, &PingHandle::timeoutTimerFired) 48 49 , m_shouldUseCredentialStorage(shouldUseCredentialStorage) 49 50 , m_shouldFollowRedirects(shouldFollowRedirects) … … 65 66 void willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&&) final 66 67 { 68 m_currentRequest = WTFMove(request); 67 69 if (m_shouldFollowRedirects) { 68 handle->continueWillSendRequest( WTFMove(request));70 handle->continueWillSendRequest(ResourceRequest { m_currentRequest }); 69 71 return; 70 72 } 73 pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Not allowed to follow redirects"), ResourceError::Type::AccessControl }); 74 } 75 void didReceiveResponse(ResourceHandle*, ResourceResponse&&) final { pingLoadComplete(); } 76 void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int) final { pingLoadComplete(); } 77 void didFinishLoading(ResourceHandle*) final { pingLoadComplete(); } 78 void didFail(ResourceHandle*, const ResourceError& error) final { pingLoadComplete(error); } 79 bool shouldUseCredentialStorage(ResourceHandle*) final { return m_shouldUseCredentialStorage; } 80 bool usesAsyncCallbacks() final { return m_usesAsyncCallbacks == UsesAsyncCallbacks::Yes; } 81 void timeoutTimerFired() { pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Load timed out"), ResourceError::Type::Timeout }); } 82 83 void pingLoadComplete(const ResourceError& error = { }) 84 { 85 if (auto completionHandler = std::exchange(m_completionHandler, nullptr)) 86 completionHandler(error); 71 87 delete this; 72 88 } 73 void didReceiveResponse(ResourceHandle*, ResourceResponse&&) final { delete this; }74 void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int) final { delete this; };75 void didFinishLoading(ResourceHandle*) final { delete this; }76 void didFail(ResourceHandle*, const ResourceError&) final { delete this; }77 bool shouldUseCredentialStorage(ResourceHandle*) final { return m_shouldUseCredentialStorage; }78 bool usesAsyncCallbacks() final { return m_usesAsyncCallbacks == UsesAsyncCallbacks::Yes; }79 void timeoutTimerFired() { delete this; }80 89 81 90 virtual ~PingHandle() 82 91 { 83 if (m_completionHandler) 84 m_completionHandler(); 85 92 ASSERT(!m_completionHandler); 86 93 if (m_handle) { 87 94 ASSERT(m_handle->client() == this); … … 92 99 93 100 RefPtr<ResourceHandle> m_handle; 101 ResourceRequest m_currentRequest; 94 102 Timer m_timeoutTimer; 95 103 bool m_shouldUseCredentialStorage; 96 104 bool m_shouldFollowRedirects; 97 105 UsesAsyncCallbacks m_usesAsyncCallbacks; 98 WTF::Function<void( )> m_completionHandler;106 WTF::Function<void(const ResourceError&)> m_completionHandler; 99 107 }; 100 108 -
trunk/Source/WebKit/ChangeLog
r220931 r220946 1 2017-08-18 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Improve error reporting 4 https://bugs.webkit.org/show_bug.cgi?id=175723 5 6 Reviewed by Darin Adler. 7 8 Have Ping loads such as beacons report errors via their completion handler. 9 The Beacon API is using this error to log a console message when beacon loads 10 fail, provided that the page is still alive. 11 12 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 13 (WebKit::NetworkConnectionToWebProcess::loadPing): 14 (WebKit::NetworkConnectionToWebProcess::didFinishPingLoad): 15 * NetworkProcess/NetworkConnectionToWebProcess.h: 16 * NetworkProcess/PingLoad.cpp: 17 (WebKit::PingLoad::~PingLoad): 18 (WebKit::PingLoad::didFinish): 19 (WebKit::PingLoad::willPerformHTTPRedirection): 20 (WebKit::PingLoad::didReceiveChallenge): 21 (WebKit::PingLoad::didReceiveResponseNetworkSession): 22 (WebKit::PingLoad::didCompleteWithError): 23 (WebKit::PingLoad::wasBlocked): 24 (WebKit::PingLoad::cannotShowURL): 25 (WebKit::PingLoad::timeoutTimerFired): 26 (WebKit::PingLoad::currentRequest const): 27 (WebKit::PingLoad::makeCrossOriginAccessRequestWithPreflight): 28 * NetworkProcess/PingLoad.h: 29 * WebProcess/Network/NetworkProcessConnection.cpp: 30 (WebKit::NetworkProcessConnection::didFinishPingLoad): 31 * WebProcess/Network/NetworkProcessConnection.h: 32 * WebProcess/Network/NetworkProcessConnection.messages.in: 33 * WebProcess/Network/WebLoaderStrategy.cpp: 34 (WebKit::WebLoaderStrategy::networkProcessCrashed): 35 (WebKit::WebLoaderStrategy::startPingLoad): 36 (WebKit::WebLoaderStrategy::didFinishPingLoad): 37 * WebProcess/Network/WebLoaderStrategy.h: 38 1 39 2017-08-18 Chris Dumez <cdumez@apple.com> 2 40 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r220922 r220946 246 246 247 247 // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled. 248 new PingHandle(context.get(), loadParameters.request, loadParameters.allowStoredCredentials == AllowStoredCredentials, PingHandle::UsesAsyncCallbacks::Yes, loadParameters.shouldFollowRedirects, [this, protectedThis = makeRef(*this), identifier = loadParameters.identifier] {249 didFinishPingLoad(identifier );248 new PingHandle(context.get(), loadParameters.request, loadParameters.allowStoredCredentials == AllowStoredCredentials, PingHandle::UsesAsyncCallbacks::Yes, loadParameters.shouldFollowRedirects, [this, protectedThis = makeRef(*this), identifier = loadParameters.identifier] (const ResourceError& error) { 249 didFinishPingLoad(identifier, error); 250 250 }); 251 251 #endif 252 252 } 253 253 254 void NetworkConnectionToWebProcess::didFinishPingLoad(uint64_t pingLoadIdentifier )254 void NetworkConnectionToWebProcess::didFinishPingLoad(uint64_t pingLoadIdentifier, const ResourceError& error) 255 255 { 256 256 if (!m_connection->isValid()) 257 257 return; 258 258 259 m_connection->send(Messages::NetworkProcessConnection::DidFinishPingLoad(pingLoadIdentifier ), 0);259 m_connection->send(Messages::NetworkProcessConnection::DidFinishPingLoad(pingLoadIdentifier, error), 0); 260 260 } 261 261 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
r220922 r220946 39 39 class BlobDataFileReference; 40 40 class HTTPHeaderMap; 41 class ResourceError; 41 42 class ResourceRequest; 42 43 } … … 62 63 63 64 void didCleanupResourceLoader(NetworkResourceLoader&); 64 void didFinishPingLoad(uint64_t pingLoadIdentifier );65 void didFinishPingLoad(uint64_t pingLoadIdentifier, const WebCore::ResourceError&); 65 66 66 67 bool captureExtraNetworkLoadMetricsEnabled() const { return m_captureExtraNetworkLoadMetricsEnabled; } -
trunk/Source/WebKit/NetworkProcess/PingLoad.cpp
r220922 r220946 34 34 #include "NetworkConnectionToWebProcess.h" 35 35 #include "SessionTracker.h" 36 #include "WebErrors.h" 36 37 #include <WebCore/ContentSecurityPolicy.h> 37 38 #include <WebCore/CrossOriginAccessControl.h> … … 67 68 PingLoad::~PingLoad() 68 69 { 69 m_connection->didFinishPingLoad(m_parameters.identifier);70 71 70 if (m_redirectHandler) 72 71 m_redirectHandler({ }); … … 77 76 m_task->cancel(); 78 77 } 78 } 79 80 void PingLoad::didFinish(const ResourceError& error) 81 { 82 m_connection->didFinishPingLoad(m_parameters.identifier, error); 83 delete this; 79 84 } 80 85 … … 98 103 void PingLoad::willPerformHTTPRedirection(ResourceResponse&& redirectResponse, ResourceRequest&& request, RedirectCompletionHandler&& completionHandler) 99 104 { 105 m_lastRedirectionRequest = request; 106 100 107 RELEASE_LOG_IF_ALLOWED("willPerformHTTPRedirection - shouldFollowRedirects? %d", m_parameters.shouldFollowRedirects); 101 108 if (!m_parameters.shouldFollowRedirects) { … … 150 157 RELEASE_LOG_IF_ALLOWED("didReceiveChallenge"); 151 158 completionHandler(AuthenticationChallengeDisposition::Cancel, { }); 152 d elete this;159 didFinish(ResourceError { String(), 0, currentRequest().url(), ASCIILiteral("Failed HTTP authentication"), ResourceError::Type::AccessControl }); 153 160 } 154 161 … … 157 164 RELEASE_LOG_IF_ALLOWED("didReceiveResponseNetworkSession - httpStatusCode: %d", response.httpStatusCode()); 158 165 completionHandler(PolicyAction::PolicyIgnore); 159 d elete this;166 didFinish(); 160 167 } 161 168 … … 172 179 else 173 180 RELEASE_LOG_IF_ALLOWED("didCompleteWithError, error_code: %d", error.errorCode()); 174 delete this; 181 182 didFinish(error); 175 183 } 176 184 … … 182 190 { 183 191 RELEASE_LOG_IF_ALLOWED("wasBlocked"); 184 d elete this;192 didFinish(blockedError(currentRequest())); 185 193 } 186 194 … … 188 196 { 189 197 RELEASE_LOG_IF_ALLOWED("cannotShowURL"); 190 d elete this;198 didFinish(cannotShowURLError(currentRequest())); 191 199 } 192 200 … … 194 202 { 195 203 RELEASE_LOG_IF_ALLOWED("timeoutTimerFired"); 196 delete this; 204 didFinish(ResourceError { String(), 0, currentRequest().url(), ASCIILiteral("Load timed out"), ResourceError::Type::Timeout }); 205 } 206 207 const ResourceRequest& PingLoad::currentRequest() const 208 { 209 if (m_lastRedirectionRequest) 210 return *m_lastRedirectionRequest; 211 212 return m_parameters.request; 197 213 } 198 214 … … 263 279 preflightSuccess(ResourceRequest { corsPreflightChecker->originalRequest() }); 264 280 else 265 d elete this;281 didFinish(ResourceError { String(), 0, corsPreflightChecker->originalRequest().url(), ASCIILiteral("CORS preflight failed"), ResourceError::Type::AccessControl }); 266 282 }); 267 283 m_corsPreflightChecker->startPreflight(); -
trunk/Source/WebKit/NetworkProcess/PingLoad.h
r220922 r220946 30 30 #include "NetworkDataTask.h" 31 31 #include "NetworkResourceLoadParameters.h" 32 #include <WebCore/ResourceError.h> 32 33 33 34 namespace WebCore { … … 69 70 70 71 WebCore::SecurityOrigin& securityOrigin() const; 72 73 const WebCore::ResourceRequest& currentRequest() const; 74 void didFinish(const WebCore::ResourceError& = { }); 71 75 72 76 NetworkResourceLoadParameters m_parameters; … … 81 85 RedirectCompletionHandler m_redirectHandler; 82 86 mutable std::unique_ptr<WebCore::ContentSecurityPolicy> m_contentSecurityPolicy; 87 std::optional<WebCore::ResourceRequest> m_lastRedirectionRequest; 83 88 }; 84 89 -
trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
r220922 r220946 136 136 } 137 137 138 void NetworkProcessConnection::didFinishPingLoad(uint64_t pingLoadIdentifier )138 void NetworkProcessConnection::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error) 139 139 { 140 WebProcess::singleton().webLoaderStrategy().didFinishPingLoad(pingLoadIdentifier );140 WebProcess::singleton().webLoaderStrategy().didFinishPingLoad(pingLoadIdentifier, WTFMove(error)); 141 141 } 142 142 -
trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
r220922 r220946 74 74 75 75 void didWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, const Vector<String>& filenames); 76 void didFinishPingLoad(uint64_t pingLoadIdentifier );76 void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&); 77 77 78 78 #if ENABLE(SHAREABLE_RESOURCE) -
trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.messages.in
r220922 r220946 28 28 29 29 DidWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, Vector<String> filenames) 30 DidFinishPingLoad(uint64_t pingLoadIdentifier )30 DidFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError error) 31 31 } -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
r220922 r220946 354 354 auto pingLoadCompletionHandlers = WTFMove(m_pingLoadCompletionHandlers); 355 355 for (auto& pingLoadCompletionHandler : pingLoadCompletionHandlers.values()) 356 pingLoadCompletionHandler( );356 pingLoadCompletionHandler(internalError(URL())); 357 357 } 358 358 … … 397 397 } 398 398 399 void WebLoaderStrategy::startPingLoad(NetworkingContext* networkingContext, ResourceRequest& request, const HTTPHeaderMap& originalRequestHeaders, Ref<SecurityOrigin>&& sourceOrigin, ContentSecurityPolicy* contentSecurityPolicy, const FetchOptions& options, WTF::Function<void()>&& completionHandler)399 void WebLoaderStrategy::startPingLoad(NetworkingContext* networkingContext, ResourceRequest& request, const HTTPHeaderMap& originalRequestHeaders, Ref<SecurityOrigin>&& sourceOrigin, ContentSecurityPolicy* contentSecurityPolicy, const FetchOptions& options, PingLoadCompletionHandler&& completionHandler) 400 400 { 401 401 // It's possible that call to createPingHandle might be made during initial empty Document creation before a NetworkingContext exists. … … 403 403 if (!networkingContext) { 404 404 if (completionHandler) 405 completionHandler( );405 completionHandler(internalError(request.url())); 406 406 return; 407 407 } … … 430 430 } 431 431 432 void WebLoaderStrategy::didFinishPingLoad(uint64_t pingLoadIdentifier )432 void WebLoaderStrategy::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error) 433 433 { 434 434 if (auto completionHandler = m_pingLoadCompletionHandlers.take(pingLoadIdentifier)) 435 completionHandler( );435 completionHandler(WTFMove(error)); 436 436 } 437 437 -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
r220922 r220946 60 60 void resumePendingRequests() final; 61 61 62 void startPingLoad(WebCore::NetworkingContext*, WebCore::ResourceRequest&, const WebCore::HTTPHeaderMap& originalRequestHeaders, Ref<WebCore::SecurityOrigin>&& sourceOrigin, WebCore::ContentSecurityPolicy*, const WebCore::FetchOptions&, WTF::Function<void()>&& completionHandler) final;63 void didFinishPingLoad(uint64_t pingLoadIdentifier );62 void startPingLoad(WebCore::NetworkingContext*, WebCore::ResourceRequest&, const WebCore::HTTPHeaderMap& originalRequestHeaders, Ref<WebCore::SecurityOrigin>&& sourceOrigin, WebCore::ContentSecurityPolicy*, const WebCore::FetchOptions&, PingLoadCompletionHandler&&) final; 63 void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&); 64 64 65 65 void storeDerivedDataToCache(const SHA1::Digest& bodyHash, const String& type, const String& partition, WebCore::SharedBuffer&) final; … … 86 86 HashMap<unsigned long, RefPtr<WebResourceLoader>> m_webResourceLoaders; 87 87 HashMap<unsigned long, WebURLSchemeTaskProxy*> m_urlSchemeTasks; 88 HashMap<unsigned long, WTF::Function<void()>> m_pingLoadCompletionHandlers;88 HashMap<unsigned long, PingLoadCompletionHandler> m_pingLoadCompletionHandlers; 89 89 }; 90 90 -
trunk/Source/WebKitLegacy/ChangeLog
r220922 r220946 1 2017-08-18 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Improve error reporting 4 https://bugs.webkit.org/show_bug.cgi?id=175723 5 6 Reviewed by Darin Adler. 7 8 Have Ping loads such as beacons report errors via their completion handler. 9 The Beacon API is using this error to log a console message when beacon loads 10 fail, provided that the page is still alive. 11 12 * WebCoreSupport/WebResourceLoadScheduler.cpp: 13 (WebResourceLoadScheduler::startPingLoad): 14 * WebCoreSupport/WebResourceLoadScheduler.h: 15 1 16 2017-08-18 Chris Dumez <cdumez@apple.com> 2 17 -
trunk/Source/WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.cpp
r220922 r220946 364 364 } 365 365 366 void WebResourceLoadScheduler::startPingLoad(NetworkingContext* networkingContext, ResourceRequest& request, const HTTPHeaderMap&, Ref<SecurityOrigin>&&, WebCore::ContentSecurityPolicy*, const FetchOptions& options, WTF::Function<void()>&& completionHandler)366 void WebResourceLoadScheduler::startPingLoad(NetworkingContext* networkingContext, ResourceRequest& request, const HTTPHeaderMap&, Ref<SecurityOrigin>&&, WebCore::ContentSecurityPolicy*, const FetchOptions& options, PingLoadCompletionHandler&& completionHandler) 367 367 { 368 368 // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled. -
trunk/Source/WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.h
r220922 r220946 60 60 void resumePendingRequests() final; 61 61 62 void startPingLoad(WebCore::NetworkingContext*, WebCore::ResourceRequest&, const WebCore::HTTPHeaderMap&, Ref<WebCore::SecurityOrigin>&& sourceOrigin, WebCore::ContentSecurityPolicy*, const WebCore::FetchOptions&, WTF::Function<void()>&& completionHandler) final;62 void startPingLoad(WebCore::NetworkingContext*, WebCore::ResourceRequest&, const WebCore::HTTPHeaderMap&, Ref<WebCore::SecurityOrigin>&& sourceOrigin, WebCore::ContentSecurityPolicy*, const WebCore::FetchOptions&, PingLoadCompletionHandler&&) final; 63 63 64 64 void storeDerivedDataToCache(const SHA1::Digest&, const String&, const String&, WebCore::SharedBuffer&) final { }
Note: See TracChangeset
for help on using the changeset viewer.