本文整理汇总了C++中CachedResourceLoader::frame方法的典型用法代码示例。如果您正苦于以下问题:C++ CachedResourceLoader::frame方法的具体用法?C++ CachedResourceLoader::frame怎么用?C++ CachedResourceLoader::frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CachedResourceLoader
的用法示例。
在下文中一共展示了CachedResourceLoader::frame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openFunc
static void* openFunc(const char* uri)
{
ASSERT(XMLDocumentParserScope::currentCachedResourceLoader);
ASSERT(currentThread() == libxmlLoaderThread);
KURL url(KURL(), uri);
if (!shouldAllowExternalLoad(url))
return &globalDescriptor;
ResourceError error;
ResourceResponse response;
Vector<char> data;
{
CachedResourceLoader* cachedResourceLoader = XMLDocumentParserScope::currentCachedResourceLoader;
XMLDocumentParserScope scope(0);
// FIXME: We should restore the original global error handler as well.
if (cachedResourceLoader->frame())
cachedResourceLoader->frame()->loader()->loadResourceSynchronously(url, AllowStoredCredentials, error, response, data);
}
// We have to check the URL again after the load to catch redirects.
// See <https://bugs.webkit.org/show_bug.cgi?id=21963>.
if (!shouldAllowExternalLoad(response.url()))
return &globalDescriptor;
return new OffsetBuffer(data);
}
示例2: load
void CachedResource::load(CachedResourceLoader& cachedResourceLoader)
{
if (!cachedResourceLoader.frame()) {
RELEASE_LOG_IF_ALLOWED("load: No associated frame");
failBeforeStarting();
return;
}
Frame& frame = *cachedResourceLoader.frame();
// Prevent new loads if we are in the PageCache or being added to the PageCache.
// We query the top document because new frames may be created in pagehide event handlers
// and their pageCacheState will not reflect the fact that they are about to enter page
// cache.
if (auto* topDocument = frame.mainFrame().document()) {
if (topDocument->pageCacheState() != Document::NotInPageCache) {
RELEASE_LOG_IF_ALLOWED("load: Already in page cache or being added to it (frame = %p)", &frame);
failBeforeStarting();
return;
}
}
FrameLoader& frameLoader = frame.loader();
if (m_options.securityCheck == DoSecurityCheck && (frameLoader.state() == FrameStateProvisional || !frameLoader.activeDocumentLoader() || frameLoader.activeDocumentLoader()->isStopping())) {
if (frameLoader.state() == FrameStateProvisional)
RELEASE_LOG_IF_ALLOWED("load: Failed security check -- state is provisional (frame = %p)", &frame);
else if (!frameLoader.activeDocumentLoader())
RELEASE_LOG_IF_ALLOWED("load: Failed security check -- not active document (frame = %p)", &frame);
else if (frameLoader.activeDocumentLoader()->isStopping())
RELEASE_LOG_IF_ALLOWED("load: Failed security check -- active loader is stopping (frame = %p)", &frame);
failBeforeStarting();
return;
}
m_loading = true;
#if USE(QUICK_LOOK)
if (!m_resourceRequest.isNull() && m_resourceRequest.url().protocolIs(QLPreviewProtocol())) {
// When QuickLook is invoked to convert a document, it returns a unique URL in the
// NSURLReponse for the main document. To make safeQLURLForDocumentURLAndResourceURL()
// work, we need to use the QL URL not the original URL.
const URL& documentURL = frameLoader.documentLoader()->response().url();
m_resourceRequest.setURL(safeQLURLForDocumentURLAndResourceURL(documentURL, url()));
}
#endif
if (isCacheValidator()) {
CachedResource* resourceToRevalidate = m_resourceToRevalidate;
ASSERT(resourceToRevalidate->canUseCacheValidator());
ASSERT(resourceToRevalidate->isLoaded());
const String& lastModified = resourceToRevalidate->response().httpHeaderField(HTTPHeaderName::LastModified);
const String& eTag = resourceToRevalidate->response().httpHeaderField(HTTPHeaderName::ETag);
if (!lastModified.isEmpty() || !eTag.isEmpty()) {
ASSERT(cachedResourceLoader.cachePolicy(type()) != CachePolicyReload);
if (cachedResourceLoader.cachePolicy(type()) == CachePolicyRevalidate)
m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
if (!lastModified.isEmpty())
m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::IfModifiedSince, lastModified);
if (!eTag.isEmpty())
m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::IfNoneMatch, eTag);
}
}
#if ENABLE(LINK_PREFETCH)
if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkSubresource)
m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::Purpose, "prefetch");
#endif
m_resourceRequest.setPriority(loadPriority());
// Navigation algorithm is setting up the request before sending it to CachedResourceLoader?CachedResource.
// So no need for extra fields for MainResource.
if (type() != CachedResource::MainResource)
frameLoader.addExtraFieldsToSubresourceRequest(m_resourceRequest);
// FIXME: It's unfortunate that the cache layer and below get to know anything about fragment identifiers.
// We should look into removing the expectation of that knowledge from the platform network stacks.
ResourceRequest request(m_resourceRequest);
if (!m_fragmentIdentifierForRequest.isNull()) {
URL url = request.url();
url.setFragmentIdentifier(m_fragmentIdentifierForRequest);
request.setURL(url);
m_fragmentIdentifierForRequest = String();
}
m_loader = platformStrategies()->loaderStrategy()->loadResource(frame, *this, request, m_options);
if (!m_loader) {
RELEASE_LOG_IF_ALLOWED("load: Unable to create SubresourceLoader (frame = %p)", &frame);
failBeforeStarting();
return;
}
m_status = Pending;
}