| Index: third_party/inspector_protocol/lib/DispatcherBase_h.template
|
| diff --git a/third_party/inspector_protocol/lib/DispatcherBase_h.template b/third_party/inspector_protocol/lib/DispatcherBase_h.template
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..17fd8708abdb76944afafdac03ff0db0df11df46
|
| --- /dev/null
|
| +++ b/third_party/inspector_protocol/lib/DispatcherBase_h.template
|
| @@ -0,0 +1,97 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef {{"_".join(config.protocol.namespace)}}_DispatcherBase_h
|
| +#define {{"_".join(config.protocol.namespace)}}_DispatcherBase_h
|
| +
|
| +//#include "BackendCallback.h"
|
| +//#include "Collections.h"
|
| +//#include "ErrorSupport.h"
|
| +//#include "Forward.h"
|
| +//#include "Values.h"
|
| +
|
| +{% for namespace in config.protocol.namespace %}
|
| +namespace {{namespace}} {
|
| +{% endfor %}
|
| +
|
| +class WeakPtr;
|
| +
|
| +class {{config.lib.export_macro}} DispatcherBase {
|
| + PROTOCOL_DISALLOW_COPY(DispatcherBase);
|
| +public:
|
| + static const char kInvalidRequest[];
|
| + class {{config.lib.export_macro}} WeakPtr {
|
| + public:
|
| + explicit WeakPtr(DispatcherBase*);
|
| + ~WeakPtr();
|
| + DispatcherBase* get() { return m_dispatcher; }
|
| + void dispose() { m_dispatcher = nullptr; }
|
| +
|
| + private:
|
| + DispatcherBase* m_dispatcher;
|
| + };
|
| +
|
| + class {{config.lib.export_macro}} Callback : public protocol::BackendCallback {
|
| + public:
|
| + Callback(std::unique_ptr<WeakPtr> backendImpl, int callId);
|
| + virtual ~Callback();
|
| + void dispose();
|
| +
|
| + protected:
|
| + void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError);
|
| +
|
| + private:
|
| + std::unique_ptr<WeakPtr> m_backendImpl;
|
| + int m_callId;
|
| + };
|
| +
|
| + explicit DispatcherBase(FrontendChannel*);
|
| + virtual ~DispatcherBase();
|
| +
|
| + enum CommonErrorCode {
|
| + ParseError = -32700,
|
| + InvalidRequest = -32600,
|
| + MethodNotFound = -32601,
|
| + InvalidParams = -32602,
|
| + InternalError = -32603,
|
| + ServerError = -32000,
|
| + };
|
| +
|
| + static bool getCommandName(const String& message, String* result);
|
| +
|
| + virtual void dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) = 0;
|
| +
|
| + void sendResponse(int callId, const ErrorString&, ErrorSupport*, std::unique_ptr<protocol::DictionaryValue> result);
|
| + void sendResponse(int callId, const ErrorString&, std::unique_ptr<protocol::DictionaryValue> result);
|
| + void sendResponse(int callId, const ErrorString&);
|
| +
|
| + void reportProtocolError(int callId, CommonErrorCode, const String& errorMessage, ErrorSupport* errors);
|
| + void clearFrontend();
|
| +
|
| + std::unique_ptr<WeakPtr> weakPtr();
|
| +
|
| +private:
|
| + FrontendChannel* m_frontendChannel;
|
| + protocol::HashSet<WeakPtr*> m_weakPtrs;
|
| +};
|
| +
|
| +class {{config.lib.export_macro}} UberDispatcher {
|
| + PROTOCOL_DISALLOW_COPY(UberDispatcher);
|
| +public:
|
| + explicit UberDispatcher(FrontendChannel*);
|
| + void registerBackend(const String& name, std::unique_ptr<protocol::DispatcherBase>);
|
| + void dispatch(std::unique_ptr<Value> message);
|
| + FrontendChannel* channel() { return m_frontendChannel; }
|
| + virtual ~UberDispatcher();
|
| +
|
| +private:
|
| + FrontendChannel* m_frontendChannel;
|
| + protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispatchers;
|
| +};
|
| +
|
| +{% for namespace in config.protocol.namespace %}
|
| +} // namespace {{namespace}}
|
| +{% endfor %}
|
| +
|
| +#endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h)
|
|
|