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

Side by Side 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: per-domain generation Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DispatcherBase_h
6 #define DispatcherBase_h
7
8 #include "platform/PlatformExport.h"
9 #include "platform/inspector_protocol/BackendCallback.h"
10 #include "platform/inspector_protocol/Collections.h"
11 #include "platform/inspector_protocol/ErrorSupport.h"
12 #include "platform/inspector_protocol/String16.h"
13 #include "platform/inspector_protocol/Values.h"
14
15 namespace blink {
16 namespace protocol {
17
18 class FrontendChannel;
19 class WeakPtr;
20
21 class PLATFORM_EXPORT DispatcherBase {
22 public:
23 class WeakPtr {
24 public:
25 explicit WeakPtr(DispatcherBase*);
26 ~WeakPtr();
27 DispatcherBase* get() { return m_dispatcher; }
28 void dispose() { m_dispatcher = nullptr; }
29
30 private:
31 DispatcherBase* m_dispatcher;
32 };
33
34 class PLATFORM_EXPORT Callback : public protocol::BackendCallback {
35 public:
36 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId);
37 virtual ~Callback();
38 void dispose();
39
40 protected:
41 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess age, const ErrorString& invocationError);
42
43 private:
44 std::unique_ptr<WeakPtr> m_backendImpl;
45 int m_callId;
46 };
47
48 explicit DispatcherBase(FrontendChannel*);
49 virtual ~DispatcherBase();
50
51 enum CommonErrorCode {
52 ParseError = -32700,
53 InvalidRequest = -32600,
54 MethodNotFound = -32601,
55 InvalidParams = -32602,
56 InternalError = -32603,
57 ServerError = -32000,
58 };
59
60 static bool getCommandName(const String16& message, String16* result);
61
62 virtual void dispatch(int callId, const String16& method, std::unique_ptr<pr otocol::DictionaryValue> messageObject) = 0;
63
64 void sendResponse(int callId, const ErrorString&, ErrorSupport*, std::unique _ptr<protocol::DictionaryValue> result);
65 void sendResponse(int callId, const ErrorString&, std::unique_ptr<protocol:: DictionaryValue> result);
66 void sendResponse(int callId, const ErrorString&);
67
68 void reportProtocolError(int callId, CommonErrorCode, const String16& errorM essage, ErrorSupport* errors);
69 void clearFrontend();
70
71 std::unique_ptr<WeakPtr> weakPtr();
72
73 private:
74 FrontendChannel* m_frontendChannel;
75 protocol::HashSet<WeakPtr*> m_weakPtrs;
76 };
77
78 class PLATFORM_EXPORT UberDispatcher {
79 public:
80 explicit UberDispatcher(FrontendChannel*);
81 void registerBackend(const String16& name, std::unique_ptr<protocol::Dispatc herBase>);
82 void dispatch(const String16& message);
83 FrontendChannel* channel() { return m_frontendChannel; }
84 virtual ~UberDispatcher();
85
86 private:
87 FrontendChannel* m_frontendChannel;
88 protocol::HashMap<String16, std::unique_ptr<protocol::DispatcherBase>> m_dis patchers;
89 };
90
91 } // namespace platform
92 } // namespace blink
93
94 #endif // !defined(DispatcherBase_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698