Esempio n. 1
0
void InjectedScript::ObjectScope::findInjectedScript(V8InspectorSessionImpl* session)
{
    std::unique_ptr<RemoteObjectId> remoteId = RemoteObjectId::parse(m_errorString, m_remoteObjectId);
    if (!remoteId)
        return;
    InjectedScript* injectedScript = session->findInjectedScript(m_errorString, remoteId.get());
    if (!injectedScript)
        return;
    m_objectGroupName = injectedScript->objectGroupName(*remoteId);
    if (!injectedScript->findObject(m_errorString, *remoteId, &m_object))
        return;
    m_injectedScript = injectedScript;
}
void InspectorHeapProfilerAgent::getHeapObjectId(ErrorString* errorString, const String& objectId, String* heapSnapshotObjectId)
{
    OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId);
    if (!remoteId) {
        *errorString = "Invalid object id";
        return;
    }
    InjectedScript injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get());
    if (injectedScript.isEmpty()) {
        *errorString = "Inspected context has gone";
        return;
    }
    ScriptState::Scope scope(injectedScript.scriptState());
    v8::Local<v8::Value> value = injectedScript.findObject(*remoteId);
    if (value.IsEmpty() || value->IsUndefined()) {
        *errorString = "Object with given id not found";
        return;
    }

    v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value);
    *heapSnapshotObjectId = String::number(id);
}