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

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: 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 PROTOCOL_DISALLOW_COPY(DispatcherBase);
23 public:
24 class WeakPtr {
25 public:
26 explicit WeakPtr(DispatcherBase*);
27 ~WeakPtr();
28 DispatcherBase* get() { return m_dispatcher; }
29 void dispose() { m_dispatcher = nullptr; }
30
31 private:
32 DispatcherBase* m_dispatcher;
33 };
34
35 class PLATFORM_EXPORT Callback : public protocol::BackendCallback {
36 public:
37 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId);
38 virtual ~Callback();
39 void dispose();
40
41 protected:
42 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess age, const ErrorString& invocationError);
43
44 private:
45 std::unique_ptr<WeakPtr> m_backendImpl;
46 int m_callId;
47 };
48
49 explicit DispatcherBase(FrontendChannel*);
50 virtual ~DispatcherBase();
51
52 enum CommonErrorCode {
53 ParseError = -32700,
54 InvalidRequest = -32600,
55 MethodNotFound = -32601,
56 InvalidParams = -32602,
57 InternalError = -32603,
58 ServerError = -32000,
59 };
60
61 static bool getCommandName(const String16& message, String16* result);
62
63 virtual void dispatch(int callId, const String16& method, std::unique_ptr<pr otocol::DictionaryValue> messageObject) = 0;
64
65 void sendResponse(int callId, const ErrorString&, ErrorSupport*, std::unique _ptr<protocol::DictionaryValue> result);
66 void sendResponse(int callId, const ErrorString&, std::unique_ptr<protocol:: DictionaryValue> result);
67 void sendResponse(int callId, const ErrorString&);
68
69 void reportProtocolError(int callId, CommonErrorCode, const String16& errorM essage, ErrorSupport* errors);
70 void clearFrontend();
71
72 std::unique_ptr<WeakPtr> weakPtr();
73
74 private:
75 FrontendChannel* m_frontendChannel;
76 protocol::HashSet<WeakPtr*> m_weakPtrs;
77 };
78
79 class PLATFORM_EXPORT UberDispatcher {
80 PROTOCOL_DISALLOW_COPY(UberDispatcher);
81 public:
82 explicit UberDispatcher(FrontendChannel*);
83 void registerBackend(const String16& name, std::unique_ptr<protocol::Dispatc herBase>);
84 void dispatch(const String16& message);
85 FrontendChannel* channel() { return m_frontendChannel; }
86 virtual ~UberDispatcher();
87
88 private:
89 FrontendChannel* m_frontendChannel;
90 protocol::HashMap<String16, std::unique_ptr<protocol::DispatcherBase>> m_dis patchers;
91 };
92
93 } // namespace platform
94 } // namespace blink
95
96 #endif // !defined(DispatcherBase_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698