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

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

Issue 2447323002: [inspector] use own copy of third_party/inspector_protocol (Closed)
Patch Set: updated README.v8 Created 4 years, 2 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
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)

Powered by Google App Engine
This is Rietveld 408576698