コード例 #1
0
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());
}
コード例 #2
0
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());
}
コード例 #3
0
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload)
{
    if (preload->isPreconnect()) {
        preconnectHost(preload.get());
        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->charset().string() : preload->charset());
    request.setForPreload(true);
    Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20);
    m_document->loader()->startPreload(preload->resourceType(), request);
}
コード例 #4
0
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().getString() : 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);
}
コード例 #5
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());
}