GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/Release/obj/gen/src/node/inspector/protocol/NodeWorker.h Lines: 95 100 95.0 %
Date: 2019-08-17 22:35:23 Branches: 5 10 50.0 %

Line Branch Exec Source
1
// This file is generated by TypeBuilder_h.template.
2
3
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
4
// Use of this source code is governed by a BSD-style license that can be
5
// found in the LICENSE file.
6
7
#ifndef node_inspector_protocol_NodeWorker_h
8
#define node_inspector_protocol_NodeWorker_h
9
10
#include "src/node/inspector/protocol/Protocol.h"
11
// For each imported domain we generate a ValueConversions struct instead of a full domain definition
12
// and include Domain::API version from there.
13
14
namespace node {
15
namespace inspector {
16
namespace protocol {
17
namespace NodeWorker {
18
19
// ------------- Forward and enum declarations.
20
using WorkerID = String;
21
using SessionID = String;
22
class WorkerInfo;
23
class AttachedToWorkerNotification;
24
class DetachedFromWorkerNotification;
25
class ReceivedMessageFromWorkerNotification;
26
27
// ------------- Type and builder declarations.
28
29
class  WorkerInfo : public Serializable{
30
    PROTOCOL_DISALLOW_COPY(WorkerInfo);
31
public:
32
    static std::unique_ptr<WorkerInfo> fromValue(protocol::Value* value, ErrorSupport* errors);
33
34
20
    ~WorkerInfo() override { }
35
36
    String getWorkerId() { return m_workerId; }
37
10
    void setWorkerId(const String& value) { m_workerId = value; }
38
39
    String getType() { return m_type; }
40
10
    void setType(const String& value) { m_type = value; }
41
42
    String getTitle() { return m_title; }
43
10
    void setTitle(const String& value) { m_title = value; }
44
45
    String getUrl() { return m_url; }
46
10
    void setUrl(const String& value) { m_url = value; }
47
48
    std::unique_ptr<protocol::DictionaryValue> toValue() const;
49
    String serializeToJSON() override { return toValue()->serializeToJSON(); }
50
    std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
51
    String toJSON() const { return toValue()->toJSONString(); }
52
    std::unique_ptr<WorkerInfo> clone() const;
53
54
    template<int STATE>
55
10
    class WorkerInfoBuilder {
56
    public:
57
        enum {
58
            NoFieldsSet = 0,
59
            WorkerIdSet = 1 << 1,
60
            TypeSet = 1 << 2,
61
            TitleSet = 1 << 3,
62
            UrlSet = 1 << 4,
63
            AllFieldsSet = (WorkerIdSet | TypeSet | TitleSet | UrlSet | 0)};
64
65
66
10
        WorkerInfoBuilder<STATE | WorkerIdSet>& setWorkerId(const String& value)
67
        {
68
            static_assert(!(STATE & WorkerIdSet), "property workerId should not be set yet");
69
10
            m_result->setWorkerId(value);
70
10
            return castState<WorkerIdSet>();
71
        }
72
73
10
        WorkerInfoBuilder<STATE | TypeSet>& setType(const String& value)
74
        {
75
            static_assert(!(STATE & TypeSet), "property type should not be set yet");
76
10
            m_result->setType(value);
77
10
            return castState<TypeSet>();
78
        }
79
80
10
        WorkerInfoBuilder<STATE | TitleSet>& setTitle(const String& value)
81
        {
82
            static_assert(!(STATE & TitleSet), "property title should not be set yet");
83
10
            m_result->setTitle(value);
84
10
            return castState<TitleSet>();
85
        }
86
87
10
        WorkerInfoBuilder<STATE | UrlSet>& setUrl(const String& value)
88
        {
89
            static_assert(!(STATE & UrlSet), "property url should not be set yet");
90
10
            m_result->setUrl(value);
91
10
            return castState<UrlSet>();
92
        }
93
94
10
        std::unique_ptr<WorkerInfo> build()
95
        {
96
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
97
10
            return std::move(m_result);
98
        }
99
100
    private:
101
        friend class WorkerInfo;
102
10
        WorkerInfoBuilder() : m_result(new WorkerInfo()) { }
103
104
40
        template<int STEP> WorkerInfoBuilder<STATE | STEP>& castState()
105
        {
106
40
            return *reinterpret_cast<WorkerInfoBuilder<STATE | STEP>*>(this);
107
        }
108
109
        std::unique_ptr<protocol::NodeWorker::WorkerInfo> m_result;
110
    };
111
112
10
    static WorkerInfoBuilder<0> create()
113
    {
114
10
        return WorkerInfoBuilder<0>();
115
    }
116
117
private:
118
10
    WorkerInfo()
119
10
    {
120
10
    }
121
122
    String m_workerId;
123
    String m_type;
124
    String m_title;
125
    String m_url;
126
};
127
128
129
class  AttachedToWorkerNotification : public Serializable{
130
    PROTOCOL_DISALLOW_COPY(AttachedToWorkerNotification);
131
public:
132
    static std::unique_ptr<AttachedToWorkerNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
133
134
20
    ~AttachedToWorkerNotification() override { }
135
136
    String getSessionId() { return m_sessionId; }
137
10
    void setSessionId(const String& value) { m_sessionId = value; }
138
139
    protocol::NodeWorker::WorkerInfo* getWorkerInfo() { return m_workerInfo.get(); }
140
10
    void setWorkerInfo(std::unique_ptr<protocol::NodeWorker::WorkerInfo> value) { m_workerInfo = std::move(value); }
141
142
    bool getWaitingForDebugger() { return m_waitingForDebugger; }
143
10
    void setWaitingForDebugger(bool value) { m_waitingForDebugger = value; }
144
145
    std::unique_ptr<protocol::DictionaryValue> toValue() const;
146
10
    String serializeToJSON() override { return toValue()->serializeToJSON(); }
147
    std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
148
    String toJSON() const { return toValue()->toJSONString(); }
149
    std::unique_ptr<AttachedToWorkerNotification> clone() const;
150
151
    template<int STATE>
152
10
    class AttachedToWorkerNotificationBuilder {
153
    public:
154
        enum {
155
            NoFieldsSet = 0,
156
            SessionIdSet = 1 << 1,
157
            WorkerInfoSet = 1 << 2,
158
            WaitingForDebuggerSet = 1 << 3,
159
            AllFieldsSet = (SessionIdSet | WorkerInfoSet | WaitingForDebuggerSet | 0)};
160
161
162
10
        AttachedToWorkerNotificationBuilder<STATE | SessionIdSet>& setSessionId(const String& value)
163
        {
164
            static_assert(!(STATE & SessionIdSet), "property sessionId should not be set yet");
165
10
            m_result->setSessionId(value);
166
10
            return castState<SessionIdSet>();
167
        }
168
169
10
        AttachedToWorkerNotificationBuilder<STATE | WorkerInfoSet>& setWorkerInfo(std::unique_ptr<protocol::NodeWorker::WorkerInfo> value)
170
        {
171
            static_assert(!(STATE & WorkerInfoSet), "property workerInfo should not be set yet");
172
10
            m_result->setWorkerInfo(std::move(value));
173
10
            return castState<WorkerInfoSet>();
174
        }
175
176
10
        AttachedToWorkerNotificationBuilder<STATE | WaitingForDebuggerSet>& setWaitingForDebugger(bool value)
177
        {
178
            static_assert(!(STATE & WaitingForDebuggerSet), "property waitingForDebugger should not be set yet");
179
10
            m_result->setWaitingForDebugger(value);
180
10
            return castState<WaitingForDebuggerSet>();
181
        }
182
183
10
        std::unique_ptr<AttachedToWorkerNotification> build()
184
        {
185
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
186
10
            return std::move(m_result);
187
        }
188
189
    private:
190
        friend class AttachedToWorkerNotification;
191
10
        AttachedToWorkerNotificationBuilder() : m_result(new AttachedToWorkerNotification()) { }
192
193
30
        template<int STEP> AttachedToWorkerNotificationBuilder<STATE | STEP>& castState()
194
        {
195
30
            return *reinterpret_cast<AttachedToWorkerNotificationBuilder<STATE | STEP>*>(this);
196
        }
197
198
        std::unique_ptr<protocol::NodeWorker::AttachedToWorkerNotification> m_result;
199
    };
200
201
10
    static AttachedToWorkerNotificationBuilder<0> create()
202
    {
203
10
        return AttachedToWorkerNotificationBuilder<0>();
204
    }
205
206
private:
207
10
    AttachedToWorkerNotification()
208
10
    {
209
10
          m_waitingForDebugger = false;
210
10
    }
211
212
    String m_sessionId;
213
    std::unique_ptr<protocol::NodeWorker::WorkerInfo> m_workerInfo;
214
    bool m_waitingForDebugger;
215
};
216
217
218
class  DetachedFromWorkerNotification : public Serializable{
219
    PROTOCOL_DISALLOW_COPY(DetachedFromWorkerNotification);
220
public:
221
    static std::unique_ptr<DetachedFromWorkerNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
222
223
20
    ~DetachedFromWorkerNotification() override { }
224
225
    String getSessionId() { return m_sessionId; }
226
10
    void setSessionId(const String& value) { m_sessionId = value; }
227
228
    std::unique_ptr<protocol::DictionaryValue> toValue() const;
229
10
    String serializeToJSON() override { return toValue()->serializeToJSON(); }
230
    std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
231
    String toJSON() const { return toValue()->toJSONString(); }
232
    std::unique_ptr<DetachedFromWorkerNotification> clone() const;
233
234
    template<int STATE>
235
10
    class DetachedFromWorkerNotificationBuilder {
236
    public:
237
        enum {
238
            NoFieldsSet = 0,
239
            SessionIdSet = 1 << 1,
240
            AllFieldsSet = (SessionIdSet | 0)};
241
242
243
10
        DetachedFromWorkerNotificationBuilder<STATE | SessionIdSet>& setSessionId(const String& value)
244
        {
245
            static_assert(!(STATE & SessionIdSet), "property sessionId should not be set yet");
246
10
            m_result->setSessionId(value);
247
10
            return castState<SessionIdSet>();
248
        }
249
250
10
        std::unique_ptr<DetachedFromWorkerNotification> build()
251
        {
252
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
253
10
            return std::move(m_result);
254
        }
255
256
    private:
257
        friend class DetachedFromWorkerNotification;
258
10
        DetachedFromWorkerNotificationBuilder() : m_result(new DetachedFromWorkerNotification()) { }
259
260
10
        template<int STEP> DetachedFromWorkerNotificationBuilder<STATE | STEP>& castState()
261
        {
262
10
            return *reinterpret_cast<DetachedFromWorkerNotificationBuilder<STATE | STEP>*>(this);
263
        }
264
265
        std::unique_ptr<protocol::NodeWorker::DetachedFromWorkerNotification> m_result;
266
    };
267
268
10
    static DetachedFromWorkerNotificationBuilder<0> create()
269
    {
270
10
        return DetachedFromWorkerNotificationBuilder<0>();
271
    }
272
273
private:
274
10
    DetachedFromWorkerNotification()
275
10
    {
276
10
    }
277
278
    String m_sessionId;
279
};
280
281
282
class  ReceivedMessageFromWorkerNotification : public Serializable{
283
    PROTOCOL_DISALLOW_COPY(ReceivedMessageFromWorkerNotification);
284
public:
285
    static std::unique_ptr<ReceivedMessageFromWorkerNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
286
287
328
    ~ReceivedMessageFromWorkerNotification() override { }
288
289
    String getSessionId() { return m_sessionId; }
290
164
    void setSessionId(const String& value) { m_sessionId = value; }
291
292
    String getMessage() { return m_message; }
293
164
    void setMessage(const String& value) { m_message = value; }
294
295
    std::unique_ptr<protocol::DictionaryValue> toValue() const;
296
164
    String serializeToJSON() override { return toValue()->serializeToJSON(); }
297
    std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
298
    String toJSON() const { return toValue()->toJSONString(); }
299
    std::unique_ptr<ReceivedMessageFromWorkerNotification> clone() const;
300
301
    template<int STATE>
302
164
    class ReceivedMessageFromWorkerNotificationBuilder {
303
    public:
304
        enum {
305
            NoFieldsSet = 0,
306
            SessionIdSet = 1 << 1,
307
            MessageSet = 1 << 2,
308
            AllFieldsSet = (SessionIdSet | MessageSet | 0)};
309
310
311
164
        ReceivedMessageFromWorkerNotificationBuilder<STATE | SessionIdSet>& setSessionId(const String& value)
312
        {
313
            static_assert(!(STATE & SessionIdSet), "property sessionId should not be set yet");
314
164
            m_result->setSessionId(value);
315
164
            return castState<SessionIdSet>();
316
        }
317
318
164
        ReceivedMessageFromWorkerNotificationBuilder<STATE | MessageSet>& setMessage(const String& value)
319
        {
320
            static_assert(!(STATE & MessageSet), "property message should not be set yet");
321
164
            m_result->setMessage(value);
322
164
            return castState<MessageSet>();
323
        }
324
325
164
        std::unique_ptr<ReceivedMessageFromWorkerNotification> build()
326
        {
327
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
328
164
            return std::move(m_result);
329
        }
330
331
    private:
332
        friend class ReceivedMessageFromWorkerNotification;
333
164
        ReceivedMessageFromWorkerNotificationBuilder() : m_result(new ReceivedMessageFromWorkerNotification()) { }
334
335
328
        template<int STEP> ReceivedMessageFromWorkerNotificationBuilder<STATE | STEP>& castState()
336
        {
337
328
            return *reinterpret_cast<ReceivedMessageFromWorkerNotificationBuilder<STATE | STEP>*>(this);
338
        }
339
340
        std::unique_ptr<protocol::NodeWorker::ReceivedMessageFromWorkerNotification> m_result;
341
    };
342
343
164
    static ReceivedMessageFromWorkerNotificationBuilder<0> create()
344
    {
345
164
        return ReceivedMessageFromWorkerNotificationBuilder<0>();
346
    }
347
348
private:
349
164
    ReceivedMessageFromWorkerNotification()
350
164
    {
351
164
    }
352
353
    String m_sessionId;
354
    String m_message;
355
};
356
357
358
// ------------- Backend interface.
359
360
5192
class  Backend {
361
public:
362
4788
    virtual ~Backend() { }
363
364
    virtual DispatchResponse sendMessageToWorker(const String& in_message, const String& in_sessionId) = 0;
365
    virtual DispatchResponse enable(bool in_waitForDebuggerOnStart) = 0;
366
    virtual DispatchResponse disable() = 0;
367
    virtual DispatchResponse detach(const String& in_sessionId) = 0;
368
369
};
370
371
// ------------- Frontend interface.
372
373
class  Frontend {
374
public:
375
5192
    explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
376
    void attachedToWorker(const String& sessionId, std::unique_ptr<protocol::NodeWorker::WorkerInfo> workerInfo, bool waitingForDebugger);
377
    void detachedFromWorker(const String& sessionId);
378
    void receivedMessageFromWorker(const String& sessionId, const String& message);
379
380
    void flush();
381
    void sendRawJSONNotification(String);
382
    void sendRawCBORNotification(std::vector<uint8_t>);
383
private:
384
    FrontendChannel* m_frontendChannel;
385
};
386
387
// ------------- Dispatcher.
388
389
class  Dispatcher {
390
public:
391
    static void wire(UberDispatcher*, Backend*);
392
393
private:
394
    Dispatcher() { }
395
};
396
397
// ------------- Metainfo.
398
399
class  Metainfo {
400
public:
401
    using BackendClass = Backend;
402
    using FrontendClass = Frontend;
403
    using DispatcherClass = Dispatcher;
404
    static const char domainName[];
405
    static const char commandPrefix[];
406
    static const char version[];
407
};
408
409
} // namespace NodeWorker
410
} // namespace node
411
} // namespace inspector
412
} // namespace protocol
413
414
#endif // !defined(node_inspector_protocol_NodeWorker_h)