void V8ConsoleMessageStorage::clear()
{
    m_messages.clear();
    m_expiredCount = 0;
    V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId);
    if (session) {
        session->consoleAgent()->reset();
        session->releaseObjectGroup("console");
        session->client()->consoleCleared();
    }
}
void V8ConsoleMessageStorage::addMessage(std::unique_ptr<V8ConsoleMessage> message)
{
    int contextGroupId = m_contextGroupId;
    V8DebuggerImpl* debugger = m_debugger;

    if (message->type() == ClearMessageType)
        clear();

    V8InspectorSessionImpl* session = debugger->sessionForContextGroup(contextGroupId);
    if (session)
        session->consoleAgent()->messageAdded(message.get());
    if (!debugger->hasConsoleMessageStorage(contextGroupId))
        return;

    DCHECK(m_messages.size() <= maxConsoleMessageCount);
    if (m_messages.size() == maxConsoleMessageCount) {
        ++m_expiredCount;
        m_messages.pop_front();
    }
    m_messages.push_back(std::move(message));
}
Esempio n. 3
0
void V8ConsoleMessageStorage::addMessage(std::unique_ptr<V8ConsoleMessage> message)
{
    if (message->type() == ConsoleAPIType::kClear) {
        clear();
        notifyClear();
    }

    V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId);
    if (session) {
        if (message->origin() == V8MessageOrigin::kConsole)
            session->consoleAgent()->messageAdded(message.get());
        session->runtimeAgent()->messageAdded(message.get());
    }

    DCHECK(m_messages.size() <= maxConsoleMessageCount);
    if (m_messages.size() == maxConsoleMessageCount) {
        ++m_expiredCount;
        m_messages.pop_front();
    }
    m_messages.push_back(std::move(message));
}