void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const String16& heapSnapshotObjectId, const protocol::Maybe<String16>& objectGroup, std::unique_ptr<protocol::Runtime::RemoteObject>* result) { bool ok; int id = heapSnapshotObjectId.toInteger(&ok); if (!ok) { *error = "Invalid heap snapshot object id"; return; } v8::HandleScope handles(m_isolate); v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id); if (heapObject.IsEmpty()) { *error = "Object is not available"; return; } if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) { *error = "Object is not available"; return; } *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe(""), false); if (!result) *error = "Object is not available"; }
void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, const String16& inspectedHeapObjectId) { bool ok; int id = inspectedHeapObjectId.toInteger(&ok); if (!ok) { *errorString = "Invalid heap snapshot object id"; return; } v8::HandleScope handles(m_isolate); v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id); if (heapObject.IsEmpty()) { *errorString = "Object is not available"; return; } if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) { *errorString = "Object is not available"; return; } m_session->addInspectedObject(wrapUnique(new InspectableHeapObject(id))); }