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