private boolean maybeHandleDebuggerCustomMessageResponse(ExtensionResponse response) {
final int messageId = response.messageId();
final String sessionId = response.sessionId();
final String methodName = response.methodName();
final Jso result = response.result();
if (idToCustomMessageIds.get(sessionId) != null
&& idToCustomMessageIds.get(sessionId).hasKey(messageId)) {
JsIntegerMap<Integer> map = idToCustomMessageIds.get(sessionId);
Jso customResponse = Jso.create();
customResponse.addField("id", map.get(messageId).intValue());
customResponse.addField("result", result);
if (response.isError()) {
customResponse.addField("error", response.errorMessage());
}
final String customResponseSerialized = Jso.serialize(customResponse);
map.erase(messageId);
dispatchDebuggerResponse(new DebuggerResponseDispatcher() {
@Override
public void dispatch(DebuggerResponseListener responseListener) {
responseListener.onCustomMessageResponse(sessionId, customResponseSerialized);
}
});
return true;
} else if (methodName.startsWith("DOM.")) {
Jso customResponse = Jso.create();
customResponse.addField("method", methodName);
customResponse.addField("params", result);
if (response.isError()) {
customResponse.addField("error", response.errorMessage());
}
final String customResponseSerialized = Jso.serialize(customResponse);
dispatchDebuggerResponse(new DebuggerResponseDispatcher() {
@Override