Ejemplo n.º 1
0
void CachedTextTrack::updateData(SharedBuffer* data)
{
    ASSERT(dataBufferingPolicy() == BufferData);
    m_data = data;
    setEncodedSize(data ? data->size() : 0);

    CachedResourceClientWalker<CachedResourceClient> walker(m_clients);
    while (CachedResourceClient* client = walker.next())
        client->deprecatedDidReceiveCachedResource(this);
}
Ejemplo n.º 2
0
void CachedRawResource::addDataBuffer(SharedBuffer& data)
{
    CachedResourceHandle<CachedRawResource> protect(this);
    ASSERT(dataBufferingPolicy() == BufferData);
    m_data = &data;

    unsigned incrementalDataLength;
    const char* incrementalData = calculateIncrementalDataChunk(&data, incrementalDataLength);
    setEncodedSize(data.size());
    notifyClientsDataWasReceived(incrementalData, incrementalDataLength);
    if (dataBufferingPolicy() == DoNotBufferData) {
        if (m_loader)
            m_loader->setDataBufferingPolicy(DoNotBufferData);
        clear();
        return;
    }

    CachedResource::addDataBuffer(data);
}
Ejemplo n.º 3
0
bool CachedRawResource::canReuse(const ResourceRequest& newRequest) const
{
    if (dataBufferingPolicy() == DoNotBufferData)
        return false;

    if (m_resourceRequest.httpMethod() != newRequest.httpMethod())
        return false;

    if (m_resourceRequest.httpBody() != newRequest.httpBody())
        return false;

    if (m_resourceRequest.allowCookies() != newRequest.allowCookies())
        return false;

    if (newRequest.isConditional())
        return false;

    // Ensure most headers match the existing headers before continuing.
    // Note that the list of ignored headers includes some headers explicitly related to caching.
    // A more detailed check of caching policy will be performed later, this is simply a list of
    // headers that we might permit to be different and still reuse the existing CachedResource.
    const HTTPHeaderMap& newHeaders = newRequest.httpHeaderFields();
    const HTTPHeaderMap& oldHeaders = m_resourceRequest.httpHeaderFields();

    for (const auto& header : newHeaders) {
        if (header.keyAsHTTPHeaderName) {
            if (!shouldIgnoreHeaderForCacheReuse(header.keyAsHTTPHeaderName.value())
                && header.value != oldHeaders.commonHeaders().get(header.keyAsHTTPHeaderName.value()))
                return false;
        } else if (header.value != oldHeaders.uncommonHeaders().get(header.key))
            return false;
    }

    // For this second loop, we don't actually need to compare values, checking that the
    // key is contained in newHeaders is sufficient due to the previous loop.
    for (const auto& header : oldHeaders) {
        if (header.keyAsHTTPHeaderName) {
            if (!shouldIgnoreHeaderForCacheReuse(header.keyAsHTTPHeaderName.value())
                && !newHeaders.commonHeaders().contains(header.keyAsHTTPHeaderName.value()))
                return false;
        } else if (!newHeaders.uncommonHeaders().contains(header.key))
            return false;
    }

    return true;
}
Ejemplo n.º 4
0
void CachedRawResource::addData(const char* data, unsigned length)
{
    ASSERT(dataBufferingPolicy() == DoNotBufferData);
    notifyClientsDataWasReceived(data, length);
    CachedResource::addData(data, length);
}
Ejemplo n.º 5
0
void CachedImage::addData(const char* data, unsigned length)
{
    ASSERT(dataBufferingPolicy() == DoNotBufferData);
    addIncrementalDataBuffer(*SharedBuffer::create(data, length));
    CachedResource::addData(data, length);
}
Ejemplo n.º 6
0
void CachedImage::addDataBuffer(SharedBuffer& data)
{
    ASSERT(dataBufferingPolicy() == BufferData);
    addIncrementalDataBuffer(data);
    CachedResource::addDataBuffer(data);
}
Ejemplo n.º 7
0
void CachedResource::addData(const char*, unsigned)
{
    ASSERT(dataBufferingPolicy() == DoNotBufferData);
}
Ejemplo n.º 8
0
void CachedResource::addDataBuffer(SharedBuffer&)
{
    ASSERT(dataBufferingPolicy() == BufferData);
}