Example usage for com.google.gwt.coreext.client JsIntegerMap put

List of usage examples for com.google.gwt.coreext.client JsIntegerMap put

Introduction

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

Prototype

public final native void put(int key, T val) ;

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

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

License:Apache License

/**
 * Sets up mapping of NetworkResourceRecord types to their respective
 * handlers./*from   ww  w .  j av  a  2  s . c  om*/
 *
 * @param proxy the {@link NetworkEventDispatcher}
 * @param typeMap the {@link FastStringMap}
 */
private static void setNetworkEventCallbacks(final NetworkEventDispatcher proxy,
        JsIntegerMap<EventRecordDispatcher> typeMap) {

    typeMap.put(EventRecordType.RESOURCE_SEND_REQUEST, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            proxy.onNetworkResourceStarted(data.<ResourceWillSendEvent>cast());
        }
    });

    typeMap.put(EventRecordType.RESOURCE_RECEIVE_RESPONSE, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            proxy.onNetworkResourceResponse(data.<ResourceResponseEvent>cast());
        }
    });

    typeMap.put(EventRecordType.RESOURCE_FINISH, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            ResourceFinishEvent finish = data.cast();
            proxy.onNetworkResourceFinished(finish);
        }
    });

    typeMap.put(EventRecordType.NETWORK_LOADING_FINISHED, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            ResourceFinishEvent finish = data.cast();
            proxy.onNetworkResourceFinished(finish);
        }
    });

    typeMap.put(EventRecordType.RESOURCE_UPDATED, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            proxy.onNetworkResourceUpdated(data.<ResourceUpdateEvent>cast());
        }
    });

    typeMap.put(EventRecordType.NETWORK_DATA_RECEIVED, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            proxy.onNetworkDataReceived(data.<NetworkDataReceivedEvent>cast());
        }
    });

    typeMap.put(EventRecordType.NETWORK_RESPONSE_RECEIVED, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            proxy.onNetworkResponseReceived(data.<NetworkResponseReceivedEvent>cast());
        }
    });

    typeMap.put(EventRecordType.NETWORK_REQUEST_WILL_BE_SENT, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            proxy.onNetworkRequestWillBeSent(data.<NetworkRequestWillBeSentEvent>cast());
        }
    });
}

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

License:Apache License

/**
 * This sets up the function routing for EventRecord TYPES corresponding to
 * top level events that we want to special case.
 * //  w  ww  . j  a  v a  2  s .c  o m
 * @param dispatcher
 * @param typeMap
 */
private static void setSpecialCasedEventCallbacks(final UiEventDispatcher dispatcher,
        JsIntegerMap<EventRecordDispatcher> typeMap) {

    typeMap.put(TimerCleared.TYPE, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            dispatcher.onTimerCleared(data.<TimerCleared>cast());
        }
    });

    typeMap.put(TimerInstalled.TYPE, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            dispatcher.onTimerInstalled(data.<TimerInstalled>cast());
        }
    });

    typeMap.put(ResourceResponseEvent.TYPE, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            // TODO(jaimeyap): For now we ignore this event. But this event seems to
            // measure things coming out of Application cache, and possibly XHR
            // callbacks coming out of memory cache. We should try to show this
            // properly on the sluggishness view without confusing it with Resource
            // Data Received events.
        }
    });

    typeMap.put(WindowLoadEvent.TYPE, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            List<LoadEventListener> listeners = dispatcher.loadEventListeners;
            for (int i = 0, n = listeners.size(); i < n; i++) {
                listeners.get(i).onWindowLoad(data.<WindowLoadEvent>cast());
            }
        }
    });

    typeMap.put(DomContentLoadedEvent.TYPE, new EventRecordDispatcher() {
        public void onEventRecord(EventRecord data) {
            List<LoadEventListener> listeners = dispatcher.loadEventListeners;
            for (int i = 0, n = listeners.size(); i < n; i++) {
                listeners.get(i).onDomContentLoaded(data.<DomContentLoadedEvent>cast());
            }
        }
    });
}