Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template

Issue 1738073002: DevTools: introduce protocol::Value, baseline for hierarchical data in remote debugging protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
index 3b5f8ba0cb3f2df30768a1171f925c1c40f11501..d790ca399ef1c52d32f3365f5e84f7f9e273a9da 100644
--- a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
+++ b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template
@@ -6,8 +6,8 @@
#include "platform/inspector_protocol/{{class_name}}.h"
-#include "platform/JSONParser.h"
#include "platform/inspector_protocol/FrontendChannel.h"
+#include "platform/inspector_protocol/Parser.h"
#include "wtf/text/CString.h"
namespace blink {
@@ -45,7 +45,7 @@ public:
virtual void reportProtocolError(int sessionId, int callId, CommonErrorCode, const String& errorMessage, ErrorSupport* errors) const;
using Dispatcher::reportProtocolError;
- void sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassRefPtr<JSONObject> result);
+ void sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassRefPtr<protocol::DictionaryValue> result);
bool isActive() { return m_frontendChannel; }
{% for domain in api.domains %}
@@ -53,14 +53,14 @@ public:
{% endfor %}
private:
- using CallHandler = void (DispatcherImpl::*)(int sessionId, int callId, JSONObject* messageObject, ErrorSupport* errors);
+ using CallHandler = void (DispatcherImpl::*)(int sessionId, int callId, DictionaryValue* messageObject, ErrorSupport* errors);
using DispatchMap = HashMap<String, CallHandler>;
{% for domain in api.domains %}
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
- void {{domain.domain}}_{{command.name}}(int sessionId, int callId, JSONObject* requestMessageObject, ErrorSupport*);
+ void {{domain.domain}}_{{command.name}}(int sessionId, int callId, DictionaryValue* requestMessageObject, ErrorSupport*);
{% endfor %}
{% endfor %}
@@ -70,14 +70,14 @@ private:
{{domain.domain}}CommandHandler* m_{{domain.domain | lower}}Agent;
{% endfor %}
- void sendResponse(int sessionId, int callId, ErrorString invocationError, PassRefPtr<JSONObject> result)
+ void sendResponse(int sessionId, int callId, ErrorString invocationError, PassRefPtr<protocol::DictionaryValue> result)
{
sendResponse(sessionId, callId, invocationError, nullptr, result);
}
void sendResponse(int sessionId, int callId, ErrorString invocationError)
{
- sendResponse(sessionId, callId, invocationError, nullptr, JSONObject::create());
+ sendResponse(sessionId, callId, invocationError, nullptr, DictionaryValue::create());
}
static const char InvalidParamsFormatString[];
@@ -105,7 +105,7 @@ void Dispatcher::{{domain.domain}}CommandHandler::{{command.name | to_title_case
{%- if not loop.last -%}, {% endif -%}
{% endfor %})
{
- RefPtr<JSONObject> resultObject = JSONObject::create();
+ RefPtr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
{% for parameter in command.returns %}
{% if "optional" in parameter %}
if ({{parameter.name}}.isJust())
@@ -118,7 +118,7 @@ void Dispatcher::{{domain.domain}}CommandHandler::{{command.name | to_title_case
}
{% endif %}
-void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callId, JSONObject* requestMessageObject, ErrorSupport* errors)
+void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callId, DictionaryValue* requestMessageObject, ErrorSupport* errors)
{
if (!m_{{domain.domain | lower}}Agent)
errors->addError("{{domain.domain}} handler is not available.");
@@ -130,10 +130,10 @@ void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callI
{% if "parameters" in command %}
// Prepare input parameters.
- RefPtr<JSONObject> object = JSONObject::cast(requestMessageObject->get("params"));
+ RefPtr<protocol::DictionaryValue> object = DictionaryValue::cast(requestMessageObject->get("params"));
errors->push();
{% for property in command.parameters %}
- RefPtr<JSONValue> {{property.name}}Value = object ? object->get("{{property.name}}") : nullptr;
+ RefPtr<protocol::Value> {{property.name}}Value = object ? object->get("{{property.name}}") : nullptr;
{% if property.optional %}
Maybe<{{resolve_type(property).raw_type}}> in_{{property.name}};
if ({{property.name}}Value) {
@@ -156,7 +156,7 @@ void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callI
RefPtr<{{domain.domain}}CommandHandler::{{command.name | to_title_case}}Callback> callback = adoptRef(new {{domain.domain}}CommandHandler::{{command.name | to_title_case}}Callback(this, sessionId, callId));
{% elif "returns" in command %}
// Declare output parameters.
- RefPtr<JSONObject> result = JSONObject::create();
+ RefPtr<protocol::DictionaryValue> result = DictionaryValue::create();
{% for property in command.returns %}
{% if "optional" in property %}
Maybe<{{resolve_type(property).raw_type}}> out_{{property.name}};
@@ -210,16 +210,16 @@ void DispatcherImpl::dispatch(int sessionId, const String& message)
{
RefPtr<Dispatcher> protect(this);
int callId = 0;
- RefPtr<JSONValue> parsedMessage = parseJSON(message);
+ RefPtr<protocol::Value> parsedMessage = parseJSON(message);
ASSERT(parsedMessage);
- RefPtr<JSONObject> messageObject = JSONObject::cast(parsedMessage.release());
+ RefPtr<protocol::DictionaryValue> messageObject = DictionaryValue::cast(parsedMessage.release());
ASSERT(messageObject);
- RefPtr<JSONValue> callIdValue = messageObject->get("id");
+ RefPtr<protocol::Value> callIdValue = messageObject->get("id");
bool success = callIdValue->asNumber(&callId);
ASSERT_UNUSED(success, success);
- RefPtr<JSONValue> methodValue = messageObject->get("method");
+ RefPtr<protocol::Value> methodValue = messageObject->get("method");
String method;
success = methodValue && methodValue->asString(&method);
ASSERT_UNUSED(success, success);
@@ -234,14 +234,14 @@ void DispatcherImpl::dispatch(int sessionId, const String& message)
((*this).*it->value)(sessionId, callId, messageObject.get(), &errors);
}
-void DispatcherImpl::sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassRefPtr<JSONObject> result)
+void DispatcherImpl::sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassRefPtr<protocol::DictionaryValue> result)
{
if (invocationError.length() || (errors && errors->hasErrors())) {
reportProtocolError(sessionId, callId, ServerError, invocationError, errors);
return;
}
- RefPtr<JSONObject> responseMessage = JSONObject::create();
+ RefPtr<protocol::DictionaryValue> responseMessage = DictionaryValue::create();
responseMessage->setNumber("id", callId);
responseMessage->setObject("result", result);
if (m_frontendChannel)
@@ -259,13 +259,13 @@ void DispatcherImpl::reportProtocolError(int sessionId, int callId, CommonErrorC
ASSERT(code >=0);
ASSERT((unsigned)code < m_commonErrors.size());
ASSERT(m_commonErrors[code]);
- RefPtr<JSONObject> error = JSONObject::create();
+ RefPtr<protocol::DictionaryValue> error = DictionaryValue::create();
error->setNumber("code", m_commonErrors[code]);
error->setString("message", errorMessage);
ASSERT(error);
if (errors && errors->hasErrors())
error->setString("data", errors->errors());
- RefPtr<JSONObject> message = JSONObject::create();
+ RefPtr<protocol::DictionaryValue> message = DictionaryValue::create();
message->setObject("error", error);
message->setNumber("id", callId);
if (m_frontendChannel)
@@ -274,11 +274,11 @@ void DispatcherImpl::reportProtocolError(int sessionId, int callId, CommonErrorC
bool Dispatcher::getCommandName(const String& message, String* result)
{
- RefPtr<JSONValue> value = parseJSON(message);
+ RefPtr<protocol::Value> value = parseJSON(message);
if (!value)
return false;
- RefPtr<JSONObject> object = JSONObject::cast(value.release());
+ RefPtr<protocol::DictionaryValue> object = DictionaryValue::cast(value.release());
if (!object)
return false;
@@ -304,7 +304,7 @@ bool Dispatcher::CallbackBase::isActive()
return !m_alreadySent && m_backendImpl->isActive();
}
-void Dispatcher::CallbackBase::sendIfActive(PassRefPtr<JSONObject> partialMessage, const ErrorString& invocationError)
+void Dispatcher::CallbackBase::sendIfActive(PassRefPtr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError)
{
if (m_alreadySent)
return;

Powered by Google App Engine
This is Rietveld 408576698