Web Inspector: Switch to type-safe JSON ConsoleMessage.cpp, InspectorDOMAgent.cpp...
[WebKit-https.git] / Source / WebCore / inspector / ConsoleMessage.cpp
index e16a72ea666505c773c4e18be25fce4be40cdfa4..8d353f6f0665b95a733b033e61e1c0ff3f86f9d0 100644 (file)
@@ -134,17 +134,17 @@ static String messageLevelValue(MessageLevel level)
 
 void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
 {
-    RefPtr<InspectorObject> jsonObj = InspectorObject::create();
-    jsonObj->setString("source", messageSourceValue(m_source));
+    RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
+        .setSource(messageSourceValue(m_source))
+        .setLevel(messageLevelValue(m_level))
+        .setText(m_message);
     // FIXME: only send out type for ConsoleAPI source messages.
-    jsonObj->setString("type", messageTypeValue(m_type));
-    jsonObj->setString("level", messageLevelValue(m_level));
-    jsonObj->setNumber("line", static_cast<int>(m_line));
-    jsonObj->setString("url", m_url);
-    jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
-    jsonObj->setString("text", m_message);
+    jsonObj->setType(messageTypeValue(m_type));
+    jsonObj->setLine(static_cast<int>(m_line));
+    jsonObj->setUrl(m_url);
+    jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
     if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
-        jsonObj->setString("networkRequestId", m_requestId);
+        jsonObj->setNetworkRequestId(m_requestId);
     if (m_arguments && m_arguments->argumentCount()) {
         InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
         if (!injectedScript.hasNoValue()) {
@@ -157,11 +157,11 @@ void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, Injecte
                 }
                 jsonArgs->pushValue(inspectorValue);
             }
-            jsonObj->setArray("parameters", jsonArgs);
+            jsonObj->setParameters(jsonArgs);
         }
     }
     if (m_callStack)
-        jsonObj->setArray("stackTrace", m_callStack->buildInspectorArray());
+        jsonObj->setStackTrace(m_callStack->buildInspectorArray());
     frontend->messageAdded(jsonObj);
 }