Ejemplo n.º 1
0
void HTMLResourcePreloader::preload(std::unique_ptr<PreloadRequest> preload)
{
    ASSERT(m_document.frame());
    ASSERT(m_document.renderView());
    if (!preload->media().isEmpty() && !mediaAttributeMatches(m_document, &m_document.renderView()->style(), preload->media()))
        return;

    CachedResourceRequest request = preload->resourceRequest(m_document);
    m_document.cachedResourceLoader().preload(preload->resourceType(), request, preload->charset());
}
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload)
{
    ASSERT(m_document->frame());
    ASSERT(m_document->renderer());
    ASSERT(m_document->renderer()->style());
    if (!preload->media().isEmpty() && !mediaAttributeMatches(m_document->frame(), m_document->renderer()->style(), preload->media()))
        return;

    CachedResourceRequest request = preload->resourceRequest(m_document);
    m_document->cachedResourceLoader()->preload(preload->resourceType(), request, preload->charset());
}
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload)
{
    Document* executingDocument = m_document->import() ? m_document->import()->master() : m_document;
    Document* loadingDocument = m_document;

    ASSERT(executingDocument->frame());
    ASSERT(executingDocument->renderer());
    ASSERT(executingDocument->renderer()->style());
    if (!preload->media().isEmpty() && !mediaAttributeMatches(executingDocument->frame(), executingDocument->renderer()->style(), preload->media()))
        return;

    FetchRequest request = preload->resourceRequest(m_document);
    blink::Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20);
    loadingDocument->fetcher()->preload(preload->resourceType(), request, preload->charset());
}