void ProcessThrottler::updateAssertion()
{
    // If the process is currently runnable but will be suspended then first give it a chance to complete what it was doing
    // and clean up - move it to the background and send it a message to notify. Schedule a timeout so it can't stay running
    // in the background for too long.
    if (m_assertion && m_assertion->state() != AssertionState::Suspended && !m_foregroundCounter.value() && !m_backgroundCounter.value()) {
        ++m_suspendMessageCount;
        RELEASE_LOG("%p - ProcessThrottler::updateAssertion() sending PrepareToSuspend IPC", this);
        m_process.sendPrepareToSuspend();
        m_suspendTimer.startOneShot(processSuspensionTimeout);
        m_assertion->setState(AssertionState::Background);
        m_process.didSetAssertionState(AssertionState::Background);
        return;
    }

    bool shouldBeRunnable = m_foregroundCounter.value() || m_backgroundCounter.value();

    // If we're currently waiting for the Web process to do suspension cleanup, but no longer need to be suspended, tell the Web process to cancel the cleanup.
    if (m_suspendTimer.isActive() && shouldBeRunnable)
        m_process.sendCancelPrepareToSuspend();
    
    if (m_assertion && m_assertion->state() == AssertionState::Suspended && shouldBeRunnable)
        m_process.sendProcessDidResume();

    updateAssertionNow();
}
Beispiel #2
0
void ProcessThrottler::updateAssertion()
{
    // If the process is currently runnable but will be suspended then first give it a chance to complete what it was doing
    // and clean up - move it to the background and send it a message to notify. Schedule a timeout so it can't stay running
    // in the background for too long.
    if (m_assertion && m_assertion->state() != AssertionState::Suspended && !m_foregroundCount && !m_backgroundCount) {
        ++m_suspendMessageCount;
        m_process->sendProcessWillSuspend();
        m_suspendTimer.startOneShot(processSuspensionTimeout);
        m_assertion->setState(AssertionState::Background);
        return;
    }

    // If we're currently waiting for the Web process to do suspension cleanup, but no longer need to be suspended, tell the Web process to cancel the cleanup.
    if (m_suspendTimer.isActive() && (m_foregroundCount || m_backgroundCount))
        m_process->sendCancelProcessWillSuspend();

    updateAssertionNow();
}
Beispiel #3
0
void ProcessThrottler::didCancelProcessSuspension()
{
    if (!--m_suspendMessageCount)
        updateAssertionNow();
    ASSERT(m_suspendMessageCount >= 0);
}
Beispiel #4
0
void ProcessThrottler::processReadyToSuspend()
{
    if (!--m_suspendMessageCount)
        updateAssertionNow();
    ASSERT(m_suspendMessageCount >= 0);
}
Beispiel #5
0
void ProcessThrottler::suspendTimerFired(WebCore::Timer<ProcessThrottler>*)
{
    updateAssertionNow();
}
void ProcessThrottler::suspendTimerFired()
{
    updateAssertionNow();
}