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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/DispatcherBase_h.template

Issue 2282283002: [DevTools] Prepare inspector_protocol build to move. (Closed)
Patch Set: NOTREACHED Created 4 years, 3 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 {{"_".join(config.protocol.namespace)}}_DispatcherBase_h
6 #define {{"_".join(config.protocol.namespace)}}_DispatcherBase_h
7
8 //#include "BackendCallback.h"
9 //#include "Collections.h"
10 //#include "ErrorSupport.h"
11 //#include "Forward.h"
12 //#include "Values.h"
13
14 {% for namespace in config.protocol.namespace %}
15 namespace {{namespace}} {
16 {% endfor %}
17
18 class WeakPtr;
19
20 class {{config.class_export.macro}} DispatcherBase {
21 PROTOCOL_DISALLOW_COPY(DispatcherBase);
22 public:
23 static const char kInvalidRequest[];
24 class {{config.class_export.macro}} 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 {{config.class_export.macro}} Callback : public protocol::BackendCallb ack {
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 String& message, String* result);
62
63 virtual void dispatch(int callId, const String& method, std::unique_ptr<prot ocol::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 String& errorMes sage, 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 {{config.class_export.macro}} UberDispatcher {
80 PROTOCOL_DISALLOW_COPY(UberDispatcher);
81 public:
82 explicit UberDispatcher(FrontendChannel*);
83 void registerBackend(const String& name, std::unique_ptr<protocol::Dispatche rBase>);
84 void dispatch(std::unique_ptr<Value> message);
85 FrontendChannel* channel() { return m_frontendChannel; }
86 virtual ~UberDispatcher();
87
88 private:
89 FrontendChannel* m_frontendChannel;
90 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa tchers;
91 };
92
93 {% for namespace in config.protocol.namespace %}
94 } // namespace {{namespace}}
95 {% endfor %}
96
97 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698