001package Torello.Browser.BrowserAPI; 002 003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 004// Java-HTML Imports 005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 006 007import Torello.Browser.*; 008import Torello.Browser.helper.*; 009import Torello.Browser.JavaScriptAPI.*; 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.BrowserAPI.NestedHelpers.Commands.Performance$$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 Performance 034{ 035 // No Pubic Constructors 036 private Performance() { } 037 038 039 040 // ******************************************************************************************** 041 // ******************************************************************************************** 042 // Basic Types 043 // ******************************************************************************************** 044 // ******************************************************************************************** 045 046 047 /** 048 * Run-time execution metric. 049 * 050 * <EMBED CLASS=globalDefs DATA-DOMAIN=Performance DATA-API=BrowserAPI> 051 */ 052 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 053 public static class Metric 054 extends BaseType<Metric> 055 implements java.io.Serializable 056 { 057 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 058 protected static final long serialVersionUID = 1; 059 060 private static final NestedHelper<Performance.Metric> singleton = 061 Torello.Browser.BrowserAPI.NestedHelpers.Types. 062 Performance$$Metric$$.singleton; 063 064 /** Metric name. */ 065 public final String name; 066 067 /** Metric value. */ 068 public final Number value; 069 070 /** Constructor. Please review this class' fields for documentation. */ 071 public Metric(ReadOnlyList<Boolean> isPresent, String name, Number value) 072 { 073 super(singleton, Domains.Performance, "Metric", 2); 074 075 this.name = name; 076 this.value = value; 077 078 this.isPresent = (isPresent == null) 079 ? singleton.generateIsPresentList(this) 080 : THROWS.check(isPresent, 2, "Performance.Metric"); 081 } 082 083 /** Creates an instance of this class from a {@link JsonObject}.*/ 084 public static Metric fromJSON(JsonObject jo) 085 { return singleton.fromJSON(jo); } 086 087 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 088 public static NestedDescriptor<Metric> descriptor() 089 { return singleton.descriptor(); } 090 } 091 092 093 // ******************************************************************************************** 094 // ******************************************************************************************** 095 // Event Types 096 // ******************************************************************************************** 097 // ******************************************************************************************** 098 099 100 /** 101 * Current values of the metrics. 102 * 103 * <EMBED CLASS=globalDefs DATA-DOMAIN=Performance DATA-API=BrowserAPI> 104 */ 105 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 106 public static class metrics 107 extends BrowserEvent<metrics> 108 implements java.io.Serializable 109 { 110 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 111 protected static final long serialVersionUID = 1; 112 113 private static final NestedHelper<Performance.metrics> singleton = 114 Torello.Browser.BrowserAPI.NestedHelpers.Events. 115 Performance$$metrics$$.singleton; 116 117 /** Current values of the metrics. */ 118 public final Performance.Metric[] metrics; 119 120 /** Timestamp title. */ 121 public final String title; 122 123 /** Constructor. Please review this class' fields for documentation. */ 124 public metrics(ReadOnlyList<Boolean> isPresent, Metric[] metrics, String title) 125 { 126 super(singleton, Domains.Performance, "metrics", 2); 127 128 this.metrics = metrics; 129 this.title = title; 130 131 this.isPresent = (isPresent == null) 132 ? singleton.generateIsPresentList(this) 133 : THROWS.check(isPresent, 2, "Performance.metrics"); 134 } 135 136 /** Creates an instance of this class from a {@link JsonObject}.*/ 137 public static metrics fromJSON(JsonObject jo) 138 { return singleton.fromJSON(jo); } 139 140 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 141 public static NestedDescriptor<metrics> descriptor() 142 { return singleton.descriptor(); } 143 } 144 145 146 147 148 // ******************************************************************************************** 149 // ******************************************************************************************** 150 // Commands 151 // ******************************************************************************************** 152 // ******************************************************************************************** 153 154 155 /** 156 * Disable collecting and reporting metrics. 157 * 158 * @return An instance of <CODE>{@link Script}<Void></CODE> 159 * 160 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 161 * browser receives the invocation-request. 162 * 163 * <BR /><BR /><DIV CLASS=JDHint> 164 * This Browser-Function <I>does not have</I> a return-value. You may choose to 165 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 166 * the Browser Function has run to completion. 167 * </DIV> 168 */ 169 public static Script<Void> disable() 170 { 171 // Ultra-Simple Request JSON - Because this method has no parameters 172 final String requestJSON = "{\"method\":\"Performance.disable\"}"; 173 174 return Script.NO_RET(Domains.Performance, "disable", requestJSON); 175 } 176 177 /** 178 * Enable collecting and reporting metrics. 179 * 180 * @param timeDomain Time domain to use for collecting and reporting duration metrics. 181 * <BR />Acceptable Values: ["threadTicks", "timeTicks"] 182 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 183 * 184 * @return An instance of <CODE>{@link Script}<Void></CODE> 185 * 186 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 187 * browser receives the invocation-request. 188 * 189 * <BR /><BR /><DIV CLASS=JDHint> 190 * This Browser-Function <I>does not have</I> a return-value. You may choose to 191 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 192 * the Browser Function has run to completion. 193 * </DIV> 194 */ 195 public static Script<Void> enable(String timeDomain) 196 { 197 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 198 final String requestJSON = WriteJSON.get 199 (CDPTypes.STRING, "timeDomain", true, "Performance.enable", timeDomain); 200 201 return Script.NO_RET(Domains.Performance, "enable", requestJSON); 202 } 203 204 /** 205 * Retrieve current values of run-time metrics. 206 * 207 * @return An instance of <CODE>{@link Script}<{@link Performance.Metric}[]></CODE> 208 * 209 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 210 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 211 * <CODE><{@link Performance.Metric}[]></CODE> will be returned 212 * 213 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 214 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 215 * be retrieved.</I> 216 * 217 * <BR /><BR /><DIV CLASS=JDHint> 218 * This Browser Function's {@code Promise} returns: 219 * <CODE>{@link Performance.Metric}[] (<B>metrics</B>)</CODE> 220 * <BR /> 221 * Current values for run-time metrics. 222 * </DIV> 223 */ 224 public static Script<Performance.Metric[]> getMetrics() 225 { 226 // Ultra-Simple Request JSON - Because this method has no parameters 227 final String requestJSON = "{\"method\":\"Performance.getMetrics\"}"; 228 229 return new Script<>( 230 Domains.Performance, "getMetrics", requestJSON, 231 Performance$$Commands::getMetrics, 232 Performance.Metric[].class 233 ); 234 } 235 236 /** 237 * Sets time domain to use for collecting and reporting duration metrics. 238 * Note that this must be called before enabling metrics collection. Calling 239 * this method while metrics collection is enabled returns an error. 240 * 241 * <BR /><B CLASS=Exp-Top>EXPERIMENTAL</B><B CLASS=Dep-Top>DEPRECATED</B> 242 * 243 * @param timeDomain Time domain 244 * <BR />Acceptable Values: ["threadTicks", "timeTicks"] 245 * 246 * @return An instance of <CODE>{@link Script}<Void></CODE> 247 * 248 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 249 * browser receives the invocation-request. 250 * 251 * <BR /><BR /><DIV CLASS=JDHint> 252 * This Browser-Function <I>does not have</I> a return-value. You may choose to 253 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 254 * the Browser Function has run to completion. 255 * </DIV> 256 */ 257 public static Script<Void> setTimeDomain(String timeDomain) 258 { 259 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 260 final String requestJSON = WriteJSON.get 261 (CDPTypes.STRING, "timeDomain", false, "Performance.setTimeDomain", timeDomain); 262 263 return Script.NO_RET(Domains.Performance, "setTimeDomain", requestJSON); 264 } 265 266 267}