void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload, const NetworkHintsInterface& networkHintsInterface)
{
    if (preload->isPreconnect()) {
        preconnectHost(preload.get(), networkHintsInterface);
        return;
    }
    // TODO(yoichio): Should preload if document is imported.
    if (!m_document->loader())
        return;
    FetchRequest request = preload->resourceRequest(m_document);
    // TODO(dgozman): This check should go to HTMLPreloadScanner, but this requires
    // making Document::completeURLWithOverride logic to be statically accessible.
    if (request.url().protocolIsData())
        return;
    if (preload->resourceType() == Resource::Script || preload->resourceType() == Resource::CSSStyleSheet || preload->resourceType() == Resource::ImportResource)
        request.setCharset(preload->charset().isEmpty() ? m_document->characterSet().string() : preload->charset());
    request.setForPreload(true);
    int duration = static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime()));
    DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, ("WebCore.PreloadDelayMs", 0, 2000, 20));
    preloadDelayHistogram.count(duration);
    m_document->loader()->startPreload(preload->resourceType(), request);
}
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());
}
Ejemplo n.º 3
0
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload)
{
    FetchRequest request = preload->resourceRequest(m_document);
    blink::Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20);
    m_document->fetcher()->preload(preload->resourceType(), request, preload->charset());
}