Line data Source code
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 v8_inspector_protocol_Profiler_h
8 : #define v8_inspector_protocol_Profiler_h
9 :
10 : #include "src/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 : #include "src/inspector/protocol/Runtime.h"
14 : #include "src/inspector/protocol/Debugger.h"
15 :
16 : namespace v8_inspector {
17 : namespace protocol {
18 : namespace Profiler {
19 :
20 : // ------------- Forward and enum declarations.
21 : class ProfileNode;
22 : class Profile;
23 : class PositionTickInfo;
24 : class CoverageRange;
25 : class FunctionCoverage;
26 : class ScriptCoverage;
27 : class TypeObject;
28 : class TypeProfileEntry;
29 : class ScriptTypeProfile;
30 : class ConsoleProfileFinishedNotification;
31 : class ConsoleProfileStartedNotification;
32 :
33 : // ------------- Type and builder declarations.
34 :
35 : class ProfileNode : public Serializable{
36 : PROTOCOL_DISALLOW_COPY(ProfileNode);
37 : public:
38 : static std::unique_ptr<ProfileNode> fromValue(protocol::Value* value, ErrorSupport* errors);
39 :
40 1176 : ~ProfileNode() override { }
41 :
42 : int getId() { return m_id; }
43 392 : void setId(int value) { m_id = value; }
44 :
45 : protocol::Runtime::CallFrame* getCallFrame() { return m_callFrame.get(); }
46 : void setCallFrame(std::unique_ptr<protocol::Runtime::CallFrame> value) { m_callFrame = std::move(value); }
47 :
48 : bool hasHitCount() { return m_hitCount.isJust(); }
49 : int getHitCount(int defaultValue) { return m_hitCount.isJust() ? m_hitCount.fromJust() : defaultValue; }
50 : void setHitCount(int value) { m_hitCount = value; }
51 :
52 : bool hasChildren() { return m_children.isJust(); }
53 : protocol::Array<int>* getChildren(protocol::Array<int>* defaultValue) { return m_children.isJust() ? m_children.fromJust() : defaultValue; }
54 : void setChildren(std::unique_ptr<protocol::Array<int>> value) { m_children = std::move(value); }
55 :
56 : bool hasDeoptReason() { return m_deoptReason.isJust(); }
57 : String getDeoptReason(const String& defaultValue) { return m_deoptReason.isJust() ? m_deoptReason.fromJust() : defaultValue; }
58 0 : void setDeoptReason(const String& value) { m_deoptReason = value; }
59 :
60 : bool hasPositionTicks() { return m_positionTicks.isJust(); }
61 : protocol::Array<protocol::Profiler::PositionTickInfo>* getPositionTicks(protocol::Array<protocol::Profiler::PositionTickInfo>* defaultValue) { return m_positionTicks.isJust() ? m_positionTicks.fromJust() : defaultValue; }
62 38 : void setPositionTicks(std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> value) { m_positionTicks = std::move(value); }
63 :
64 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
65 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
66 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
67 : String toJSON() const { return toValue()->toJSONString(); }
68 : std::unique_ptr<ProfileNode> clone() const;
69 :
70 : template<int STATE>
71 392 : class ProfileNodeBuilder {
72 : public:
73 : enum {
74 : NoFieldsSet = 0,
75 : IdSet = 1 << 1,
76 : CallFrameSet = 1 << 2,
77 : AllFieldsSet = (IdSet | CallFrameSet | 0)};
78 :
79 :
80 : ProfileNodeBuilder<STATE | IdSet>& setId(int value)
81 : {
82 : static_assert(!(STATE & IdSet), "property id should not be set yet");
83 : m_result->setId(value);
84 : return castState<IdSet>();
85 : }
86 :
87 : ProfileNodeBuilder<STATE | CallFrameSet>& setCallFrame(std::unique_ptr<protocol::Runtime::CallFrame> value)
88 : {
89 : static_assert(!(STATE & CallFrameSet), "property callFrame should not be set yet");
90 : m_result->setCallFrame(std::move(value));
91 : return castState<CallFrameSet>();
92 : }
93 :
94 : ProfileNodeBuilder<STATE>& setHitCount(int value)
95 : {
96 : m_result->setHitCount(value);
97 : return *this;
98 : }
99 :
100 : ProfileNodeBuilder<STATE>& setChildren(std::unique_ptr<protocol::Array<int>> value)
101 : {
102 : m_result->setChildren(std::move(value));
103 : return *this;
104 : }
105 :
106 : ProfileNodeBuilder<STATE>& setDeoptReason(const String& value)
107 : {
108 : m_result->setDeoptReason(value);
109 : return *this;
110 : }
111 :
112 : ProfileNodeBuilder<STATE>& setPositionTicks(std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> value)
113 : {
114 : m_result->setPositionTicks(std::move(value));
115 : return *this;
116 : }
117 :
118 : std::unique_ptr<ProfileNode> build()
119 : {
120 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
121 : return std::move(m_result);
122 : }
123 :
124 : private:
125 : friend class ProfileNode;
126 784 : ProfileNodeBuilder() : m_result(new ProfileNode()) { }
127 :
128 : template<int STEP> ProfileNodeBuilder<STATE | STEP>& castState()
129 : {
130 : return *reinterpret_cast<ProfileNodeBuilder<STATE | STEP>*>(this);
131 : }
132 :
133 : std::unique_ptr<protocol::Profiler::ProfileNode> m_result;
134 : };
135 :
136 : static ProfileNodeBuilder<0> create()
137 : {
138 392 : return ProfileNodeBuilder<0>();
139 : }
140 :
141 : private:
142 : ProfileNode()
143 392 : {
144 392 : m_id = 0;
145 : }
146 :
147 : int m_id;
148 : std::unique_ptr<protocol::Runtime::CallFrame> m_callFrame;
149 : Maybe<int> m_hitCount;
150 : Maybe<protocol::Array<int>> m_children;
151 : Maybe<String> m_deoptReason;
152 : Maybe<protocol::Array<protocol::Profiler::PositionTickInfo>> m_positionTicks;
153 : };
154 :
155 :
156 : class Profile : public Serializable{
157 : PROTOCOL_DISALLOW_COPY(Profile);
158 : public:
159 : static std::unique_ptr<Profile> fromValue(protocol::Value* value, ErrorSupport* errors);
160 :
161 560 : ~Profile() override { }
162 :
163 : protocol::Array<protocol::Profiler::ProfileNode>* getNodes() { return m_nodes.get(); }
164 140 : void setNodes(std::unique_ptr<protocol::Array<protocol::Profiler::ProfileNode>> value) { m_nodes = std::move(value); }
165 :
166 : double getStartTime() { return m_startTime; }
167 140 : void setStartTime(double value) { m_startTime = value; }
168 :
169 : double getEndTime() { return m_endTime; }
170 140 : void setEndTime(double value) { m_endTime = value; }
171 :
172 : bool hasSamples() { return m_samples.isJust(); }
173 : protocol::Array<int>* getSamples(protocol::Array<int>* defaultValue) { return m_samples.isJust() ? m_samples.fromJust() : defaultValue; }
174 : void setSamples(std::unique_ptr<protocol::Array<int>> value) { m_samples = std::move(value); }
175 :
176 : bool hasTimeDeltas() { return m_timeDeltas.isJust(); }
177 : protocol::Array<int>* getTimeDeltas(protocol::Array<int>* defaultValue) { return m_timeDeltas.isJust() ? m_timeDeltas.fromJust() : defaultValue; }
178 : void setTimeDeltas(std::unique_ptr<protocol::Array<int>> value) { m_timeDeltas = std::move(value); }
179 :
180 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
181 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
182 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
183 : String toJSON() const { return toValue()->toJSONString(); }
184 : std::unique_ptr<Profile> clone() const;
185 :
186 : template<int STATE>
187 140 : class ProfileBuilder {
188 : public:
189 : enum {
190 : NoFieldsSet = 0,
191 : NodesSet = 1 << 1,
192 : StartTimeSet = 1 << 2,
193 : EndTimeSet = 1 << 3,
194 : AllFieldsSet = (NodesSet | StartTimeSet | EndTimeSet | 0)};
195 :
196 :
197 140 : ProfileBuilder<STATE | NodesSet>& setNodes(std::unique_ptr<protocol::Array<protocol::Profiler::ProfileNode>> value)
198 : {
199 : static_assert(!(STATE & NodesSet), "property nodes should not be set yet");
200 140 : m_result->setNodes(std::move(value));
201 140 : return castState<NodesSet>();
202 : }
203 :
204 : ProfileBuilder<STATE | StartTimeSet>& setStartTime(double value)
205 : {
206 : static_assert(!(STATE & StartTimeSet), "property startTime should not be set yet");
207 : m_result->setStartTime(value);
208 : return castState<StartTimeSet>();
209 : }
210 :
211 : ProfileBuilder<STATE | EndTimeSet>& setEndTime(double value)
212 : {
213 : static_assert(!(STATE & EndTimeSet), "property endTime should not be set yet");
214 : m_result->setEndTime(value);
215 : return castState<EndTimeSet>();
216 : }
217 :
218 : ProfileBuilder<STATE>& setSamples(std::unique_ptr<protocol::Array<int>> value)
219 : {
220 : m_result->setSamples(std::move(value));
221 : return *this;
222 : }
223 :
224 : ProfileBuilder<STATE>& setTimeDeltas(std::unique_ptr<protocol::Array<int>> value)
225 : {
226 : m_result->setTimeDeltas(std::move(value));
227 : return *this;
228 : }
229 :
230 : std::unique_ptr<Profile> build()
231 : {
232 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
233 : return std::move(m_result);
234 : }
235 :
236 : private:
237 : friend class Profile;
238 280 : ProfileBuilder() : m_result(new Profile()) { }
239 :
240 : template<int STEP> ProfileBuilder<STATE | STEP>& castState()
241 : {
242 : return *reinterpret_cast<ProfileBuilder<STATE | STEP>*>(this);
243 : }
244 :
245 : std::unique_ptr<protocol::Profiler::Profile> m_result;
246 : };
247 :
248 : static ProfileBuilder<0> create()
249 : {
250 140 : return ProfileBuilder<0>();
251 : }
252 :
253 : private:
254 : Profile()
255 140 : {
256 140 : m_startTime = 0;
257 140 : m_endTime = 0;
258 : }
259 :
260 : std::unique_ptr<protocol::Array<protocol::Profiler::ProfileNode>> m_nodes;
261 : double m_startTime;
262 : double m_endTime;
263 : Maybe<protocol::Array<int>> m_samples;
264 : Maybe<protocol::Array<int>> m_timeDeltas;
265 : };
266 :
267 :
268 : class PositionTickInfo : public Serializable{
269 : PROTOCOL_DISALLOW_COPY(PositionTickInfo);
270 : public:
271 : static std::unique_ptr<PositionTickInfo> fromValue(protocol::Value* value, ErrorSupport* errors);
272 :
273 38 : ~PositionTickInfo() override { }
274 :
275 : int getLine() { return m_line; }
276 19 : void setLine(int value) { m_line = value; }
277 :
278 : int getTicks() { return m_ticks; }
279 19 : void setTicks(int value) { m_ticks = value; }
280 :
281 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
282 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
283 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
284 : String toJSON() const { return toValue()->toJSONString(); }
285 : std::unique_ptr<PositionTickInfo> clone() const;
286 :
287 : template<int STATE>
288 : class PositionTickInfoBuilder {
289 : public:
290 : enum {
291 : NoFieldsSet = 0,
292 : LineSet = 1 << 1,
293 : TicksSet = 1 << 2,
294 : AllFieldsSet = (LineSet | TicksSet | 0)};
295 :
296 :
297 : PositionTickInfoBuilder<STATE | LineSet>& setLine(int value)
298 : {
299 : static_assert(!(STATE & LineSet), "property line should not be set yet");
300 : m_result->setLine(value);
301 : return castState<LineSet>();
302 : }
303 :
304 : PositionTickInfoBuilder<STATE | TicksSet>& setTicks(int value)
305 : {
306 : static_assert(!(STATE & TicksSet), "property ticks should not be set yet");
307 : m_result->setTicks(value);
308 : return castState<TicksSet>();
309 : }
310 :
311 : std::unique_ptr<PositionTickInfo> build()
312 : {
313 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
314 : return std::move(m_result);
315 : }
316 :
317 : private:
318 : friend class PositionTickInfo;
319 19 : PositionTickInfoBuilder() : m_result(new PositionTickInfo()) { }
320 :
321 : template<int STEP> PositionTickInfoBuilder<STATE | STEP>& castState()
322 : {
323 : return *reinterpret_cast<PositionTickInfoBuilder<STATE | STEP>*>(this);
324 : }
325 :
326 : std::unique_ptr<protocol::Profiler::PositionTickInfo> m_result;
327 : };
328 :
329 : static PositionTickInfoBuilder<0> create()
330 : {
331 : return PositionTickInfoBuilder<0>();
332 : }
333 :
334 : private:
335 : PositionTickInfo()
336 19 : {
337 19 : m_line = 0;
338 19 : m_ticks = 0;
339 : }
340 :
341 : int m_line;
342 : int m_ticks;
343 : };
344 :
345 :
346 : class CoverageRange : public Serializable{
347 : PROTOCOL_DISALLOW_COPY(CoverageRange);
348 : public:
349 : static std::unique_ptr<CoverageRange> fromValue(protocol::Value* value, ErrorSupport* errors);
350 :
351 824 : ~CoverageRange() override { }
352 :
353 : int getStartOffset() { return m_startOffset; }
354 412 : void setStartOffset(int value) { m_startOffset = value; }
355 :
356 : int getEndOffset() { return m_endOffset; }
357 412 : void setEndOffset(int value) { m_endOffset = value; }
358 :
359 : int getCount() { return m_count; }
360 412 : void setCount(int value) { m_count = value; }
361 :
362 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
363 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
364 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
365 : String toJSON() const { return toValue()->toJSONString(); }
366 : std::unique_ptr<CoverageRange> clone() const;
367 :
368 : template<int STATE>
369 : class CoverageRangeBuilder {
370 : public:
371 : enum {
372 : NoFieldsSet = 0,
373 : StartOffsetSet = 1 << 1,
374 : EndOffsetSet = 1 << 2,
375 : CountSet = 1 << 3,
376 : AllFieldsSet = (StartOffsetSet | EndOffsetSet | CountSet | 0)};
377 :
378 :
379 : CoverageRangeBuilder<STATE | StartOffsetSet>& setStartOffset(int value)
380 : {
381 : static_assert(!(STATE & StartOffsetSet), "property startOffset should not be set yet");
382 : m_result->setStartOffset(value);
383 : return castState<StartOffsetSet>();
384 : }
385 :
386 : CoverageRangeBuilder<STATE | EndOffsetSet>& setEndOffset(int value)
387 : {
388 : static_assert(!(STATE & EndOffsetSet), "property endOffset should not be set yet");
389 : m_result->setEndOffset(value);
390 : return castState<EndOffsetSet>();
391 : }
392 :
393 : CoverageRangeBuilder<STATE | CountSet>& setCount(int value)
394 : {
395 : static_assert(!(STATE & CountSet), "property count should not be set yet");
396 : m_result->setCount(value);
397 : return castState<CountSet>();
398 : }
399 :
400 : std::unique_ptr<CoverageRange> build()
401 : {
402 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
403 : return std::move(m_result);
404 : }
405 :
406 : private:
407 : friend class CoverageRange;
408 412 : CoverageRangeBuilder() : m_result(new CoverageRange()) { }
409 :
410 : template<int STEP> CoverageRangeBuilder<STATE | STEP>& castState()
411 : {
412 : return *reinterpret_cast<CoverageRangeBuilder<STATE | STEP>*>(this);
413 : }
414 :
415 : std::unique_ptr<protocol::Profiler::CoverageRange> m_result;
416 : };
417 :
418 : static CoverageRangeBuilder<0> create()
419 : {
420 : return CoverageRangeBuilder<0>();
421 : }
422 :
423 : private:
424 : CoverageRange()
425 412 : {
426 412 : m_startOffset = 0;
427 412 : m_endOffset = 0;
428 412 : m_count = 0;
429 : }
430 :
431 : int m_startOffset;
432 : int m_endOffset;
433 : int m_count;
434 : };
435 :
436 :
437 : class FunctionCoverage : public Serializable{
438 : PROTOCOL_DISALLOW_COPY(FunctionCoverage);
439 : public:
440 : static std::unique_ptr<FunctionCoverage> fromValue(protocol::Value* value, ErrorSupport* errors);
441 :
442 1140 : ~FunctionCoverage() override { }
443 :
444 : String getFunctionName() { return m_functionName; }
445 : void setFunctionName(const String& value) { m_functionName = value; }
446 :
447 : protocol::Array<protocol::Profiler::CoverageRange>* getRanges() { return m_ranges.get(); }
448 380 : void setRanges(std::unique_ptr<protocol::Array<protocol::Profiler::CoverageRange>> value) { m_ranges = std::move(value); }
449 :
450 : bool getIsBlockCoverage() { return m_isBlockCoverage; }
451 380 : void setIsBlockCoverage(bool value) { m_isBlockCoverage = value; }
452 :
453 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
454 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
455 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
456 : String toJSON() const { return toValue()->toJSONString(); }
457 : std::unique_ptr<FunctionCoverage> clone() const;
458 :
459 : template<int STATE>
460 380 : class FunctionCoverageBuilder {
461 : public:
462 : enum {
463 : NoFieldsSet = 0,
464 : FunctionNameSet = 1 << 1,
465 : RangesSet = 1 << 2,
466 : IsBlockCoverageSet = 1 << 3,
467 : AllFieldsSet = (FunctionNameSet | RangesSet | IsBlockCoverageSet | 0)};
468 :
469 :
470 : FunctionCoverageBuilder<STATE | FunctionNameSet>& setFunctionName(const String& value)
471 : {
472 : static_assert(!(STATE & FunctionNameSet), "property functionName should not be set yet");
473 : m_result->setFunctionName(value);
474 : return castState<FunctionNameSet>();
475 : }
476 :
477 380 : FunctionCoverageBuilder<STATE | RangesSet>& setRanges(std::unique_ptr<protocol::Array<protocol::Profiler::CoverageRange>> value)
478 : {
479 : static_assert(!(STATE & RangesSet), "property ranges should not be set yet");
480 380 : m_result->setRanges(std::move(value));
481 380 : return castState<RangesSet>();
482 : }
483 :
484 : FunctionCoverageBuilder<STATE | IsBlockCoverageSet>& setIsBlockCoverage(bool value)
485 : {
486 : static_assert(!(STATE & IsBlockCoverageSet), "property isBlockCoverage should not be set yet");
487 : m_result->setIsBlockCoverage(value);
488 : return castState<IsBlockCoverageSet>();
489 : }
490 :
491 : std::unique_ptr<FunctionCoverage> build()
492 : {
493 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
494 : return std::move(m_result);
495 : }
496 :
497 : private:
498 : friend class FunctionCoverage;
499 760 : FunctionCoverageBuilder() : m_result(new FunctionCoverage()) { }
500 :
501 : template<int STEP> FunctionCoverageBuilder<STATE | STEP>& castState()
502 : {
503 : return *reinterpret_cast<FunctionCoverageBuilder<STATE | STEP>*>(this);
504 : }
505 :
506 : std::unique_ptr<protocol::Profiler::FunctionCoverage> m_result;
507 : };
508 :
509 : static FunctionCoverageBuilder<0> create()
510 : {
511 380 : return FunctionCoverageBuilder<0>();
512 : }
513 :
514 : private:
515 : FunctionCoverage()
516 380 : {
517 380 : m_isBlockCoverage = false;
518 : }
519 :
520 : String m_functionName;
521 : std::unique_ptr<protocol::Array<protocol::Profiler::CoverageRange>> m_ranges;
522 : bool m_isBlockCoverage;
523 : };
524 :
525 :
526 : class ScriptCoverage : public Serializable{
527 : PROTOCOL_DISALLOW_COPY(ScriptCoverage);
528 : public:
529 : static std::unique_ptr<ScriptCoverage> fromValue(protocol::Value* value, ErrorSupport* errors);
530 :
531 480 : ~ScriptCoverage() override { }
532 :
533 : String getScriptId() { return m_scriptId; }
534 : void setScriptId(const String& value) { m_scriptId = value; }
535 :
536 : String getUrl() { return m_url; }
537 : void setUrl(const String& value) { m_url = value; }
538 :
539 : protocol::Array<protocol::Profiler::FunctionCoverage>* getFunctions() { return m_functions.get(); }
540 160 : void setFunctions(std::unique_ptr<protocol::Array<protocol::Profiler::FunctionCoverage>> value) { m_functions = std::move(value); }
541 :
542 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
543 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
544 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
545 : String toJSON() const { return toValue()->toJSONString(); }
546 : std::unique_ptr<ScriptCoverage> clone() const;
547 :
548 : template<int STATE>
549 160 : class ScriptCoverageBuilder {
550 : public:
551 : enum {
552 : NoFieldsSet = 0,
553 : ScriptIdSet = 1 << 1,
554 : UrlSet = 1 << 2,
555 : FunctionsSet = 1 << 3,
556 : AllFieldsSet = (ScriptIdSet | UrlSet | FunctionsSet | 0)};
557 :
558 :
559 : ScriptCoverageBuilder<STATE | ScriptIdSet>& setScriptId(const String& value)
560 : {
561 : static_assert(!(STATE & ScriptIdSet), "property scriptId should not be set yet");
562 : m_result->setScriptId(value);
563 : return castState<ScriptIdSet>();
564 : }
565 :
566 : ScriptCoverageBuilder<STATE | UrlSet>& setUrl(const String& value)
567 : {
568 : static_assert(!(STATE & UrlSet), "property url should not be set yet");
569 : m_result->setUrl(value);
570 : return castState<UrlSet>();
571 : }
572 :
573 160 : ScriptCoverageBuilder<STATE | FunctionsSet>& setFunctions(std::unique_ptr<protocol::Array<protocol::Profiler::FunctionCoverage>> value)
574 : {
575 : static_assert(!(STATE & FunctionsSet), "property functions should not be set yet");
576 160 : m_result->setFunctions(std::move(value));
577 160 : return castState<FunctionsSet>();
578 : }
579 :
580 : std::unique_ptr<ScriptCoverage> build()
581 : {
582 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
583 : return std::move(m_result);
584 : }
585 :
586 : private:
587 : friend class ScriptCoverage;
588 320 : ScriptCoverageBuilder() : m_result(new ScriptCoverage()) { }
589 :
590 : template<int STEP> ScriptCoverageBuilder<STATE | STEP>& castState()
591 : {
592 : return *reinterpret_cast<ScriptCoverageBuilder<STATE | STEP>*>(this);
593 : }
594 :
595 : std::unique_ptr<protocol::Profiler::ScriptCoverage> m_result;
596 : };
597 :
598 : static ScriptCoverageBuilder<0> create()
599 : {
600 160 : return ScriptCoverageBuilder<0>();
601 : }
602 :
603 : private:
604 : ScriptCoverage()
605 160 : {
606 : }
607 :
608 : String m_scriptId;
609 : String m_url;
610 : std::unique_ptr<protocol::Array<protocol::Profiler::FunctionCoverage>> m_functions;
611 : };
612 :
613 :
614 : class TypeObject : public Serializable{
615 : PROTOCOL_DISALLOW_COPY(TypeObject);
616 : public:
617 : static std::unique_ptr<TypeObject> fromValue(protocol::Value* value, ErrorSupport* errors);
618 :
619 392 : ~TypeObject() override { }
620 :
621 : String getName() { return m_name; }
622 : void setName(const String& value) { m_name = value; }
623 :
624 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
625 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
626 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
627 : String toJSON() const { return toValue()->toJSONString(); }
628 : std::unique_ptr<TypeObject> clone() const;
629 :
630 : template<int STATE>
631 196 : class TypeObjectBuilder {
632 : public:
633 : enum {
634 : NoFieldsSet = 0,
635 : NameSet = 1 << 1,
636 : AllFieldsSet = (NameSet | 0)};
637 :
638 :
639 : TypeObjectBuilder<STATE | NameSet>& setName(const String& value)
640 : {
641 : static_assert(!(STATE & NameSet), "property name should not be set yet");
642 : m_result->setName(value);
643 : return castState<NameSet>();
644 : }
645 :
646 : std::unique_ptr<TypeObject> build()
647 : {
648 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
649 : return std::move(m_result);
650 : }
651 :
652 : private:
653 : friend class TypeObject;
654 392 : TypeObjectBuilder() : m_result(new TypeObject()) { }
655 :
656 : template<int STEP> TypeObjectBuilder<STATE | STEP>& castState()
657 : {
658 : return *reinterpret_cast<TypeObjectBuilder<STATE | STEP>*>(this);
659 : }
660 :
661 : std::unique_ptr<protocol::Profiler::TypeObject> m_result;
662 : };
663 :
664 : static TypeObjectBuilder<0> create()
665 : {
666 196 : return TypeObjectBuilder<0>();
667 : }
668 :
669 : private:
670 : TypeObject()
671 196 : {
672 : }
673 :
674 : String m_name;
675 : };
676 :
677 :
678 : class TypeProfileEntry : public Serializable{
679 : PROTOCOL_DISALLOW_COPY(TypeProfileEntry);
680 : public:
681 : static std::unique_ptr<TypeProfileEntry> fromValue(protocol::Value* value, ErrorSupport* errors);
682 :
683 296 : ~TypeProfileEntry() override { }
684 :
685 : int getOffset() { return m_offset; }
686 148 : void setOffset(int value) { m_offset = value; }
687 :
688 : protocol::Array<protocol::Profiler::TypeObject>* getTypes() { return m_types.get(); }
689 148 : void setTypes(std::unique_ptr<protocol::Array<protocol::Profiler::TypeObject>> value) { m_types = std::move(value); }
690 :
691 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
692 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
693 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
694 : String toJSON() const { return toValue()->toJSONString(); }
695 : std::unique_ptr<TypeProfileEntry> clone() const;
696 :
697 : template<int STATE>
698 148 : class TypeProfileEntryBuilder {
699 : public:
700 : enum {
701 : NoFieldsSet = 0,
702 : OffsetSet = 1 << 1,
703 : TypesSet = 1 << 2,
704 : AllFieldsSet = (OffsetSet | TypesSet | 0)};
705 :
706 :
707 : TypeProfileEntryBuilder<STATE | OffsetSet>& setOffset(int value)
708 : {
709 : static_assert(!(STATE & OffsetSet), "property offset should not be set yet");
710 : m_result->setOffset(value);
711 : return castState<OffsetSet>();
712 : }
713 :
714 148 : TypeProfileEntryBuilder<STATE | TypesSet>& setTypes(std::unique_ptr<protocol::Array<protocol::Profiler::TypeObject>> value)
715 : {
716 : static_assert(!(STATE & TypesSet), "property types should not be set yet");
717 148 : m_result->setTypes(std::move(value));
718 148 : return castState<TypesSet>();
719 : }
720 :
721 : std::unique_ptr<TypeProfileEntry> build()
722 : {
723 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
724 : return std::move(m_result);
725 : }
726 :
727 : private:
728 : friend class TypeProfileEntry;
729 148 : TypeProfileEntryBuilder() : m_result(new TypeProfileEntry()) { }
730 :
731 : template<int STEP> TypeProfileEntryBuilder<STATE | STEP>& castState()
732 : {
733 : return *reinterpret_cast<TypeProfileEntryBuilder<STATE | STEP>*>(this);
734 : }
735 :
736 : std::unique_ptr<protocol::Profiler::TypeProfileEntry> m_result;
737 : };
738 :
739 : static TypeProfileEntryBuilder<0> create()
740 : {
741 : return TypeProfileEntryBuilder<0>();
742 : }
743 :
744 : private:
745 : TypeProfileEntry()
746 148 : {
747 148 : m_offset = 0;
748 : }
749 :
750 : int m_offset;
751 : std::unique_ptr<protocol::Array<protocol::Profiler::TypeObject>> m_types;
752 : };
753 :
754 :
755 : class ScriptTypeProfile : public Serializable{
756 : PROTOCOL_DISALLOW_COPY(ScriptTypeProfile);
757 : public:
758 : static std::unique_ptr<ScriptTypeProfile> fromValue(protocol::Value* value, ErrorSupport* errors);
759 :
760 96 : ~ScriptTypeProfile() override { }
761 :
762 : String getScriptId() { return m_scriptId; }
763 : void setScriptId(const String& value) { m_scriptId = value; }
764 :
765 : String getUrl() { return m_url; }
766 : void setUrl(const String& value) { m_url = value; }
767 :
768 : protocol::Array<protocol::Profiler::TypeProfileEntry>* getEntries() { return m_entries.get(); }
769 32 : void setEntries(std::unique_ptr<protocol::Array<protocol::Profiler::TypeProfileEntry>> value) { m_entries = std::move(value); }
770 :
771 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
772 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
773 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
774 : String toJSON() const { return toValue()->toJSONString(); }
775 : std::unique_ptr<ScriptTypeProfile> clone() const;
776 :
777 : template<int STATE>
778 32 : class ScriptTypeProfileBuilder {
779 : public:
780 : enum {
781 : NoFieldsSet = 0,
782 : ScriptIdSet = 1 << 1,
783 : UrlSet = 1 << 2,
784 : EntriesSet = 1 << 3,
785 : AllFieldsSet = (ScriptIdSet | UrlSet | EntriesSet | 0)};
786 :
787 :
788 : ScriptTypeProfileBuilder<STATE | ScriptIdSet>& setScriptId(const String& value)
789 : {
790 : static_assert(!(STATE & ScriptIdSet), "property scriptId should not be set yet");
791 : m_result->setScriptId(value);
792 : return castState<ScriptIdSet>();
793 : }
794 :
795 : ScriptTypeProfileBuilder<STATE | UrlSet>& setUrl(const String& value)
796 : {
797 : static_assert(!(STATE & UrlSet), "property url should not be set yet");
798 : m_result->setUrl(value);
799 : return castState<UrlSet>();
800 : }
801 :
802 32 : ScriptTypeProfileBuilder<STATE | EntriesSet>& setEntries(std::unique_ptr<protocol::Array<protocol::Profiler::TypeProfileEntry>> value)
803 : {
804 : static_assert(!(STATE & EntriesSet), "property entries should not be set yet");
805 32 : m_result->setEntries(std::move(value));
806 32 : return castState<EntriesSet>();
807 : }
808 :
809 : std::unique_ptr<ScriptTypeProfile> build()
810 : {
811 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
812 : return std::move(m_result);
813 : }
814 :
815 : private:
816 : friend class ScriptTypeProfile;
817 64 : ScriptTypeProfileBuilder() : m_result(new ScriptTypeProfile()) { }
818 :
819 : template<int STEP> ScriptTypeProfileBuilder<STATE | STEP>& castState()
820 : {
821 : return *reinterpret_cast<ScriptTypeProfileBuilder<STATE | STEP>*>(this);
822 : }
823 :
824 : std::unique_ptr<protocol::Profiler::ScriptTypeProfile> m_result;
825 : };
826 :
827 : static ScriptTypeProfileBuilder<0> create()
828 : {
829 32 : return ScriptTypeProfileBuilder<0>();
830 : }
831 :
832 : private:
833 : ScriptTypeProfile()
834 32 : {
835 : }
836 :
837 : String m_scriptId;
838 : String m_url;
839 : std::unique_ptr<protocol::Array<protocol::Profiler::TypeProfileEntry>> m_entries;
840 : };
841 :
842 :
843 : class ConsoleProfileFinishedNotification : public Serializable{
844 : PROTOCOL_DISALLOW_COPY(ConsoleProfileFinishedNotification);
845 : public:
846 : static std::unique_ptr<ConsoleProfileFinishedNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
847 :
848 390 : ~ConsoleProfileFinishedNotification() override { }
849 :
850 : String getId() { return m_id; }
851 : void setId(const String& value) { m_id = value; }
852 :
853 : protocol::Debugger::Location* getLocation() { return m_location.get(); }
854 : void setLocation(std::unique_ptr<protocol::Debugger::Location> value) { m_location = std::move(value); }
855 :
856 : protocol::Profiler::Profile* getProfile() { return m_profile.get(); }
857 : void setProfile(std::unique_ptr<protocol::Profiler::Profile> value) { m_profile = std::move(value); }
858 :
859 : bool hasTitle() { return m_title.isJust(); }
860 : String getTitle(const String& defaultValue) { return m_title.isJust() ? m_title.fromJust() : defaultValue; }
861 260 : void setTitle(const String& value) { m_title = value; }
862 :
863 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
864 390 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
865 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
866 : String toJSON() const { return toValue()->toJSONString(); }
867 : std::unique_ptr<ConsoleProfileFinishedNotification> clone() const;
868 :
869 : template<int STATE>
870 130 : class ConsoleProfileFinishedNotificationBuilder {
871 : public:
872 : enum {
873 : NoFieldsSet = 0,
874 : IdSet = 1 << 1,
875 : LocationSet = 1 << 2,
876 : ProfileSet = 1 << 3,
877 : AllFieldsSet = (IdSet | LocationSet | ProfileSet | 0)};
878 :
879 :
880 : ConsoleProfileFinishedNotificationBuilder<STATE | IdSet>& setId(const String& value)
881 : {
882 : static_assert(!(STATE & IdSet), "property id should not be set yet");
883 : m_result->setId(value);
884 : return castState<IdSet>();
885 : }
886 :
887 : ConsoleProfileFinishedNotificationBuilder<STATE | LocationSet>& setLocation(std::unique_ptr<protocol::Debugger::Location> value)
888 : {
889 : static_assert(!(STATE & LocationSet), "property location should not be set yet");
890 : m_result->setLocation(std::move(value));
891 : return castState<LocationSet>();
892 : }
893 :
894 : ConsoleProfileFinishedNotificationBuilder<STATE | ProfileSet>& setProfile(std::unique_ptr<protocol::Profiler::Profile> value)
895 : {
896 : static_assert(!(STATE & ProfileSet), "property profile should not be set yet");
897 : m_result->setProfile(std::move(value));
898 : return castState<ProfileSet>();
899 : }
900 :
901 : ConsoleProfileFinishedNotificationBuilder<STATE>& setTitle(const String& value)
902 : {
903 : m_result->setTitle(value);
904 : return *this;
905 : }
906 :
907 : std::unique_ptr<ConsoleProfileFinishedNotification> build()
908 : {
909 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
910 : return std::move(m_result);
911 : }
912 :
913 : private:
914 : friend class ConsoleProfileFinishedNotification;
915 260 : ConsoleProfileFinishedNotificationBuilder() : m_result(new ConsoleProfileFinishedNotification()) { }
916 :
917 : template<int STEP> ConsoleProfileFinishedNotificationBuilder<STATE | STEP>& castState()
918 : {
919 : return *reinterpret_cast<ConsoleProfileFinishedNotificationBuilder<STATE | STEP>*>(this);
920 : }
921 :
922 : std::unique_ptr<protocol::Profiler::ConsoleProfileFinishedNotification> m_result;
923 : };
924 :
925 : static ConsoleProfileFinishedNotificationBuilder<0> create()
926 : {
927 130 : return ConsoleProfileFinishedNotificationBuilder<0>();
928 : }
929 :
930 : private:
931 : ConsoleProfileFinishedNotification()
932 130 : {
933 : }
934 :
935 : String m_id;
936 : std::unique_ptr<protocol::Debugger::Location> m_location;
937 : std::unique_ptr<protocol::Profiler::Profile> m_profile;
938 : Maybe<String> m_title;
939 : };
940 :
941 :
942 : class ConsoleProfileStartedNotification : public Serializable{
943 : PROTOCOL_DISALLOW_COPY(ConsoleProfileStartedNotification);
944 : public:
945 : static std::unique_ptr<ConsoleProfileStartedNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
946 :
947 405 : ~ConsoleProfileStartedNotification() override { }
948 :
949 : String getId() { return m_id; }
950 : void setId(const String& value) { m_id = value; }
951 :
952 : protocol::Debugger::Location* getLocation() { return m_location.get(); }
953 : void setLocation(std::unique_ptr<protocol::Debugger::Location> value) { m_location = std::move(value); }
954 :
955 : bool hasTitle() { return m_title.isJust(); }
956 : String getTitle(const String& defaultValue) { return m_title.isJust() ? m_title.fromJust() : defaultValue; }
957 270 : void setTitle(const String& value) { m_title = value; }
958 :
959 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
960 405 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
961 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
962 : String toJSON() const { return toValue()->toJSONString(); }
963 : std::unique_ptr<ConsoleProfileStartedNotification> clone() const;
964 :
965 : template<int STATE>
966 135 : class ConsoleProfileStartedNotificationBuilder {
967 : public:
968 : enum {
969 : NoFieldsSet = 0,
970 : IdSet = 1 << 1,
971 : LocationSet = 1 << 2,
972 : AllFieldsSet = (IdSet | LocationSet | 0)};
973 :
974 :
975 : ConsoleProfileStartedNotificationBuilder<STATE | IdSet>& setId(const String& value)
976 : {
977 : static_assert(!(STATE & IdSet), "property id should not be set yet");
978 : m_result->setId(value);
979 : return castState<IdSet>();
980 : }
981 :
982 : ConsoleProfileStartedNotificationBuilder<STATE | LocationSet>& setLocation(std::unique_ptr<protocol::Debugger::Location> value)
983 : {
984 : static_assert(!(STATE & LocationSet), "property location should not be set yet");
985 : m_result->setLocation(std::move(value));
986 : return castState<LocationSet>();
987 : }
988 :
989 : ConsoleProfileStartedNotificationBuilder<STATE>& setTitle(const String& value)
990 : {
991 : m_result->setTitle(value);
992 : return *this;
993 : }
994 :
995 : std::unique_ptr<ConsoleProfileStartedNotification> build()
996 : {
997 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
998 : return std::move(m_result);
999 : }
1000 :
1001 : private:
1002 : friend class ConsoleProfileStartedNotification;
1003 270 : ConsoleProfileStartedNotificationBuilder() : m_result(new ConsoleProfileStartedNotification()) { }
1004 :
1005 : template<int STEP> ConsoleProfileStartedNotificationBuilder<STATE | STEP>& castState()
1006 : {
1007 : return *reinterpret_cast<ConsoleProfileStartedNotificationBuilder<STATE | STEP>*>(this);
1008 : }
1009 :
1010 : std::unique_ptr<protocol::Profiler::ConsoleProfileStartedNotification> m_result;
1011 : };
1012 :
1013 : static ConsoleProfileStartedNotificationBuilder<0> create()
1014 : {
1015 135 : return ConsoleProfileStartedNotificationBuilder<0>();
1016 : }
1017 :
1018 : private:
1019 : ConsoleProfileStartedNotification()
1020 135 : {
1021 : }
1022 :
1023 : String m_id;
1024 : std::unique_ptr<protocol::Debugger::Location> m_location;
1025 : Maybe<String> m_title;
1026 : };
1027 :
1028 :
1029 : // ------------- Backend interface.
1030 :
1031 3879 : class Backend {
1032 : public:
1033 3879 : virtual ~Backend() { }
1034 :
1035 : virtual DispatchResponse disable() = 0;
1036 : virtual DispatchResponse enable() = 0;
1037 : virtual DispatchResponse getBestEffortCoverage(std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>* out_result) = 0;
1038 : virtual DispatchResponse setSamplingInterval(int in_interval) = 0;
1039 : virtual DispatchResponse start() = 0;
1040 : virtual DispatchResponse startPreciseCoverage(Maybe<bool> in_callCount, Maybe<bool> in_detailed) = 0;
1041 : virtual DispatchResponse startTypeProfile() = 0;
1042 : virtual DispatchResponse stop(std::unique_ptr<protocol::Profiler::Profile>* out_profile) = 0;
1043 : virtual DispatchResponse stopPreciseCoverage() = 0;
1044 : virtual DispatchResponse stopTypeProfile() = 0;
1045 : virtual DispatchResponse takePreciseCoverage(std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>* out_result) = 0;
1046 : virtual DispatchResponse takeTypeProfile(std::unique_ptr<protocol::Array<protocol::Profiler::ScriptTypeProfile>>* out_result) = 0;
1047 :
1048 : };
1049 :
1050 : // ------------- Frontend interface.
1051 :
1052 : class Frontend {
1053 : public:
1054 3879 : explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
1055 : void consoleProfileFinished(const String& id, std::unique_ptr<protocol::Debugger::Location> location, std::unique_ptr<protocol::Profiler::Profile> profile, Maybe<String> title = Maybe<String>());
1056 : void consoleProfileStarted(const String& id, std::unique_ptr<protocol::Debugger::Location> location, Maybe<String> title = Maybe<String>());
1057 :
1058 : void flush();
1059 : void sendRawNotification(String);
1060 : void sendRawNotification(std::vector<uint8_t>);
1061 : private:
1062 : FrontendChannel* m_frontendChannel;
1063 : };
1064 :
1065 : // ------------- Dispatcher.
1066 :
1067 : class Dispatcher {
1068 : public:
1069 : static void wire(UberDispatcher*, Backend*);
1070 :
1071 : private:
1072 : Dispatcher() { }
1073 : };
1074 :
1075 : // ------------- Metainfo.
1076 :
1077 : class Metainfo {
1078 : public:
1079 : using BackendClass = Backend;
1080 : using FrontendClass = Frontend;
1081 : using DispatcherClass = Dispatcher;
1082 : static const char domainName[];
1083 : static const char commandPrefix[];
1084 : static const char version[];
1085 : };
1086 :
1087 : } // namespace Profiler
1088 : } // namespace v8_inspector
1089 : } // namespace protocol
1090 :
1091 : #endif // !defined(v8_inspector_protocol_Profiler_h)
|