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

Side by Side Diff: third_party/inspector_protocol/lib/DispatcherBase_h.template

Issue 2500093002: [DevTools] Move IO and Tracing to new generator. (Closed)
Patch Set: roll Created 4 years, 1 month 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef {{"_".join(config.protocol.namespace)}}_DispatcherBase_h 5 #ifndef {{"_".join(config.protocol.namespace)}}_DispatcherBase_h
6 #define {{"_".join(config.protocol.namespace)}}_DispatcherBase_h 6 #define {{"_".join(config.protocol.namespace)}}_DispatcherBase_h
7 7
8 //#include "Collections.h" 8 //#include "Collections.h"
9 //#include "ErrorSupport.h" 9 //#include "ErrorSupport.h"
10 //#include "Forward.h" 10 //#include "Forward.h"
(...skipping 24 matching lines...) Expand all
35 }; 35 };
36 36
37 Status status() const { return m_status; } 37 Status status() const { return m_status; }
38 const String& errorMessage() const { return m_errorMessage; } 38 const String& errorMessage() const { return m_errorMessage; }
39 ErrorCode errorCode() const { return m_errorCode; } 39 ErrorCode errorCode() const { return m_errorCode; }
40 bool isSuccess() const { return m_status == kSuccess; } 40 bool isSuccess() const { return m_status == kSuccess; }
41 41
42 static DispatchResponse OK(); 42 static DispatchResponse OK();
43 static DispatchResponse Error(const String&); 43 static DispatchResponse Error(const String&);
44 static DispatchResponse InternalError(); 44 static DispatchResponse InternalError();
45 static DispatchResponse InvalidParams(const String&);
45 static DispatchResponse FallThrough(); 46 static DispatchResponse FallThrough();
46 47
47 private: 48 private:
48 Status m_status; 49 Status m_status;
49 String m_errorMessage; 50 String m_errorMessage;
50 ErrorCode m_errorCode; 51 ErrorCode m_errorCode;
51 }; 52 };
52 53
53 class {{config.lib.export_macro}} DispatcherBase { 54 class {{config.lib.export_macro}} DispatcherBase {
54 PROTOCOL_DISALLOW_COPY(DispatcherBase); 55 PROTOCOL_DISALLOW_COPY(DispatcherBase);
55 public: 56 public:
56 static const char kInvalidParamsString[]; 57 static const char kInvalidParamsString[];
57 class {{config.lib.export_macro}} WeakPtr { 58 class {{config.lib.export_macro}} WeakPtr {
58 public: 59 public:
59 explicit WeakPtr(DispatcherBase*); 60 explicit WeakPtr(DispatcherBase*);
60 ~WeakPtr(); 61 ~WeakPtr();
61 DispatcherBase* get() { return m_dispatcher; } 62 DispatcherBase* get() { return m_dispatcher; }
62 void dispose() { m_dispatcher = nullptr; } 63 void dispose() { m_dispatcher = nullptr; }
63 64
64 private: 65 private:
65 DispatcherBase* m_dispatcher; 66 DispatcherBase* m_dispatcher;
66 }; 67 };
67 68
68 class {{config.lib.export_macro}} Callback { 69 class {{config.lib.export_macro}} Callback {
69 public: 70 public:
70 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId); 71 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId, int callbackI d);
71 virtual ~Callback(); 72 virtual ~Callback();
72 void dispose(); 73 void dispose();
73 74
74 protected: 75 protected:
75 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess age, const DispatchResponse& response); 76 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess age, const DispatchResponse& response);
77 void fallThroughIfActive();
76 78
77 private: 79 private:
78 std::unique_ptr<WeakPtr> m_backendImpl; 80 std::unique_ptr<WeakPtr> m_backendImpl;
79 int m_callId; 81 int m_callId;
82 int m_callbackId;
80 }; 83 };
81 84
82 explicit DispatcherBase(FrontendChannel*); 85 explicit DispatcherBase(FrontendChannel*);
83 virtual ~DispatcherBase(); 86 virtual ~DispatcherBase();
84 87
85 static bool getCommandName(const String& message, String* result); 88 static bool getCommandName(const String& message, String* result);
86 89
87 virtual DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) = 0; 90 virtual DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) = 0;
88 91
89 void sendResponse(int callId, const DispatchResponse&, std::unique_ptr<proto col::DictionaryValue> result); 92 void sendResponse(int callId, const DispatchResponse&, std::unique_ptr<proto col::DictionaryValue> result);
90 void sendResponse(int callId, const DispatchResponse&); 93 void sendResponse(int callId, const DispatchResponse&);
91 94
92 void reportProtocolError(int callId, DispatchResponse::ErrorCode, const Stri ng& errorMessage, ErrorSupport* errors); 95 void reportProtocolError(int callId, DispatchResponse::ErrorCode, const Stri ng& errorMessage, ErrorSupport* errors);
93 void clearFrontend(); 96 void clearFrontend();
94 97
95 std::unique_ptr<WeakPtr> weakPtr(); 98 std::unique_ptr<WeakPtr> weakPtr();
96 99
100 int nextCallbackId();
101 void markFallThrough(int callbackId);
102 bool lastCallbackFallThrough() { return m_lastCallbackFallThrough; }
103
97 private: 104 private:
98 FrontendChannel* m_frontendChannel; 105 FrontendChannel* m_frontendChannel;
99 protocol::HashSet<WeakPtr*> m_weakPtrs; 106 protocol::HashSet<WeakPtr*> m_weakPtrs;
107 int m_lastCallbackId;
108 bool m_lastCallbackFallThrough;
100 }; 109 };
101 110
102 class {{config.lib.export_macro}} UberDispatcher { 111 class {{config.lib.export_macro}} UberDispatcher {
103 PROTOCOL_DISALLOW_COPY(UberDispatcher); 112 PROTOCOL_DISALLOW_COPY(UberDispatcher);
104 public: 113 public:
105 explicit UberDispatcher(FrontendChannel*); 114 explicit UberDispatcher(FrontendChannel*);
106 void registerBackend(const String& name, std::unique_ptr<protocol::Dispatche rBase>); 115 void registerBackend(const String& name, std::unique_ptr<protocol::Dispatche rBase>);
107 DispatchResponse::Status dispatch(std::unique_ptr<Value> message); 116 DispatchResponse::Status dispatch(std::unique_ptr<Value> message);
108 FrontendChannel* channel() { return m_frontendChannel; } 117 FrontendChannel* channel() { return m_frontendChannel; }
118 bool fallThroughForNotFound() { return m_fallThroughForNotFound; }
119 void setFallThroughForNotFound(bool);
109 virtual ~UberDispatcher(); 120 virtual ~UberDispatcher();
110 121
111 private: 122 private:
112 FrontendChannel* m_frontendChannel; 123 FrontendChannel* m_frontendChannel;
124 bool m_fallThroughForNotFound;
113 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa tchers; 125 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa tchers;
114 }; 126 };
115 127
116 {% for namespace in config.protocol.namespace %} 128 {% for namespace in config.protocol.namespace %}
117 } // namespace {{namespace}} 129 } // namespace {{namespace}}
118 {% endfor %} 130 {% endfor %}
119 131
120 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h) 132 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698