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 9095cbc961c7761406eb58c76264cf13e9b1f128..3f9c102758e078d3f10bdd3d7bac577bed7b2156 100644 |
--- a/third_party/inspector_protocol/lib/DispatcherBase_cpp.template |
+++ b/third_party/inspector_protocol/lib/DispatcherBase_cpp.template |
@@ -58,9 +58,10 @@ DispatcherBase::WeakPtr::~WeakPtr() |
m_dispatcher->m_weakPtrs.erase(this); |
} |
-DispatcherBase::Callback::Callback(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId) |
+DispatcherBase::Callback::Callback(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, int callbackId) |
: m_backendImpl(std::move(backendImpl)) |
- , m_callId(callId) { } |
+ , m_callId(callId) |
+ , m_callbackId(callbackId) { } |
DispatcherBase::Callback::~Callback() = default; |
@@ -77,14 +78,36 @@ void DispatcherBase::Callback::sendIfActive(std::unique_ptr<protocol::Dictionary |
m_backendImpl = nullptr; |
} |
+void DispatcherBase::Callback::fallThroughIfActive() |
+{ |
+ if (!m_backendImpl || !m_backendImpl->get()) |
+ return; |
+ m_backendImpl->get()->markFallThrough(m_callbackId); |
+ m_backendImpl = nullptr; |
+} |
+ |
DispatcherBase::DispatcherBase(FrontendChannel* frontendChannel) |
- : m_frontendChannel(frontendChannel) { } |
+ : m_frontendChannel(frontendChannel) |
+ , m_lastCallbackId(0) |
+ , m_lastCallbackFallThrough(false) { } |
DispatcherBase::~DispatcherBase() |
{ |
clearFrontend(); |
} |
+int DispatcherBase::nextCallbackId() |
+{ |
+ m_lastCallbackFallThrough = false; |
+ return ++m_lastCallbackId; |
+} |
+ |
+void DispatcherBase::markFallThrough(int callbackId) |
+{ |
+ if (callbackId == m_lastCallbackId) |
+ m_lastCallbackFallThrough = true; |
+} |
+ |
// static |
bool DispatcherBase::getCommandName(const String& message, String* result) |
{ |
@@ -171,6 +194,10 @@ std::unique_ptr<DispatcherBase::WeakPtr> DispatcherBase::weakPtr() |
UberDispatcher::UberDispatcher(FrontendChannel* frontendChannel) |
: m_frontendChannel(frontendChannel) { } |
+UberDispatcher::UberDispatcher(FrontendChannel* frontendChannel, bool fallThroughForNotFound) |
+ : m_frontendChannel(frontendChannel) |
+ , m_fallThroughForNotFound(fallThroughForNotFound) { } |
+ |
void UberDispatcher::registerBackend(const String& name, std::unique_ptr<protocol::DispatcherBase> dispatcher) |
{ |
m_dispatchers[name] = std::move(dispatcher); |
@@ -206,12 +233,16 @@ DispatchResponse::Status UberDispatcher::dispatch(std::unique_ptr<Value> parsedM |
size_t dotIndex = method.find("."); |
if (dotIndex == StringUtil::kNotFound) { |
+ if (m_fallThroughForNotFound) |
+ return DispatchResponse::kFallThrough; |
reportProtocolErrorTo(m_frontendChannel, callId, DispatchResponse::kMethodNotFound, "'" + method + "' wasn't found", nullptr); |
return DispatchResponse::kError; |
} |
String domain = StringUtil::substring(method, 0, dotIndex); |
auto it = m_dispatchers.find(domain); |
if (it == m_dispatchers.end()) { |
+ if (m_fallThroughForNotFound) |
+ return DispatchResponse::kFallThrough; |
reportProtocolErrorTo(m_frontendChannel, callId, DispatchResponse::kMethodNotFound, "'" + method + "' wasn't found", nullptr); |
return DispatchResponse::kError; |
} |