예제 #1
0
void CachedResource::tryReplaceEncodedData(PassRefPtr<SharedBuffer> newBuffer)
{
    if (!m_data)
        return;
    
    if (!mayTryReplaceEncodedData())
        return;

    ASSERT(m_data->size() == newBuffer->size());
    ASSERT(!memcmp(m_data->data(), newBuffer->data(), m_data->size()));

    m_data->tryReplaceSharedBufferContents(newBuffer.get());
}
예제 #2
0
void CachedResource::tryReplaceEncodedData(SharedBuffer& newBuffer)
{
    if (!m_data)
        return;
    
    if (!mayTryReplaceEncodedData())
        return;

    // We have to do the memcmp because we can't tell if the replacement file backed data is for the
    // same resource or if we made a second request with the same URL which gave us a different
    // resource. We have seen this happen for cached POST resources.
    if (m_data->size() != newBuffer.size() || memcmp(m_data->data(), newBuffer.data(), m_data->size()))
        return;

    if (m_data->tryReplaceContentsWithPlatformBuffer(newBuffer))
        didReplaceSharedBufferContents();
}