5 #include "src/inspector/remote-object-id.h" 7 #include "src/inspector/protocol/Protocol.h" 8 #include "src/inspector/string-util.h" 12 RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) {}
14 std::unique_ptr<protocol::DictionaryValue>
15 RemoteObjectIdBase::parseInjectedScriptId(
const String16& objectId) {
16 std::unique_ptr<protocol::Value> parsedValue =
17 protocol::StringUtil::parseJSON(objectId);
18 if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject)
21 std::unique_ptr<protocol::DictionaryValue> parsedObjectId(
22 protocol::DictionaryValue::cast(parsedValue.release()));
24 parsedObjectId->getInteger(
"injectedScriptId", &m_injectedScriptId);
25 if (success)
return parsedObjectId;
29 RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) {}
31 Response RemoteObjectId::parse(
const String16& objectId,
32 std::unique_ptr<RemoteObjectId>* result) {
33 std::unique_ptr<RemoteObjectId> remoteObjectId(
new RemoteObjectId());
34 std::unique_ptr<protocol::DictionaryValue> parsedObjectId =
35 remoteObjectId->parseInjectedScriptId(objectId);
36 if (!parsedObjectId)
return Response::Error(
"Invalid remote object id");
38 bool success = parsedObjectId->getInteger(
"id", &remoteObjectId->m_id);
39 if (!success)
return Response::Error(
"Invalid remote object id");
40 *result = std::move(remoteObjectId);
41 return Response::OK();
44 RemoteCallFrameId::RemoteCallFrameId()
45 : RemoteObjectIdBase(), m_frameOrdinal(0) {}
47 Response RemoteCallFrameId::parse(
const String16& objectId,
48 std::unique_ptr<RemoteCallFrameId>* result) {
49 std::unique_ptr<RemoteCallFrameId> remoteCallFrameId(
new RemoteCallFrameId());
50 std::unique_ptr<protocol::DictionaryValue> parsedObjectId =
51 remoteCallFrameId->parseInjectedScriptId(objectId);
52 if (!parsedObjectId)
return Response::Error(
"Invalid call frame id");
55 parsedObjectId->getInteger(
"ordinal", &remoteCallFrameId->m_frameOrdinal);
56 if (!success)
return Response::Error(
"Invalid call frame id");
57 *result = std::move(remoteCallFrameId);
58 return Response::OK();
61 String16 RemoteCallFrameId::serialize(
int injectedScriptId,
int frameOrdinal) {
62 return "{\"ordinal\":" + String16::fromInteger(frameOrdinal) +
63 ",\"injectedScriptId\":" + String16::fromInteger(injectedScriptId) +