Esempio n. 1
0
// Try to create a PurgeableBuffer. We can fail to create one for any of the
// following reasons:
//   - shouldUsePurgeableMemory is set to false.
//   - the size of the buffer is less than the minimum size required by
//     PurgeableBuffer (currently 16k).
//   - PurgeableBuffer::createUninitialized() call fails.
void SharedBuffer::createPurgeableBuffer() const
{
    if (m_purgeableBuffer)
        return;

    if (hasPlatformData())
        return;

#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
    if (singleDataArrayBuffer())
        return;
#endif

    if (!hasOneRef())
        return;

    if (!m_shouldUsePurgeableMemory)
        return;

    char* destination = 0;
    m_purgeableBuffer = PurgeableBuffer::createUninitialized(m_size, destination);
    if (!m_purgeableBuffer)
        return;
    unsigned bufferSize = m_buffer.size();
    if (bufferSize) {
        memcpy(destination, m_buffer.data(), bufferSize);
        destination += bufferSize;
        m_buffer.clear();
    }
    copyBufferAndClear(destination, m_size - bufferSize);
}
Esempio n. 2
0
void MainFrame::selfOnlyDeref()
{
    ASSERT(m_selfOnlyRefCount);
    if (--m_selfOnlyRefCount)
        return;

    if (hasOneRef())
        dropChildren();

    deref();
}
bool MediaValuesCached::isSafeToSendToAnotherThread() const
{
#if ENABLE(OILPAN)
    // Oilpan objects are safe to send to another thread as long as the thread
    // does not outlive the thread used for creation. MediaValues are
    // allocated on the main thread and may be passed to the parser thread,
    // so this should be safe.
    return true;
#else
    return hasOneRef();
#endif
}
Esempio n. 4
0
void IDBRequest::checkForReferenceCycle()
{
    // If this request and its cursor have the only references
    // to each other, then explicitly break the cycle.
    IDBCursor* cursor = getResultCursor();
    if (!cursor || cursor->request() != this)
        return;

    if (!hasOneRef() || !cursor->hasOneRef())
        return;

    m_result.clear();
}
Esempio n. 5
0
void IDBCursor::checkForReferenceCycle()
{
    // If this cursor and its request have the only references
    // to each other, then explicitly break the cycle.
    if (!m_request || m_request->getResultCursor() != this)
        return;

    if (!hasOneRef() || !m_request->hasOneRef())
        return;

    handleBlobAcks();
    m_request.clear();
}
Esempio n. 6
0
void PluginView::unprotectPluginFromDestruction()
{
    if (m_isBeingDestroyed)
        return;

    // A plug-in may ask us to evaluate JavaScript that removes the plug-in from the
    // page, but expect the object to still be alive when the call completes. Flash,
    // for example, may crash if the plug-in is destroyed and we return to code for
    // the destroyed object higher on the stack. To prevent this, if the plug-in has
    // only one remaining reference, call deref() asynchronously.
    if (hasOneRef())
        RunLoop::main()->dispatch(bind(derefPluginView, this));
    else
        deref();
}
Esempio n. 7
0
bool AnimationPlayer::canFree() const
{
    ASSERT(m_content);
    return hasOneRef() && m_content->isAnimation() && m_content->hasOneRef();
}
Esempio n. 8
0
PassOwnPtr<PurgeableBuffer> SharedBuffer::releasePurgeableBuffer()
{ 
    ASSERT(hasOneRef()); 
    return m_purgeableBuffer.release(); 
}
Esempio n. 9
0
bool MediaValues::isSafeToSendToAnotherThread() const
{
    return (!m_frame && !m_style && m_mode == CachingMode && hasOneRef());
}
Esempio n. 10
0
bool MediaValuesCached::isSafeToSendToAnotherThread() const
{
    return hasOneRef();
}