bool InspectorDebuggerAgent::breakpointActionsFromProtocol(ErrorString& errorString, RefPtr<InspectorArray>& actions, BreakpointActions* result) { if (!actions) return true; unsigned actionsLength = actions->length(); if (!actionsLength) return true; result->reserveCapacity(actionsLength); for (unsigned i = 0; i < actionsLength; ++i) { RefPtr<InspectorValue> value = actions->get(i); RefPtr<InspectorObject> object; if (!value->asObject(object)) { errorString = ASCIILiteral("BreakpointAction of incorrect type, expected object"); return false; } String typeString; if (!object->getString(ASCIILiteral("type"), typeString)) { errorString = ASCIILiteral("BreakpointAction had type missing"); return false; } ScriptBreakpointActionType type; if (!breakpointActionTypeForString(typeString, &type)) { errorString = ASCIILiteral("BreakpointAction had unknown type"); return false; } // Specifying an identifier is optional. They are used to correlate probe samples // in the frontend across multiple backend probe actions and segregate object groups. int identifier = 0; object->getInteger(ASCIILiteral("id"), identifier); String data; object->getString(ASCIILiteral("data"), data); result->append(ScriptBreakpointAction(type, identifier, data)); } return true; }
static bool breakpointActionsFromProtocol(ErrorString* errorString, RefPtr<InspectorArray>& actions, Vector<ScriptBreakpointAction>* result) { if (!actions) return true; unsigned actionsLength = actions->length(); if (!actionsLength) return true; result->reserveCapacity(actionsLength); for (unsigned i = 0; i < actionsLength; ++i) { RefPtr<InspectorValue> value = actions->get(i); RefPtr<InspectorObject> object; if (!value->asObject(&object)) { *errorString = "BreakpointAction of incorrect type, expected object"; return false; } String typeString; if (!object->getString("type", &typeString)) { *errorString = "BreakpointAction had type missing"; return false; } ScriptBreakpointActionType type; if (!breakpointActionTypeForString(typeString, &type)) { *errorString = "BreakpointAction had unknown type"; return false; } String data; object->getString("data", &data); result->append(ScriptBreakpointAction(type, data)); } return true; }