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

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: works 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ~WeakPtr(); 60 ~WeakPtr();
61 DispatcherBase* get() { return m_dispatcher; } 61 DispatcherBase* get() { return m_dispatcher; }
62 void dispose() { m_dispatcher = nullptr; } 62 void dispose() { m_dispatcher = nullptr; }
63 63
64 private: 64 private:
65 DispatcherBase* m_dispatcher; 65 DispatcherBase* m_dispatcher;
66 }; 66 };
67 67
68 class {{config.lib.export_macro}} Callback { 68 class {{config.lib.export_macro}} Callback {
69 public: 69 public:
70 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId); 70 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId, int callbackI d);
71 virtual ~Callback(); 71 virtual ~Callback();
72 void dispose(); 72 void dispose();
73 73
74 protected: 74 protected:
75 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess age, const DispatchResponse& response); 75 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess age, const DispatchResponse& response);
76 void fallThroughIfActive();
76 77
77 private: 78 private:
78 std::unique_ptr<WeakPtr> m_backendImpl; 79 std::unique_ptr<WeakPtr> m_backendImpl;
79 int m_callId; 80 int m_callId;
81 int m_callbackId;
80 }; 82 };
81 83
82 explicit DispatcherBase(FrontendChannel*); 84 explicit DispatcherBase(FrontendChannel*);
83 virtual ~DispatcherBase(); 85 virtual ~DispatcherBase();
84 86
85 static bool getCommandName(const String& message, String* result); 87 static bool getCommandName(const String& message, String* result);
86 88
87 virtual DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) = 0; 89 virtual DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) = 0;
88 90
89 void sendResponse(int callId, const DispatchResponse&, std::unique_ptr<proto col::DictionaryValue> result); 91 void sendResponse(int callId, const DispatchResponse&, std::unique_ptr<proto col::DictionaryValue> result);
90 void sendResponse(int callId, const DispatchResponse&); 92 void sendResponse(int callId, const DispatchResponse&);
91 93
92 void reportProtocolError(int callId, DispatchResponse::ErrorCode, const Stri ng& errorMessage, ErrorSupport* errors); 94 void reportProtocolError(int callId, DispatchResponse::ErrorCode, const Stri ng& errorMessage, ErrorSupport* errors);
93 void clearFrontend(); 95 void clearFrontend();
94 96
95 std::unique_ptr<WeakPtr> weakPtr(); 97 std::unique_ptr<WeakPtr> weakPtr();
96 98
99 int nextCallbackId();
100 void markFallThrough(int callbackId);
101 bool lastCallbackFallThrough() { return m_lastCallbackFallThrough; }
102
97 private: 103 private:
98 FrontendChannel* m_frontendChannel; 104 FrontendChannel* m_frontendChannel;
99 protocol::HashSet<WeakPtr*> m_weakPtrs; 105 protocol::HashSet<WeakPtr*> m_weakPtrs;
106 int m_lastCallbackId;
107 bool m_lastCallbackFallThrough;
100 }; 108 };
101 109
102 class {{config.lib.export_macro}} UberDispatcher { 110 class {{config.lib.export_macro}} UberDispatcher {
103 PROTOCOL_DISALLOW_COPY(UberDispatcher); 111 PROTOCOL_DISALLOW_COPY(UberDispatcher);
104 public: 112 public:
105 explicit UberDispatcher(FrontendChannel*); 113 explicit UberDispatcher(FrontendChannel*);
114 UberDispatcher(FrontendChannel*, bool fallThroughForNotFound);
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; }
109 virtual ~UberDispatcher(); 119 virtual ~UberDispatcher();
110 120
111 private: 121 private:
112 FrontendChannel* m_frontendChannel; 122 FrontendChannel* m_frontendChannel;
123 bool m_fallThroughForNotFound;
113 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa tchers; 124 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa tchers;
114 }; 125 };
115 126
116 {% for namespace in config.protocol.namespace %} 127 {% for namespace in config.protocol.namespace %}
117 } // namespace {{namespace}} 128 } // namespace {{namespace}}
118 {% endfor %} 129 {% endfor %}
119 130
120 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h) 131 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698