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_HeapProfiler_h
8 : #define v8_inspector_protocol_HeapProfiler_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 :
15 : namespace v8_inspector {
16 : namespace protocol {
17 : namespace HeapProfiler {
18 :
19 : // ------------- Forward and enum declarations.
20 : // Heap snapshot object id.
21 : using HeapSnapshotObjectId = String;
22 : // Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
23 : class SamplingHeapProfileNode;
24 : // Profile.
25 : class SamplingHeapProfile;
26 : // Wrapper for notification params
27 : class AddHeapSnapshotChunkNotification;
28 : // Wrapper for notification params
29 : using ResetProfilesNotification = Object;
30 : // Wrapper for notification params
31 : class ReportHeapSnapshotProgressNotification;
32 : // Wrapper for notification params
33 : class LastSeenObjectIdNotification;
34 : // Wrapper for notification params
35 : class HeapStatsUpdateNotification;
36 :
37 : // ------------- Type and builder declarations.
38 :
39 : // Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
40 : class SamplingHeapProfileNode : public Serializable{
41 : PROTOCOL_DISALLOW_COPY(SamplingHeapProfileNode);
42 : public:
43 : static std::unique_ptr<SamplingHeapProfileNode> fromValue(protocol::Value* value, ErrorSupport* errors);
44 :
45 0 : ~SamplingHeapProfileNode() override { }
46 :
47 : protocol::Runtime::CallFrame* getCallFrame() { return m_callFrame.get(); }
48 : void setCallFrame(std::unique_ptr<protocol::Runtime::CallFrame> value) { m_callFrame = std::move(value); }
49 :
50 : double getSelfSize() { return m_selfSize; }
51 0 : void setSelfSize(double value) { m_selfSize = value; }
52 :
53 : protocol::Array<protocol::HeapProfiler::SamplingHeapProfileNode>* getChildren() { return m_children.get(); }
54 : void setChildren(std::unique_ptr<protocol::Array<protocol::HeapProfiler::SamplingHeapProfileNode>> value) { m_children = std::move(value); }
55 :
56 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
57 0 : String serialize() override { return toValue()->serialize(); }
58 : std::unique_ptr<SamplingHeapProfileNode> clone() const;
59 :
60 : template<int STATE>
61 : class SamplingHeapProfileNodeBuilder {
62 : public:
63 : enum {
64 : NoFieldsSet = 0,
65 : CallFrameSet = 1 << 1,
66 : SelfSizeSet = 1 << 2,
67 : ChildrenSet = 1 << 3,
68 : AllFieldsSet = (CallFrameSet | SelfSizeSet | ChildrenSet | 0)};
69 :
70 :
71 : SamplingHeapProfileNodeBuilder<STATE | CallFrameSet>& setCallFrame(std::unique_ptr<protocol::Runtime::CallFrame> value)
72 : {
73 : static_assert(!(STATE & CallFrameSet), "property callFrame should not be set yet");
74 : m_result->setCallFrame(std::move(value));
75 : return castState<CallFrameSet>();
76 : }
77 :
78 : SamplingHeapProfileNodeBuilder<STATE | SelfSizeSet>& setSelfSize(double value)
79 : {
80 : static_assert(!(STATE & SelfSizeSet), "property selfSize should not be set yet");
81 : m_result->setSelfSize(value);
82 : return castState<SelfSizeSet>();
83 : }
84 :
85 : SamplingHeapProfileNodeBuilder<STATE | ChildrenSet>& setChildren(std::unique_ptr<protocol::Array<protocol::HeapProfiler::SamplingHeapProfileNode>> value)
86 : {
87 : static_assert(!(STATE & ChildrenSet), "property children should not be set yet");
88 : m_result->setChildren(std::move(value));
89 : return castState<ChildrenSet>();
90 : }
91 :
92 : std::unique_ptr<SamplingHeapProfileNode> build()
93 : {
94 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
95 : return std::move(m_result);
96 : }
97 :
98 : private:
99 : friend class SamplingHeapProfileNode;
100 0 : SamplingHeapProfileNodeBuilder() : m_result(new SamplingHeapProfileNode()) { }
101 :
102 : template<int STEP> SamplingHeapProfileNodeBuilder<STATE | STEP>& castState()
103 : {
104 : return *reinterpret_cast<SamplingHeapProfileNodeBuilder<STATE | STEP>*>(this);
105 : }
106 :
107 : std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> m_result;
108 : };
109 :
110 : static SamplingHeapProfileNodeBuilder<0> create()
111 : {
112 0 : return SamplingHeapProfileNodeBuilder<0>();
113 : }
114 :
115 : private:
116 : SamplingHeapProfileNode()
117 0 : {
118 0 : m_selfSize = 0;
119 : }
120 :
121 : std::unique_ptr<protocol::Runtime::CallFrame> m_callFrame;
122 : double m_selfSize;
123 : std::unique_ptr<protocol::Array<protocol::HeapProfiler::SamplingHeapProfileNode>> m_children;
124 : };
125 :
126 :
127 : // Profile.
128 : class SamplingHeapProfile : public Serializable{
129 : PROTOCOL_DISALLOW_COPY(SamplingHeapProfile);
130 : public:
131 : static std::unique_ptr<SamplingHeapProfile> fromValue(protocol::Value* value, ErrorSupport* errors);
132 :
133 0 : ~SamplingHeapProfile() override { }
134 :
135 : protocol::HeapProfiler::SamplingHeapProfileNode* getHead() { return m_head.get(); }
136 : void setHead(std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> value) { m_head = std::move(value); }
137 :
138 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
139 0 : String serialize() override { return toValue()->serialize(); }
140 : std::unique_ptr<SamplingHeapProfile> clone() const;
141 :
142 : template<int STATE>
143 : class SamplingHeapProfileBuilder {
144 : public:
145 : enum {
146 : NoFieldsSet = 0,
147 : HeadSet = 1 << 1,
148 : AllFieldsSet = (HeadSet | 0)};
149 :
150 :
151 : SamplingHeapProfileBuilder<STATE | HeadSet>& setHead(std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> value)
152 : {
153 : static_assert(!(STATE & HeadSet), "property head should not be set yet");
154 : m_result->setHead(std::move(value));
155 : return castState<HeadSet>();
156 : }
157 :
158 : std::unique_ptr<SamplingHeapProfile> build()
159 : {
160 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
161 : return std::move(m_result);
162 : }
163 :
164 : private:
165 : friend class SamplingHeapProfile;
166 0 : SamplingHeapProfileBuilder() : m_result(new SamplingHeapProfile()) { }
167 :
168 : template<int STEP> SamplingHeapProfileBuilder<STATE | STEP>& castState()
169 : {
170 : return *reinterpret_cast<SamplingHeapProfileBuilder<STATE | STEP>*>(this);
171 : }
172 :
173 : std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile> m_result;
174 : };
175 :
176 : static SamplingHeapProfileBuilder<0> create()
177 : {
178 : return SamplingHeapProfileBuilder<0>();
179 : }
180 :
181 : private:
182 : SamplingHeapProfile()
183 0 : {
184 : }
185 :
186 : std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> m_head;
187 : };
188 :
189 :
190 : // Wrapper for notification params
191 : class AddHeapSnapshotChunkNotification : public Serializable{
192 : PROTOCOL_DISALLOW_COPY(AddHeapSnapshotChunkNotification);
193 : public:
194 : static std::unique_ptr<AddHeapSnapshotChunkNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
195 :
196 352 : ~AddHeapSnapshotChunkNotification() override { }
197 :
198 : String getChunk() { return m_chunk; }
199 : void setChunk(const String& value) { m_chunk = value; }
200 :
201 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
202 528 : String serialize() override { return toValue()->serialize(); }
203 : std::unique_ptr<AddHeapSnapshotChunkNotification> clone() const;
204 :
205 : template<int STATE>
206 : class AddHeapSnapshotChunkNotificationBuilder {
207 : public:
208 : enum {
209 : NoFieldsSet = 0,
210 : ChunkSet = 1 << 1,
211 : AllFieldsSet = (ChunkSet | 0)};
212 :
213 :
214 : AddHeapSnapshotChunkNotificationBuilder<STATE | ChunkSet>& setChunk(const String& value)
215 : {
216 : static_assert(!(STATE & ChunkSet), "property chunk should not be set yet");
217 : m_result->setChunk(value);
218 : return castState<ChunkSet>();
219 : }
220 :
221 : std::unique_ptr<AddHeapSnapshotChunkNotification> build()
222 : {
223 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
224 : return std::move(m_result);
225 : }
226 :
227 : private:
228 : friend class AddHeapSnapshotChunkNotification;
229 352 : AddHeapSnapshotChunkNotificationBuilder() : m_result(new AddHeapSnapshotChunkNotification()) { }
230 :
231 : template<int STEP> AddHeapSnapshotChunkNotificationBuilder<STATE | STEP>& castState()
232 : {
233 : return *reinterpret_cast<AddHeapSnapshotChunkNotificationBuilder<STATE | STEP>*>(this);
234 : }
235 :
236 : std::unique_ptr<protocol::HeapProfiler::AddHeapSnapshotChunkNotification> m_result;
237 : };
238 :
239 : static AddHeapSnapshotChunkNotificationBuilder<0> create()
240 : {
241 176 : return AddHeapSnapshotChunkNotificationBuilder<0>();
242 : }
243 :
244 : private:
245 : AddHeapSnapshotChunkNotification()
246 176 : {
247 : }
248 :
249 : String m_chunk;
250 : };
251 :
252 :
253 : // Wrapper for notification params
254 : class ReportHeapSnapshotProgressNotification : public Serializable{
255 : PROTOCOL_DISALLOW_COPY(ReportHeapSnapshotProgressNotification);
256 : public:
257 : static std::unique_ptr<ReportHeapSnapshotProgressNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
258 :
259 0 : ~ReportHeapSnapshotProgressNotification() override { }
260 :
261 : int getDone() { return m_done; }
262 0 : void setDone(int value) { m_done = value; }
263 :
264 : int getTotal() { return m_total; }
265 0 : void setTotal(int value) { m_total = value; }
266 :
267 : bool hasFinished() { return m_finished.isJust(); }
268 : bool getFinished(bool defaultValue) { return m_finished.isJust() ? m_finished.fromJust() : defaultValue; }
269 : void setFinished(bool value) { m_finished = value; }
270 :
271 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
272 0 : String serialize() override { return toValue()->serialize(); }
273 : std::unique_ptr<ReportHeapSnapshotProgressNotification> clone() const;
274 :
275 : template<int STATE>
276 : class ReportHeapSnapshotProgressNotificationBuilder {
277 : public:
278 : enum {
279 : NoFieldsSet = 0,
280 : DoneSet = 1 << 1,
281 : TotalSet = 1 << 2,
282 : AllFieldsSet = (DoneSet | TotalSet | 0)};
283 :
284 :
285 : ReportHeapSnapshotProgressNotificationBuilder<STATE | DoneSet>& setDone(int value)
286 : {
287 : static_assert(!(STATE & DoneSet), "property done should not be set yet");
288 : m_result->setDone(value);
289 : return castState<DoneSet>();
290 : }
291 :
292 : ReportHeapSnapshotProgressNotificationBuilder<STATE | TotalSet>& setTotal(int value)
293 : {
294 : static_assert(!(STATE & TotalSet), "property total should not be set yet");
295 : m_result->setTotal(value);
296 : return castState<TotalSet>();
297 : }
298 :
299 : ReportHeapSnapshotProgressNotificationBuilder<STATE>& setFinished(bool value)
300 : {
301 : m_result->setFinished(value);
302 : return *this;
303 : }
304 :
305 : std::unique_ptr<ReportHeapSnapshotProgressNotification> build()
306 : {
307 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
308 : return std::move(m_result);
309 : }
310 :
311 : private:
312 : friend class ReportHeapSnapshotProgressNotification;
313 0 : ReportHeapSnapshotProgressNotificationBuilder() : m_result(new ReportHeapSnapshotProgressNotification()) { }
314 :
315 : template<int STEP> ReportHeapSnapshotProgressNotificationBuilder<STATE | STEP>& castState()
316 : {
317 : return *reinterpret_cast<ReportHeapSnapshotProgressNotificationBuilder<STATE | STEP>*>(this);
318 : }
319 :
320 : std::unique_ptr<protocol::HeapProfiler::ReportHeapSnapshotProgressNotification> m_result;
321 : };
322 :
323 : static ReportHeapSnapshotProgressNotificationBuilder<0> create()
324 : {
325 0 : return ReportHeapSnapshotProgressNotificationBuilder<0>();
326 : }
327 :
328 : private:
329 : ReportHeapSnapshotProgressNotification()
330 0 : {
331 0 : m_done = 0;
332 0 : m_total = 0;
333 : }
334 :
335 : int m_done;
336 : int m_total;
337 : Maybe<bool> m_finished;
338 : };
339 :
340 :
341 : // Wrapper for notification params
342 : class LastSeenObjectIdNotification : public Serializable{
343 : PROTOCOL_DISALLOW_COPY(LastSeenObjectIdNotification);
344 : public:
345 : static std::unique_ptr<LastSeenObjectIdNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
346 :
347 0 : ~LastSeenObjectIdNotification() override { }
348 :
349 : int getLastSeenObjectId() { return m_lastSeenObjectId; }
350 0 : void setLastSeenObjectId(int value) { m_lastSeenObjectId = value; }
351 :
352 : double getTimestamp() { return m_timestamp; }
353 0 : void setTimestamp(double value) { m_timestamp = value; }
354 :
355 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
356 0 : String serialize() override { return toValue()->serialize(); }
357 : std::unique_ptr<LastSeenObjectIdNotification> clone() const;
358 :
359 : template<int STATE>
360 : class LastSeenObjectIdNotificationBuilder {
361 : public:
362 : enum {
363 : NoFieldsSet = 0,
364 : LastSeenObjectIdSet = 1 << 1,
365 : TimestampSet = 1 << 2,
366 : AllFieldsSet = (LastSeenObjectIdSet | TimestampSet | 0)};
367 :
368 :
369 : LastSeenObjectIdNotificationBuilder<STATE | LastSeenObjectIdSet>& setLastSeenObjectId(int value)
370 : {
371 : static_assert(!(STATE & LastSeenObjectIdSet), "property lastSeenObjectId should not be set yet");
372 : m_result->setLastSeenObjectId(value);
373 : return castState<LastSeenObjectIdSet>();
374 : }
375 :
376 : LastSeenObjectIdNotificationBuilder<STATE | TimestampSet>& setTimestamp(double value)
377 : {
378 : static_assert(!(STATE & TimestampSet), "property timestamp should not be set yet");
379 : m_result->setTimestamp(value);
380 : return castState<TimestampSet>();
381 : }
382 :
383 : std::unique_ptr<LastSeenObjectIdNotification> build()
384 : {
385 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
386 : return std::move(m_result);
387 : }
388 :
389 : private:
390 : friend class LastSeenObjectIdNotification;
391 0 : LastSeenObjectIdNotificationBuilder() : m_result(new LastSeenObjectIdNotification()) { }
392 :
393 : template<int STEP> LastSeenObjectIdNotificationBuilder<STATE | STEP>& castState()
394 : {
395 : return *reinterpret_cast<LastSeenObjectIdNotificationBuilder<STATE | STEP>*>(this);
396 : }
397 :
398 : std::unique_ptr<protocol::HeapProfiler::LastSeenObjectIdNotification> m_result;
399 : };
400 :
401 : static LastSeenObjectIdNotificationBuilder<0> create()
402 : {
403 0 : return LastSeenObjectIdNotificationBuilder<0>();
404 : }
405 :
406 : private:
407 : LastSeenObjectIdNotification()
408 0 : {
409 0 : m_lastSeenObjectId = 0;
410 0 : m_timestamp = 0;
411 : }
412 :
413 : int m_lastSeenObjectId;
414 : double m_timestamp;
415 : };
416 :
417 :
418 : // Wrapper for notification params
419 : class HeapStatsUpdateNotification : public Serializable{
420 : PROTOCOL_DISALLOW_COPY(HeapStatsUpdateNotification);
421 : public:
422 : static std::unique_ptr<HeapStatsUpdateNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
423 :
424 0 : ~HeapStatsUpdateNotification() override { }
425 :
426 : protocol::Array<int>* getStatsUpdate() { return m_statsUpdate.get(); }
427 : void setStatsUpdate(std::unique_ptr<protocol::Array<int>> value) { m_statsUpdate = std::move(value); }
428 :
429 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
430 0 : String serialize() override { return toValue()->serialize(); }
431 : std::unique_ptr<HeapStatsUpdateNotification> clone() const;
432 :
433 : template<int STATE>
434 : class HeapStatsUpdateNotificationBuilder {
435 : public:
436 : enum {
437 : NoFieldsSet = 0,
438 : StatsUpdateSet = 1 << 1,
439 : AllFieldsSet = (StatsUpdateSet | 0)};
440 :
441 :
442 : HeapStatsUpdateNotificationBuilder<STATE | StatsUpdateSet>& setStatsUpdate(std::unique_ptr<protocol::Array<int>> value)
443 : {
444 : static_assert(!(STATE & StatsUpdateSet), "property statsUpdate should not be set yet");
445 : m_result->setStatsUpdate(std::move(value));
446 : return castState<StatsUpdateSet>();
447 : }
448 :
449 : std::unique_ptr<HeapStatsUpdateNotification> build()
450 : {
451 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
452 : return std::move(m_result);
453 : }
454 :
455 : private:
456 : friend class HeapStatsUpdateNotification;
457 0 : HeapStatsUpdateNotificationBuilder() : m_result(new HeapStatsUpdateNotification()) { }
458 :
459 : template<int STEP> HeapStatsUpdateNotificationBuilder<STATE | STEP>& castState()
460 : {
461 : return *reinterpret_cast<HeapStatsUpdateNotificationBuilder<STATE | STEP>*>(this);
462 : }
463 :
464 : std::unique_ptr<protocol::HeapProfiler::HeapStatsUpdateNotification> m_result;
465 : };
466 :
467 : static HeapStatsUpdateNotificationBuilder<0> create()
468 : {
469 : return HeapStatsUpdateNotificationBuilder<0>();
470 : }
471 :
472 : private:
473 : HeapStatsUpdateNotification()
474 0 : {
475 : }
476 :
477 : std::unique_ptr<protocol::Array<int>> m_statsUpdate;
478 : };
479 :
480 :
481 : // ------------- Backend interface.
482 :
483 4573 : class Backend {
484 : public:
485 4573 : virtual ~Backend() { }
486 :
487 : virtual DispatchResponse enable() = 0;
488 : virtual DispatchResponse disable() = 0;
489 : virtual DispatchResponse startTrackingHeapObjects(Maybe<bool> in_trackAllocations) = 0;
490 : virtual DispatchResponse stopTrackingHeapObjects(Maybe<bool> in_reportProgress) = 0;
491 : virtual DispatchResponse takeHeapSnapshot(Maybe<bool> in_reportProgress) = 0;
492 : virtual DispatchResponse collectGarbage() = 0;
493 : virtual DispatchResponse getObjectByHeapObjectId(const String& in_objectId, Maybe<String> in_objectGroup, std::unique_ptr<protocol::Runtime::RemoteObject>* out_result) = 0;
494 : virtual DispatchResponse addInspectedHeapObject(const String& in_heapObjectId) = 0;
495 : virtual DispatchResponse getHeapObjectId(const String& in_objectId, String* out_heapSnapshotObjectId) = 0;
496 : virtual DispatchResponse startSampling(Maybe<double> in_samplingInterval) = 0;
497 : virtual DispatchResponse stopSampling(std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>* out_profile) = 0;
498 :
499 : };
500 :
501 : // ------------- Frontend interface.
502 :
503 : class Frontend {
504 : public:
505 4573 : explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
506 : void addHeapSnapshotChunk(const String& chunk);
507 : void resetProfiles();
508 : void reportHeapSnapshotProgress(int done, int total, Maybe<bool> finished = Maybe<bool>());
509 : void lastSeenObjectId(int lastSeenObjectId, double timestamp);
510 : void heapStatsUpdate(std::unique_ptr<protocol::Array<int>> statsUpdate);
511 :
512 : void flush();
513 : void sendRawNotification(const String&);
514 : private:
515 : FrontendChannel* m_frontendChannel;
516 : };
517 :
518 : // ------------- Dispatcher.
519 :
520 : class Dispatcher {
521 : public:
522 : static void wire(UberDispatcher*, Backend*);
523 :
524 : private:
525 : Dispatcher() { }
526 : };
527 :
528 : // ------------- Metainfo.
529 :
530 : class Metainfo {
531 : public:
532 : using BackendClass = Backend;
533 : using FrontendClass = Frontend;
534 : using DispatcherClass = Dispatcher;
535 : static const char domainName[];
536 : static const char commandPrefix[];
537 : static const char version[];
538 : };
539 :
540 : } // namespace HeapProfiler
541 : } // namespace v8_inspector
542 : } // namespace protocol
543 :
544 : #endif // !defined(v8_inspector_protocol_HeapProfiler_h)
|