001package Torello.Browser.JavaScriptAPI;
002
003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
004// Java-HTML Imports
005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
006
007import Torello.Browser.*;
008import Torello.Browser.helper.*;
009import Torello.Browser.BrowserAPI.*;
010import Torello.JSON.*;
011
012import Torello.Java.ReadOnly.ReadOnlyList;
013import Torello.Java.ReadOnly.ReadOnlyArrayList;
014
015import Torello.JavaDoc.Annotations.StaticFunctional;
016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
017
018import Torello.Browser.JavaScriptAPI.NestedHelpers.Commands.HeapProfiler$$Commands;
019
020
021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
022// JDK Imports
023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
024
025import javax.json.JsonObject;
026import javax.json.JsonValue;
027
028/**
029 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN>
030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE>
031 */
032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE")
033public class HeapProfiler
034{
035    // No Pubic Constructors
036    private HeapProfiler() { }
037
038
039    // ********************************************************************************************
040    // ********************************************************************************************
041    // Eliminated Types
042    // ********************************************************************************************
043    // ********************************************************************************************
044
045
046    /**
047     * Heap snapshot object id.
048
049     * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType
050     *     DATA-NAME=HeapSnapshotObjectId>
051     */
052    public static final String HeapSnapshotObjectId =
053        "HeapSnapshotObjectId has been eliminated.\n" +
054        "It was replaced with the standard Java-Type: String";
055
056
057    // ********************************************************************************************
058    // ********************************************************************************************
059    // Marker Events
060    // ********************************************************************************************
061    // ********************************************************************************************
062
063
064    /**
065     * <CODE>[No Description Provided by Google]</CODE>
066
067     * 
068     * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.MarkerEvent
069     *     DATA-NAME=resetProfiles>
070     */
071    public static final String resetProfiles = "HeapProfiler.resetProfiles Marker Event";
072
073
074
075    // ********************************************************************************************
076    // ********************************************************************************************
077    // Basic Types
078    // ********************************************************************************************
079    // ********************************************************************************************
080
081
082    /**
083     * Sampling profile.
084     * 
085     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
086     */
087    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
088    public static class SamplingHeapProfile
089        extends BaseType<SamplingHeapProfile>
090        implements java.io.Serializable
091    {
092        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
093        protected static final long serialVersionUID = 1;
094
095        private static final NestedHelper<HeapProfiler.SamplingHeapProfile> singleton =
096            Torello.Browser.JavaScriptAPI.NestedHelpers.Types.
097                HeapProfiler$$SamplingHeapProfile$$.singleton;
098
099        /** <CODE>[No Description Provided by Google]</CODE> */
100        public final HeapProfiler.SamplingHeapProfileNode head;
101
102        /** <CODE>[No Description Provided by Google]</CODE> */
103        public final HeapProfiler.SamplingHeapProfileSample[] samples;
104
105        /** Constructor.  Please review this class' fields for documentation. */
106        public SamplingHeapProfile(
107                ReadOnlyList<Boolean> isPresent, SamplingHeapProfileNode head,
108                SamplingHeapProfileSample[] samples
109            )
110        {
111            super(singleton, Domains.HeapProfiler, "SamplingHeapProfile", 2);
112
113            this.head       = head;
114            this.samples    = samples;
115
116            this.isPresent = (isPresent == null)
117                ? singleton.generateIsPresentList(this)
118                : THROWS.check(isPresent, 2, "HeapProfiler.SamplingHeapProfile");
119        }
120
121        /** Creates an instance of this class from a {@link JsonObject}.*/
122        public static SamplingHeapProfile fromJSON(JsonObject jo)
123        { return singleton.fromJSON(jo); }
124
125        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
126        public static NestedDescriptor<SamplingHeapProfile> descriptor()
127        { return singleton.descriptor(); }
128    }
129
130    /**
131     * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
132     * 
133     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
134     */
135    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
136    public static class SamplingHeapProfileNode
137        extends BaseType<SamplingHeapProfileNode>
138        implements java.io.Serializable
139    {
140        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
141        protected static final long serialVersionUID = 1;
142
143        private static final NestedHelper<HeapProfiler.SamplingHeapProfileNode> singleton =
144            Torello.Browser.JavaScriptAPI.NestedHelpers.Types.
145                HeapProfiler$$SamplingHeapProfileNode$$.singleton;
146
147        /** Function location. */
148        public final RunTime.CallFrame callFrame;
149
150        /** Allocations size in bytes for the node excluding children. */
151        public final Number selfSize;
152
153        /** Node id. Ids are unique across all profiles collected between startSampling and stopSampling. */
154        public final int id;
155
156        /** Child nodes. */
157        public final HeapProfiler.SamplingHeapProfileNode[] children;
158
159        /** Constructor.  Please review this class' fields for documentation. */
160        public SamplingHeapProfileNode(
161                ReadOnlyList<Boolean> isPresent, RunTime.CallFrame callFrame, Number selfSize,
162                int id, SamplingHeapProfileNode[] children
163            )
164        {
165            super(singleton, Domains.HeapProfiler, "SamplingHeapProfileNode", 4);
166
167            this.callFrame  = callFrame;
168            this.selfSize   = selfSize;
169            this.id         = id;
170            this.children   = children;
171
172            this.isPresent = (isPresent == null)
173                ? singleton.generateIsPresentList(this)
174                : THROWS.check(isPresent, 4, "HeapProfiler.SamplingHeapProfileNode");
175        }
176
177        /** Creates an instance of this class from a {@link JsonObject}.*/
178        public static SamplingHeapProfileNode fromJSON(JsonObject jo)
179        { return singleton.fromJSON(jo); }
180
181        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
182        public static NestedDescriptor<SamplingHeapProfileNode> descriptor()
183        { return singleton.descriptor(); }
184    }
185
186    /**
187     * A single sample from a sampling profile.
188     * 
189     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
190     */
191    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
192    public static class SamplingHeapProfileSample
193        extends BaseType<SamplingHeapProfileSample>
194        implements java.io.Serializable
195    {
196        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
197        protected static final long serialVersionUID = 1;
198
199        private static final NestedHelper<HeapProfiler.SamplingHeapProfileSample> singleton =
200            Torello.Browser.JavaScriptAPI.NestedHelpers.Types.
201                HeapProfiler$$SamplingHeapProfileSample$$.singleton;
202
203        /** Allocation size in bytes attributed to the sample. */
204        public final Number size;
205
206        /** Id of the corresponding profile tree node. */
207        public final int nodeId;
208
209        /**
210         * Time-ordered sample ordinal number. It is unique across all profiles retrieved
211         * between startSampling and stopSampling.
212         */
213        public final Number ordinal;
214
215        /** Constructor.  Please review this class' fields for documentation. */
216        public SamplingHeapProfileSample
217            (ReadOnlyList<Boolean> isPresent, Number size, int nodeId, Number ordinal)
218        {
219            super(singleton, Domains.HeapProfiler, "SamplingHeapProfileSample", 3);
220
221            this.size       = size;
222            this.nodeId     = nodeId;
223            this.ordinal    = ordinal;
224
225            this.isPresent = (isPresent == null)
226                ? singleton.generateIsPresentList(this)
227                : THROWS.check(isPresent, 3, "HeapProfiler.SamplingHeapProfileSample");
228        }
229
230        /** Creates an instance of this class from a {@link JsonObject}.*/
231        public static SamplingHeapProfileSample fromJSON(JsonObject jo)
232        { return singleton.fromJSON(jo); }
233
234        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
235        public static NestedDescriptor<SamplingHeapProfileSample> descriptor()
236        { return singleton.descriptor(); }
237    }
238
239
240    // ********************************************************************************************
241    // ********************************************************************************************
242    // Event Types
243    // ********************************************************************************************
244    // ********************************************************************************************
245
246
247    /**
248     * <CODE>[No Description Provided by Google]</CODE>
249     * 
250     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
251     */
252    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
253    public static class addHeapSnapshotChunk
254        extends BrowserEvent<addHeapSnapshotChunk>
255        implements java.io.Serializable
256    {
257        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
258        protected static final long serialVersionUID = 1;
259
260        private static final NestedHelper<HeapProfiler.addHeapSnapshotChunk> singleton =
261            Torello.Browser.JavaScriptAPI.NestedHelpers.Events.
262                HeapProfiler$$addHeapSnapshotChunk$$.singleton;
263
264        /** <CODE>[No Description Provided by Google]</CODE> */
265        public final String chunk;
266
267        /** Constructor.  Please review this class' fields for documentation. */
268        public addHeapSnapshotChunk(ReadOnlyList<Boolean> isPresent, String chunk)
269        {
270            super(singleton, Domains.HeapProfiler, "addHeapSnapshotChunk", 1);
271
272            this.chunk = chunk;
273
274            this.isPresent = (isPresent == null)
275                ? singleton.generateIsPresentList(this)
276                : THROWS.check(isPresent, 1, "HeapProfiler.addHeapSnapshotChunk");
277        }
278
279        /** Creates an instance of this class from a {@link JsonObject}.*/
280        public static addHeapSnapshotChunk fromJSON(JsonObject jo)
281        { return singleton.fromJSON(jo); }
282
283        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
284        public static NestedDescriptor<addHeapSnapshotChunk> descriptor()
285        { return singleton.descriptor(); }
286    }
287
288    /**
289     * If heap objects tracking has been started then backend may send update for one or more fragments
290     * 
291     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
292     */
293    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
294    public static class heapStatsUpdate
295        extends BrowserEvent<heapStatsUpdate>
296        implements java.io.Serializable
297    {
298        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
299        protected static final long serialVersionUID = 1;
300
301        private static final NestedHelper<HeapProfiler.heapStatsUpdate> singleton =
302            Torello.Browser.JavaScriptAPI.NestedHelpers.Events.
303                HeapProfiler$$heapStatsUpdate$$.singleton;
304
305        /**
306         * An array of triplets. Each triplet describes a fragment. The first integer is the fragment
307         * index, the second integer is a total count of objects for the fragment, the third integer is
308         * a total size of the objects for the fragment.
309         */
310        public final int[] statsUpdate;
311
312        /** Constructor.  Please review this class' fields for documentation. */
313        public heapStatsUpdate(ReadOnlyList<Boolean> isPresent, int[] statsUpdate)
314        {
315            super(singleton, Domains.HeapProfiler, "heapStatsUpdate", 1);
316
317            this.statsUpdate = statsUpdate;
318
319            this.isPresent = (isPresent == null)
320                ? singleton.generateIsPresentList(this)
321                : THROWS.check(isPresent, 1, "HeapProfiler.heapStatsUpdate");
322        }
323
324        /** Creates an instance of this class from a {@link JsonObject}.*/
325        public static heapStatsUpdate fromJSON(JsonObject jo)
326        { return singleton.fromJSON(jo); }
327
328        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
329        public static NestedDescriptor<heapStatsUpdate> descriptor()
330        { return singleton.descriptor(); }
331    }
332
333    /**
334     * If heap objects tracking has been started then backend regularly sends a current value for last
335     * seen object id and corresponding timestamp. If the were changes in the heap since last event
336     * then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event.
337     * 
338     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
339     */
340    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
341    public static class lastSeenObjectId
342        extends BrowserEvent<lastSeenObjectId>
343        implements java.io.Serializable
344    {
345        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
346        protected static final long serialVersionUID = 1;
347
348        private static final NestedHelper<HeapProfiler.lastSeenObjectId> singleton =
349            Torello.Browser.JavaScriptAPI.NestedHelpers.Events.
350                HeapProfiler$$lastSeenObjectId$$.singleton;
351
352        /** <CODE>[No Description Provided by Google]</CODE> */
353        public final int lastSeenObjectId;
354
355        /** <CODE>[No Description Provided by Google]</CODE> */
356        public final Number timestamp;
357
358        /** Constructor.  Please review this class' fields for documentation. */
359        public lastSeenObjectId
360            (ReadOnlyList<Boolean> isPresent, int lastSeenObjectId, Number timestamp)
361        {
362            super(singleton, Domains.HeapProfiler, "lastSeenObjectId", 2);
363
364            this.lastSeenObjectId   = lastSeenObjectId;
365            this.timestamp          = timestamp;
366
367            this.isPresent = (isPresent == null)
368                ? singleton.generateIsPresentList(this)
369                : THROWS.check(isPresent, 2, "HeapProfiler.lastSeenObjectId");
370        }
371
372        /** Creates an instance of this class from a {@link JsonObject}.*/
373        public static lastSeenObjectId fromJSON(JsonObject jo)
374        { return singleton.fromJSON(jo); }
375
376        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
377        public static NestedDescriptor<lastSeenObjectId> descriptor()
378        { return singleton.descriptor(); }
379    }
380
381    /**
382     * <CODE>[No Description Provided by Google]</CODE>
383     * 
384     * <EMBED CLASS=globalDefs DATA-DOMAIN=HeapProfiler DATA-API=JavaScriptAPI>
385     */
386    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
387    public static class reportHeapSnapshotProgress
388        extends BrowserEvent<reportHeapSnapshotProgress>
389        implements java.io.Serializable
390    {
391        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
392        protected static final long serialVersionUID = 1;
393
394        private static final NestedHelper<HeapProfiler.reportHeapSnapshotProgress> singleton =
395            Torello.Browser.JavaScriptAPI.NestedHelpers.Events.
396                HeapProfiler$$reportHeapSnapshotProgress$$.singleton;
397
398        /** <CODE>[No Description Provided by Google]</CODE> */
399        public final int done;
400
401        /** <CODE>[No Description Provided by Google]</CODE> */
402        public final int total;
403
404        /**
405         * <CODE>[No Description Provided by Google]</CODE>
406         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
407         */
408        public final Boolean finished;
409
410        /** Constructor.  Please review this class' fields for documentation. */
411        public reportHeapSnapshotProgress
412            (ReadOnlyList<Boolean> isPresent, int done, int total, Boolean finished)
413        {
414            super(singleton, Domains.HeapProfiler, "reportHeapSnapshotProgress", 3);
415
416            this.done       = done;
417            this.total      = total;
418            this.finished   = finished;
419
420            this.isPresent = (isPresent == null)
421                ? singleton.generateIsPresentList(this)
422                : THROWS.check(isPresent, 3, "HeapProfiler.reportHeapSnapshotProgress");
423        }
424
425        /** Creates an instance of this class from a {@link JsonObject}.*/
426        public static reportHeapSnapshotProgress fromJSON(JsonObject jo)
427        { return singleton.fromJSON(jo); }
428
429        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
430        public static NestedDescriptor<reportHeapSnapshotProgress> descriptor()
431        { return singleton.descriptor(); }
432    }
433
434
435
436
437    // ********************************************************************************************
438    // ********************************************************************************************
439    // Commands
440    // ********************************************************************************************
441    // ********************************************************************************************
442
443
444    /**
445     * Enables console to refer to the node with given id via $x (see Command Line API for more details
446     * $x functions).
447     * 
448     * @param heapObjectId Heap snapshot object id to be accessible by means of $x command line API.
449     * 
450     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
451     *
452     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
453     * browser receives the invocation-request.
454     *
455     * <BR /><BR /><DIV CLASS=JDHint>
456     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
457     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
458     * the Browser Function has run to completion.
459     * </DIV>
460     */
461    public static Script<Void> addInspectedHeapObject(String heapObjectId)
462    {
463        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
464        final String requestJSON = WriteJSON.get(
465            CDPTypes.STRING, "heapObjectId", false, "HeapProfiler.addInspectedHeapObject",
466            heapObjectId
467        );
468
469        return Script.NO_RET(Domains.HeapProfiler, "addInspectedHeapObject", requestJSON);
470    }
471
472    /**
473     * <CODE>[No Description Provided by Google]</CODE>
474     * 
475     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
476     *
477     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
478     * browser receives the invocation-request.
479     *
480     * <BR /><BR /><DIV CLASS=JDHint>
481     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
482     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
483     * the Browser Function has run to completion.
484     * </DIV>
485     */
486    public static Script<Void> collectGarbage()
487    {
488        // Ultra-Simple Request JSON - Because this method has no parameters
489        final String requestJSON = "{\"method\":\"HeapProfiler.collectGarbage\"}";
490
491        return Script.NO_RET(Domains.HeapProfiler, "collectGarbage", requestJSON);
492    }
493
494    /**
495     * <CODE>[No Description Provided by Google]</CODE>
496     * 
497     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
498     *
499     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
500     * browser receives the invocation-request.
501     *
502     * <BR /><BR /><DIV CLASS=JDHint>
503     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
504     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
505     * the Browser Function has run to completion.
506     * </DIV>
507     */
508    public static Script<Void> disable()
509    {
510        // Ultra-Simple Request JSON - Because this method has no parameters
511        final String requestJSON = "{\"method\":\"HeapProfiler.disable\"}";
512
513        return Script.NO_RET(Domains.HeapProfiler, "disable", requestJSON);
514    }
515
516    /**
517     * <CODE>[No Description Provided by Google]</CODE>
518     * 
519     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
520     *
521     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
522     * browser receives the invocation-request.
523     *
524     * <BR /><BR /><DIV CLASS=JDHint>
525     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
526     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
527     * the Browser Function has run to completion.
528     * </DIV>
529     */
530    public static Script<Void> enable()
531    {
532        // Ultra-Simple Request JSON - Because this method has no parameters
533        final String requestJSON = "{\"method\":\"HeapProfiler.enable\"}";
534
535        return Script.NO_RET(Domains.HeapProfiler, "enable", requestJSON);
536    }
537
538    /**
539     * <CODE>[No Description Provided by Google]</CODE>
540     * 
541     * @param objectId Identifier of the object to get heap object id for.
542     * 
543     * @return An instance of <CODE>{@link Script}&lt;String&gt;</CODE>
544     * 
545     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
546     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
547     * <CODE>&lt;String&gt;</CODE> will be returned
548     *
549     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
550     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
551     * be retrieved.</I>
552     *
553     * <BR /><BR /><DIV CLASS=JDHint>
554     * This Browser Function's {@code Promise} returns:
555     * <CODE>String (<B>heapSnapshotObjectId</B>)</CODE>
556     * <BR />
557     * Id of the heap snapshot object corresponding to the passed remote object id.
558     * </DIV>
559     */
560    public static Script<String> getHeapObjectId(String objectId)
561    {
562        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
563        final String requestJSON = WriteJSON.get
564            (CDPTypes.STRING, "objectId", false, "HeapProfiler.getHeapObjectId", objectId);
565
566        return new Script<>(
567            Domains.HeapProfiler, "getHeapObjectId", requestJSON,
568            jo -> ReadJSON.getString(jo, "heapSnapshotObjectId", true, false),
569            String.class
570        );
571    }
572
573    /**
574     * <CODE>[No Description Provided by Google]</CODE>
575     * 
576     * @param objectId -
577     * 
578     * @param objectGroup Symbolic group name that can be used to release multiple objects.
579     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
580     * 
581     * @return An instance of <CODE>{@link Script}&lt;{@link RunTime.RemoteObject}&gt;</CODE>
582     * 
583     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
584     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
585     * <CODE>&lt;{@link RunTime.RemoteObject}&gt;</CODE> will be returned
586     *
587     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
588     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
589     * be retrieved.</I>
590     *
591     * <BR /><BR /><DIV CLASS=JDHint>
592     * This Browser Function's {@code Promise} returns:
593     * <CODE>{@link RunTime.RemoteObject} (<B>result</B>)</CODE>
594     * <BR />
595     * Evaluation result.
596     * </DIV>
597     */
598    public static Script<RunTime.RemoteObject> getObjectByHeapObjectId
599        (String objectId, String objectGroup)
600    {
601        // Convert all Method Parameters into a JSON Request-Object (as a String)
602        final String requestJSON = WriteJSON.get(
603            HeapProfiler$$Commands.getObjectByHeapObjectId$$,
604            "HeapProfiler.getObjectByHeapObjectId",
605            objectId, objectGroup
606        );
607
608        return new Script<>(
609            Domains.HeapProfiler, "getObjectByHeapObjectId", requestJSON,
610            HeapProfiler$$Commands::getObjectByHeapObjectId,
611            RunTime.RemoteObject.class
612        );
613    }
614
615    /**
616     * <CODE>[No Description Provided by Google]</CODE>
617     * 
618     * @return An instance of <CODE>{@link Script}
619     * &lt;{@link HeapProfiler.SamplingHeapProfile}&gt;</CODE>
620     * 
621     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
622     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
623     * <CODE>&lt;{@link HeapProfiler.SamplingHeapProfile}&gt;</CODE> will be returned
624     *
625     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
626     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
627     * be retrieved.</I>
628     *
629     * <BR /><BR /><DIV CLASS=JDHint>
630     * This Browser Function's {@code Promise} returns:
631     * <CODE>{@link HeapProfiler.SamplingHeapProfile} (<B>profile</B>)</CODE>
632     * <BR />
633     * Return the sampling profile being collected.
634     * </DIV>
635     */
636    public static Script<HeapProfiler.SamplingHeapProfile> getSamplingProfile()
637    {
638        // Ultra-Simple Request JSON - Because this method has no parameters
639        final String requestJSON = "{\"method\":\"HeapProfiler.getSamplingProfile\"}";
640
641        return new Script<>(
642            Domains.HeapProfiler, "getSamplingProfile", requestJSON,
643            HeapProfiler$$Commands::getSamplingProfile,
644            HeapProfiler.SamplingHeapProfile.class
645        );
646    }
647
648    /**
649     * <CODE>[No Description Provided by Google]</CODE>
650     * 
651     * @param samplingInterval 
652     * Average sample interval in bytes. Poisson distribution is used for the intervals. The
653     * default value is 32768 bytes.
654     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
655     * 
656     * @param includeObjectsCollectedByMajorGC 
657     * By default, the sampling heap profiler reports only objects which are
658     * still alive when the profile is returned via getSamplingProfile or
659     * stopSampling, which is useful for determining what functions contribute
660     * the most to steady-state memory usage. This flag instructs the sampling
661     * heap profiler to also include information about objects discarded by
662     * major GC, which will show which functions cause large temporary memory
663     * usage or long GC pauses.
664     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
665     * 
666     * @param includeObjectsCollectedByMinorGC 
667     * By default, the sampling heap profiler reports only objects which are
668     * still alive when the profile is returned via getSamplingProfile or
669     * stopSampling, which is useful for determining what functions contribute
670     * the most to steady-state memory usage. This flag instructs the sampling
671     * heap profiler to also include information about objects discarded by
672     * minor GC, which is useful when tuning a latency-sensitive application
673     * for minimal GC activity.
674     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
675     * 
676     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
677     *
678     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
679     * browser receives the invocation-request.
680     *
681     * <BR /><BR /><DIV CLASS=JDHint>
682     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
683     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
684     * the Browser Function has run to completion.
685     * </DIV>
686     */
687    public static Script<Void> startSampling(
688            Number samplingInterval, Boolean includeObjectsCollectedByMajorGC,
689            Boolean includeObjectsCollectedByMinorGC
690        )
691    {
692        // Convert all Method Parameters into a JSON Request-Object (as a String)
693        final String requestJSON = WriteJSON.get(
694            HeapProfiler$$Commands.startSampling$$, "HeapProfiler.startSampling",
695            samplingInterval, includeObjectsCollectedByMajorGC, includeObjectsCollectedByMinorGC
696        );
697
698        return Script.NO_RET(Domains.HeapProfiler, "startSampling", requestJSON);
699    }
700
701    /**
702     * <CODE>[No Description Provided by Google]</CODE>
703     * 
704     * @param trackAllocations -
705     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
706     * 
707     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
708     *
709     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
710     * browser receives the invocation-request.
711     *
712     * <BR /><BR /><DIV CLASS=JDHint>
713     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
714     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
715     * the Browser Function has run to completion.
716     * </DIV>
717     */
718    public static Script<Void> startTrackingHeapObjects(Boolean trackAllocations)
719    {
720        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
721        final String requestJSON = WriteJSON.get(
722            CDPTypes.BOXED_BOOLEAN, "trackAllocations", true,
723            "HeapProfiler.startTrackingHeapObjects", trackAllocations
724        );
725
726        return Script.NO_RET(Domains.HeapProfiler, "startTrackingHeapObjects", requestJSON);
727    }
728
729    /**
730     * <CODE>[No Description Provided by Google]</CODE>
731     * 
732     * @return An instance of <CODE>{@link Script}
733     * &lt;{@link HeapProfiler.SamplingHeapProfile}&gt;</CODE>
734     * 
735     * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using
736     * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise}
737     * <CODE>&lt;{@link HeapProfiler.SamplingHeapProfile}&gt;</CODE> will be returned
738     *
739     * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>,
740     * using {@link Promise#await()}, <I>and the returned result of this Browser Function may
741     * be retrieved.</I>
742     *
743     * <BR /><BR /><DIV CLASS=JDHint>
744     * This Browser Function's {@code Promise} returns:
745     * <CODE>{@link HeapProfiler.SamplingHeapProfile} (<B>profile</B>)</CODE>
746     * <BR />
747     * Recorded sampling heap profile.
748     * </DIV>
749     */
750    public static Script<HeapProfiler.SamplingHeapProfile> stopSampling()
751    {
752        // Ultra-Simple Request JSON - Because this method has no parameters
753        final String requestJSON = "{\"method\":\"HeapProfiler.stopSampling\"}";
754
755        return new Script<>(
756            Domains.HeapProfiler, "stopSampling", requestJSON,
757            HeapProfiler$$Commands::stopSampling,
758            HeapProfiler.SamplingHeapProfile.class
759        );
760    }
761
762    /**
763     * <CODE>[No Description Provided by Google]</CODE>
764     * 
765     * @param reportProgress 
766     * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken
767     * when the tracking is stopped.
768     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
769     * 
770     * @param treatGlobalObjectsAsRoots Deprecated in favor of <CODE>exposeInternals</CODE>.
771     * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Dep-Top>DEPRECATED</B>
772     * 
773     * @param captureNumericValue If true, numerical values are included in the snapshot
774     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
775     * 
776     * @param exposeInternals If true, exposes internals of the snapshot.
777     * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B>
778     * 
779     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
780     *
781     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
782     * browser receives the invocation-request.
783     *
784     * <BR /><BR /><DIV CLASS=JDHint>
785     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
786     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
787     * the Browser Function has run to completion.
788     * </DIV>
789     */
790    public static Script<Void> stopTrackingHeapObjects(
791            Boolean reportProgress, Boolean treatGlobalObjectsAsRoots, Boolean captureNumericValue,
792            Boolean exposeInternals
793        )
794    {
795        // Convert all Method Parameters into a JSON Request-Object (as a String)
796        final String requestJSON = WriteJSON.get(
797            HeapProfiler$$Commands.stopTrackingHeapObjects$$,
798            "HeapProfiler.stopTrackingHeapObjects",
799            reportProgress, treatGlobalObjectsAsRoots, captureNumericValue, exposeInternals
800        );
801
802        return Script.NO_RET(Domains.HeapProfiler, "stopTrackingHeapObjects", requestJSON);
803    }
804
805    /**
806     * <CODE>[No Description Provided by Google]</CODE>
807     * 
808     * @param reportProgress If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
809     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
810     * 
811     * @param treatGlobalObjectsAsRoots 
812     * If true, a raw snapshot without artificial roots will be generated.
813     * Deprecated in favor of <CODE>exposeInternals</CODE>.
814     * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Dep-Top>DEPRECATED</B>
815     * 
816     * @param captureNumericValue If true, numerical values are included in the snapshot
817     * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
818     * 
819     * @param exposeInternals If true, exposes internals of the snapshot.
820     * <BR /><B CLASS=Opt-Top>OPTIONAL</B><B CLASS=Exp-Top>EXPERIMENTAL</B>
821     * 
822     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
823     *
824     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
825     * browser receives the invocation-request.
826     *
827     * <BR /><BR /><DIV CLASS=JDHint>
828     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
829     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
830     * the Browser Function has run to completion.
831     * </DIV>
832     */
833    public static Script<Void> takeHeapSnapshot(
834            Boolean reportProgress, Boolean treatGlobalObjectsAsRoots, Boolean captureNumericValue,
835            Boolean exposeInternals
836        )
837    {
838        // Convert all Method Parameters into a JSON Request-Object (as a String)
839        final String requestJSON = WriteJSON.get(
840            HeapProfiler$$Commands.takeHeapSnapshot$$, "HeapProfiler.takeHeapSnapshot",
841            reportProgress, treatGlobalObjectsAsRoots, captureNumericValue, exposeInternals
842        );
843
844        return Script.NO_RET(Domains.HeapProfiler, "takeHeapSnapshot", requestJSON);
845    }
846
847
848}