Example usage for com.google.gwt.coreext.client JSON stringify

List of usage examples for com.google.gwt.coreext.client JSON stringify

Introduction

In this page you can find the example usage for com.google.gwt.coreext.client JSON stringify.

Prototype

public static native String stringify(JavaScriptObject jso) ;

Source Link

Usage

From source file:com.google.speedtracer.breaky.worker.BreakyWorker.java

License:Apache License

/**
 * On a message, validate.//from ww w .j  ava2 s .  c  om
 * If invalid, report to the host
 */
public void onMessage(MessageEvent event) {
    JavaScriptObject record = JSON.parse(event.getDataAsString());
    JsonSchemaResults results = validator.validate(record);
    if (!results.isValid()) {
        postMessage(JSON.stringify(createMessage(record, results.formatResultsText(event.getDataAsString()))));
    }
}

From source file:com.google.speedtracer.client.model.BreakyWorkerHost.java

License:Apache License

/**
 * Send the raw {@link EventRecord} to the web worker.
 */
public void onEventRecord(EventRecord data) {
    breakyWorker.postMessage(JSON.stringify(data));
}

From source file:com.google.speedtracer.client.model.DataDispatcher.java

License:Apache License

/**
 * Data sources that drive the DataModel drive it through this single function
 * which passes in an {@link EventRecord}.
 * //from  w w  w .  j a v  a2  s  .  c o m
 * @param record the timeline {@link EventRecord}
 */
public void onEventRecord(EventRecord record) {
    record.setSequence(eventRecords.size() + sequenceBase);
    // Possibly register a new custom type.
    record.<UiEvent>cast().apply(customTypeVisitor);

    // Keep a copy of the String for saving later.
    traceDataCopy.push(JSON.stringify(record));
    eventRecords.add(record);
    fireOnEventRecord(record);
}

From source file:com.google.speedtracer.client.model.HintletEngineHost.java

License:Apache License

public void onEventRecord(EventRecord data) {
    if (data.getType() != EventRecordType.PROFILE_DATA) {
        // The hintlet engine does not like profile data
        hintletEngineWorker.postMessage(JSON.stringify(data));
    }/*w w  w  .jav a2s.c  om*/
}

From source file:com.google.speedtracer.hintletengine.client.HintletEventRecordProcessor.java

License:Apache License

/**
 * Receive a new record of browser data and forward it to registered hintlets
 * //from   w w  w  .  ja va 2 s .c  o m
 * @param dataRecord record to send to all hintlets
 */
public void onEventRecord(JavaScriptObject dataRecord) {

    if (!DataBag.hasOwnProperty(dataRecord, "type")) {
        throw new IllegalArgumentException("Expecting an EventRecord. Getting " + JSON.stringify(dataRecord));
    }
    // TODO(haibinlu): make sure the type is valid
    EventRecord eventRecord = dataRecord.cast();
    // Calculate the time spent in each event/sub-event exclusive of children
    computeSelfTime(eventRecord);

    // Keep state for a network resource. NetworkEventDispatcher
    // will determine which events to save data from.
    HintletNetworkResources.getInstance().onEventRecord(eventRecord);
    for (HintletRule rule : rules) {
        rule.onEventRecord(eventRecord);
    }
}