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

Unified Diff: Source/core/inspector/CodeGeneratorInspectorStrings.py

Issue 325833002: DevTools: eliminate 1k lines of generated code in InspectorBackendDispatcher.cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
« no previous file with comments | « Source/core/inspector/CodeGeneratorInspector.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/CodeGeneratorInspectorStrings.py
diff --git a/Source/core/inspector/CodeGeneratorInspectorStrings.py b/Source/core/inspector/CodeGeneratorInspectorStrings.py
index c74f07c40c5a16e2876b4e89991ca9f9becd48a2..c83294ea1e00300a702e72c9c494707d54ac0768 100644
--- a/Source/core/inspector/CodeGeneratorInspectorStrings.py
+++ b/Source/core/inspector/CodeGeneratorInspectorStrings.py
@@ -44,23 +44,19 @@ ${frontendDomainMethodDeclarations}
""")
backend_method = (
-"""void InspectorBackendDispatcherImpl::${domainName}_$methodName(long callId, JSONObject*$requestMessageObject)
+"""void InspectorBackendDispatcherImpl::${domainName}_$methodName(long callId, JSONObject*$requestMessageObject, JSONArray* protocolErrors)
{
- RefPtr<JSONArray> protocolErrors = JSONArray::create();
yurys 2014/06/10 07:36:19 I'd rather we left previous implementation where p
-
if (!$agentField)
protocolErrors->pushString("${domainName} handler is not available.");
-$methodOutCode
-$methodInCode
- RefPtr<JSONObject> result = JSONObject::create();
- RefPtr<JSONValue> resultErrorData;
- ErrorString error;
- if (!protocolErrors->length()) {
- $agentField->$methodName(&error$agentCallParams);
-
-$errorCook${responseCook}
+$methodCode
+ if (protocolErrors->length()) {
+ reportProtocolError(&callId, InvalidParams, String::format(InvalidParamsFormatString, commandName($commandNameIndex)), protocolErrors);
+ return;
}
- sendResponse(callId, result, commandName($commandNameIndex), protocolErrors, error, resultErrorData);
+ ErrorString error;
+ $agentField->$methodName(&error$agentCallParams);
+$responseCook
+ sendResponse(callId, $sendResponseCallParams);
}
""")
@@ -247,7 +243,7 @@ $constructorInit
virtual void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<JSONValue> data) const;
using InspectorBackendDispatcher::reportProtocolError;
- void sendResponse(long callId, PassRefPtr<JSONObject> result, const ErrorString&invocationError, PassRefPtr<JSONValue> errorData);
+ void sendResponse(long callId, const ErrorString& invocationError, PassRefPtr<JSONValue> errorData, PassRefPtr<JSONObject> result);
bool isActive() { return m_inspectorFrontendChannel; }
$setters
@@ -267,10 +263,19 @@ $fieldDeclarations
static PassRefPtr<JSONObject> getObject(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors);
static PassRefPtr<JSONArray> getArray(JSONObject* object, const char* name, bool* valueFound, JSONArray* protocolErrors);
- void sendResponse(long callId, PassRefPtr<JSONObject> result, const char* commandName, PassRefPtr<JSONArray> protocolErrors, ErrorString invocationError, PassRefPtr<JSONValue> errorData);
-
+ void sendResponse(long callId, ErrorString invocationError, PassRefPtr<JSONObject> result)
+ {
+ sendResponse(callId, invocationError, RefPtr<JSONValue>(), result);
+ }
+ void sendResponse(long callId, ErrorString invocationError)
+ {
+ sendResponse(callId, invocationError, RefPtr<JSONValue>(), JSONObject::create());
+ }
+ static const char InvalidParamsFormatString[];
};
+const char InspectorBackendDispatcherImpl::InvalidParamsFormatString[] = "Some arguments of method '%s' can't be processed";
+
$methods
PassRefPtr<InspectorBackendDispatcher> InspectorBackendDispatcher::create(InspectorFrontendChannel* inspectorFrontendChannel)
@@ -282,7 +287,7 @@ PassRefPtr<InspectorBackendDispatcher> InspectorBackendDispatcher::create(Inspec
void InspectorBackendDispatcherImpl::dispatch(const String& message)
{
RefPtr<InspectorBackendDispatcher> protect = this;
- typedef void (InspectorBackendDispatcherImpl::*CallHandler)(long callId, JSONObject* messageObject);
+ typedef void (InspectorBackendDispatcherImpl::*CallHandler)(long callId, JSONObject* messageObject, JSONArray* protocolErrors);
typedef HashMap<String, CallHandler> DispatchMap;
DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
long callId = 0;
@@ -336,20 +341,11 @@ $messageHandlers
return;
}
- ((*this).*it->value)(callId, messageObject.get());
-}
-
-void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<JSONObject> result, const char* commandName, PassRefPtr<JSONArray> protocolErrors, ErrorString invocationError, PassRefPtr<JSONValue> errorData)
-{
- if (protocolErrors->length()) {
- String errorMessage = String::format("Some arguments of method '%s' can't be processed", commandName);
- reportProtocolError(&callId, InvalidParams, errorMessage, protocolErrors);
- return;
- }
- sendResponse(callId, result, invocationError, errorData);
+ RefPtr<JSONArray> protocolErrors = JSONArray::create();
+ ((*this).*it->value)(callId, messageObject.get(), protocolErrors.get());
}
-void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<JSONObject> result, const ErrorString& invocationError, PassRefPtr<JSONValue> errorData)
+void InspectorBackendDispatcherImpl::sendResponse(long callId, const ErrorString& invocationError, PassRefPtr<JSONValue> errorData, PassRefPtr<JSONObject> result)
{
if (invocationError.length()) {
reportProtocolError(&callId, ServerError, invocationError, errorData);
@@ -508,7 +504,7 @@ void InspectorBackendDispatcher::CallbackBase::sendIfActive(PassRefPtr<JSONObjec
{
if (m_alreadySent)
return;
- m_backendImpl->sendResponse(m_id, partialMessage, invocationError, errorData);
+ m_backendImpl->sendResponse(m_id, invocationError, errorData, partialMessage);
m_alreadySent = true;
}
@@ -901,7 +897,6 @@ $validatorCode
param_container_access_code = """
RefPtr<JSONObject> paramsContainer = requestMessageObject->getObject("params");
JSONObject* paramsContainerPtr = paramsContainer.get();
- JSONArray* protocolErrorsPtr = protocolErrors.get();
"""
class_binding_builder_part_1 = (
« no previous file with comments | « Source/core/inspector/CodeGeneratorInspector.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698