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

Unified Diff: third_party/inspector_protocol/lib/DispatcherBase_cpp.template

Issue 2548263002: [DevTools] Migrate dom, emulation, inspector, network, page and schema handlers to new generator. (Closed)
Patch Set: rebase, test fix Created 4 years 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/inspector_protocol/lib/DispatcherBase_cpp.template
diff --git a/third_party/inspector_protocol/lib/DispatcherBase_cpp.template b/third_party/inspector_protocol/lib/DispatcherBase_cpp.template
index 0d4a305abe89872af970ba20b9dc8cc1da563a20..af0aff264c2de58f6e01315ee9d0941d69d87dfd 100644
--- a/third_party/inspector_protocol/lib/DispatcherBase_cpp.template
+++ b/third_party/inspector_protocol/lib/DispatcherBase_cpp.template
@@ -248,7 +248,13 @@ void UberDispatcher::registerBackend(const String& name, std::unique_ptr<protoco
m_dispatchers[name] = std::move(dispatcher);
}
-DispatchResponse::Status UberDispatcher::dispatch(std::unique_ptr<Value> parsedMessage)
+void UberDispatcher::setupRedirects(const HashMap<String, String>& redirects)
+{
+ for (const auto& pair : redirects)
caseq 2016/12/09 01:57:49 nit: do we really need to clone it?
dgozman 2016/12/12 23:01:25 Yes, this accumulates them in UberDispatcher.
+ m_redirects[pair.first] = pair.second;
+}
+
+DispatchResponse::Status UberDispatcher::dispatch(std::unique_ptr<Value> parsedMessage, int* outCallId, String* outMethod)
{
if (!parsedMessage) {
reportProtocolErrorTo(m_frontendChannel, DispatchResponse::kParseError, "Message must be a valid JSON");
@@ -263,6 +269,8 @@ DispatchResponse::Status UberDispatcher::dispatch(std::unique_ptr<Value> parsedM
int callId = 0;
protocol::Value* callIdValue = messageObject->get("id");
bool success = callIdValue && callIdValue->asInteger(&callId);
+ if (outCallId)
+ *outCallId = callId;
if (!success) {
reportProtocolErrorTo(m_frontendChannel, DispatchResponse::kInvalidRequest, "Message must have integer 'id' porperty");
return DispatchResponse::kError;
@@ -271,11 +279,16 @@ DispatchResponse::Status UberDispatcher::dispatch(std::unique_ptr<Value> parsedM
protocol::Value* methodValue = messageObject->get("method");
String method;
success = methodValue && methodValue->asString(&method);
+ if (outMethod)
+ *outMethod = method;
if (!success) {
reportProtocolErrorTo(m_frontendChannel, callId, DispatchResponse::kInvalidRequest, "Message must have string 'method' porperty", nullptr);
return DispatchResponse::kError;
}
+ if (m_redirects.find(method) != m_redirects.end())
caseq 2016/12/09 01:57:49 nit: keep the iterator returned from find to avoid
dgozman 2016/12/12 23:01:25 Done.
+ method = m_redirects[method];
+
size_t dotIndex = method.find(".");
if (dotIndex == StringUtil::kNotFound) {
if (m_fallThroughForNotFound)
« no previous file with comments | « third_party/inspector_protocol/CodeGenerator.py ('k') | third_party/inspector_protocol/lib/DispatcherBase_h.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698