Example usage for com.google.gwt.coreext.client JsStringMap create

List of usage examples for com.google.gwt.coreext.client JsStringMap create

Introduction

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

Prototype

public static <T> JsStringMap<T> create() 

Source Link

Document

Creates a new map.

Usage

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

License:Apache License

public void clearData() {
    redirects = JsStringMap.create();
    networkEvents.clear();
}

From source file:com.google.speedtracer.client.visualizations.model.ReportDataCollector.java

License:Apache License

public ReportData gatherDataWithinWindow(double leftBound, double rightBound) {
    Collector uiEventCollector = new Collector() {
        private List<HintRecord> hints = new ArrayList<HintRecord>();

        @Override/*from  w w  w  .  jav a2s  . co  m*/
        void examineRecord(EventRecord record, JsIntegerDoubleMap out) {
            UiEvent castedRecord = record.cast();
            AggregateTimeVisitor.apply(castedRecord);
            // Aggregate the type durations. Only UiEvents will have type
            // durations set. We simply ignore events without a duration map.
            JsIntegerDoubleMap typeDurations = castedRecord.getTypeDurations();
            if (typeDurations != null) {
                doAggregation(typeDurations, out);
            }
            setTotalAvailableTime(getTotalAvailableTime() - castedRecord.getDuration());
            addHintsFromJSOArray(record.getHintRecords(), hints);
        }

        @Override
        void finishCollection(JsIntegerDoubleMap aggregateDurationsOut, List<HintRecord> hintsOut) {
            // Add a wedge for the available time between top level records.
            aggregateDurationsOut.put(-1, getTotalAvailableTime());
            hintsOut.addAll(hints);
        }
    };

    Collector networkEventCollector = new Collector() {
        JsStringMap<JSOArray<HintRecord>> resourceHints = JsStringMap.create();

        @Override
        void examineRecord(EventRecord record, JsIntegerDoubleMap out) {
            // We dont aggregate time, we simply track network resources.
            if (ResourceRecord.isResourceRecord(record)) {
                ResourceRecord resourceRecord = record.cast();
                NetworkResource resource = dataDispatcher.getNetworkEventDispatcher()
                        .getResource(resourceRecord.getRequestId());
                if (resource != null) {
                    resourceHints.put(resourceRecord.getRequestId(), resource.getHintRecords());
                }
            }
        }

        @Override
        void finishCollection(JsIntegerDoubleMap aggregateDurationsOut, final List<HintRecord> hintsOut) {
            // Collect resource related hints that we placed inside the map.
            resourceHints.iterate(new JsStringMap.IterationCallBack<JSOArray<HintRecord>>() {
                public void onIteration(String key, JSOArray<HintRecord> resourceHints) {
                    addHintsFromJSOArray(resourceHints, hintsOut);
                }
            });
        }
    };

    // Gather report for UiEvents.
    ReportData uiEventReport = gatherDataWithinWindowImpl(leftBound, rightBound,
            dataDispatcher.getUiEventDispatcher().getEventList(), uiEventCollector);

    // Gather report for Network Events.
    ReportData networkEventReport = gatherDataWithinWindowImpl(leftBound, rightBound,
            dataDispatcher.getNetworkEventDispatcher().getNetworkEvents(), networkEventCollector);

    return uiEventReport.combineWith(networkEventReport);
}