本文整理汇总了C++中WebURLResponse::wasFetchedViaServiceWorker方法的典型用法代码示例。如果您正苦于以下问题:C++ WebURLResponse::wasFetchedViaServiceWorker方法的具体用法?C++ WebURLResponse::wasFetchedViaServiceWorker怎么用?C++ WebURLResponse::wasFetchedViaServiceWorker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebURLResponse
的用法示例。
在下文中一共展示了WebURLResponse::wasFetchedViaServiceWorker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: didReceiveResponse
void ResourceLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& response, WebDataConsumerHandle* rawHandle)
{
ASSERT(!response.isNull());
ASSERT(m_state == Initialized);
// |rawHandle|'s ownership is transferred to the callee.
OwnPtr<WebDataConsumerHandle> handle = adoptPtr(rawHandle);
bool isMultipartPayload = response.isMultipartPayload();
bool isValidStateTransition = (m_connectionState == ConnectionStateStarted || m_connectionState == ConnectionStateReceivedResponse);
// In the case of multipart loads, calls to didReceiveData & didReceiveResponse can be interleaved.
RELEASE_ASSERT(isMultipartPayload || isValidStateTransition);
m_connectionState = ConnectionStateReceivedResponse;
const ResourceResponse& resourceResponse = response.toResourceResponse();
if (responseNeedsAccessControlCheck()) {
if (response.wasFetchedViaServiceWorker()) {
if (response.wasFallbackRequiredByServiceWorker()) {
m_loader->cancel();
m_loader.clear();
m_connectionState = ConnectionStateStarted;
m_loader = adoptPtr(Platform::current()->createURLLoader());
ASSERT(m_loader);
ASSERT(!m_request.skipServiceWorker());
m_request.setSkipServiceWorker(true);
WrappedResourceRequest wrappedRequest(m_request);
m_loader->loadAsynchronously(wrappedRequest, this);
return;
}
} else {
// If the response successfully validated a cached resource, perform
// the access control with respect to it. Need to do this right here
// before the resource switches clients over to that validated resource.
Resource* resource = m_resource;
if (!resource->isCacheValidator() || resourceResponse.httpStatusCode() != 304)
m_resource->setResponse(resourceResponse);
if (!m_fetcher->canAccessResource(resource, m_options.securityOrigin.get(), response.url(), ResourceFetcher::ShouldLogAccessControlErrors)) {
m_fetcher->didReceiveResponse(m_resource, resourceResponse);
cancel(ResourceError::cancelledDueToAccessCheckError(KURL(response.url())));
return;
}
}
}
m_resource->responseReceived(resourceResponse, handle.release());
if (m_state == Terminated)
return;
m_fetcher->didReceiveResponse(m_resource, resourceResponse);
if (m_state == Terminated)
return;
if (response.toResourceResponse().isMultipart()) {
// We only support multipart for images, though the image may be loaded
// as a main resource that we end up displaying through an ImageDocument.
if (!m_resource->isImage() && m_resource->type() != Resource::MainResource) {
cancel();
return;
}
m_loadingMultipartContent = true;
} else if (isMultipartPayload) {
// Since a subresource loader does not load multipart sections progressively, data was delivered to the loader all at once.
// After the first multipart section is complete, signal to delegates that this load is "finished"
m_fetcher->subresourceLoaderFinishedLoadingOnePart(this);
didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEncodedDataLength);
}
if (m_state == Terminated)
return;
if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnoreHTTPStatusCodeErrors())
return;
m_state = Finishing;
if (!m_notifiedLoadComplete) {
m_notifiedLoadComplete = true;
m_fetcher->didFailLoading(m_resource, ResourceError::cancelledError(m_request.url()));
}
ASSERT(m_state != Terminated);
m_resource->error(Resource::LoadError);
cancel();
}