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

Unified Diff: third_party/WebKit/Source/platform/inspector_protocol/DispatcherBase.h

Issue 2012753003: DevTools: consolidate protocol generators for front-end, backend and type builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/WebKit/Source/platform/inspector_protocol/DispatcherBase.h
diff --git a/third_party/WebKit/Source/platform/inspector_protocol/DispatcherBase.h b/third_party/WebKit/Source/platform/inspector_protocol/DispatcherBase.h
new file mode 100644
index 0000000000000000000000000000000000000000..466981281ded058fbb68912aa4d9faedabbf3278
--- /dev/null
+++ b/third_party/WebKit/Source/platform/inspector_protocol/DispatcherBase.h
@@ -0,0 +1,96 @@
+// 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 DispatcherBase_h
+#define DispatcherBase_h
+
+#include "platform/PlatformExport.h"
+#include "platform/inspector_protocol/BackendCallback.h"
+#include "platform/inspector_protocol/Collections.h"
+#include "platform/inspector_protocol/ErrorSupport.h"
+#include "platform/inspector_protocol/String16.h"
+#include "platform/inspector_protocol/Values.h"
+
+namespace blink {
+namespace protocol {
+
+class FrontendChannel;
+class WeakPtr;
+
+class PLATFORM_EXPORT DispatcherBase {
+ PROTOCOL_DISALLOW_COPY(DispatcherBase);
+public:
+ class WeakPtr {
+ public:
+ explicit WeakPtr(DispatcherBase*);
+ ~WeakPtr();
+ DispatcherBase* get() { return m_dispatcher; }
+ void dispose() { m_dispatcher = nullptr; }
+
+ private:
+ DispatcherBase* m_dispatcher;
+ };
+
+ class PLATFORM_EXPORT 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 String16& message, String16* result);
+
+ virtual void dispatch(int callId, const String16& 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 String16& errorMessage, ErrorSupport* errors);
+ void clearFrontend();
+
+ std::unique_ptr<WeakPtr> weakPtr();
+
+private:
+ FrontendChannel* m_frontendChannel;
+ protocol::HashSet<WeakPtr*> m_weakPtrs;
+};
+
+class PLATFORM_EXPORT UberDispatcher {
+ PROTOCOL_DISALLOW_COPY(UberDispatcher);
+public:
+ explicit UberDispatcher(FrontendChannel*);
+ void registerBackend(const String16& name, std::unique_ptr<protocol::DispatcherBase>);
+ void dispatch(const String16& message);
+ FrontendChannel* channel() { return m_frontendChannel; }
+ virtual ~UberDispatcher();
+
+private:
+ FrontendChannel* m_frontendChannel;
+ protocol::HashMap<String16, std::unique_ptr<protocol::DispatcherBase>> m_dispatchers;
+};
+
+} // namespace platform
+} // namespace blink
+
+#endif // !defined(DispatcherBase_h)

Powered by Google App Engine
This is Rietveld 408576698