Package com.google.speedtracer.client.util.Xhr

Examples of com.google.speedtracer.client.util.Xhr.XhrCallback


    serviceRequest(request);
  }

  private void init() {
    Xhr.get(symbolManifestUrl.getUrl(), new XhrCallback() {

      public void onFail(XMLHttpRequest xhr) {
        // Let pending requests know that the manifest failed to load.
        for (PendingRequest request : pendingRequests) {
          request.callback.onSymbolsFetchFailed(ERROR_MANIFEST_NOT_LOADED);
View Full Code Here


    JsSymbolMap symbolMap = get(symbolMapUrl);
    // We only want to request and parse for symbolMaps we havn't already
    // parsed.
    if (symbolMap == null) {
      // Create the XhrCallback to service this request.
      XhrCallback xhrCallback = new XhrCallback() {

        public void onFail(XMLHttpRequest xhr) {
          callback.onSymbolsFetchFailed(ERROR_SYMBOL_FETCH_FAIL);
          dequeuePendingXhrs(symbolMapUrl, xhr, false);
          if (ClientConfig.isDebugMode()) {
            Logging.getLogger().logText(
                "Fetching symbol map: " + symbolMapUrl + " failed.");
          }
        }

        public void onSuccess(XMLHttpRequest xhr) {
          // Double check that another XHR didnt pull it down and parse it.
          JsSymbolMap fetchedSymbolMap = get(symbolMapUrl);
          if (fetchedSymbolMap == null) {
            fetchedSymbolMap = JsSymbolMap.parse(
                resourceSymbolInfo.getSourceServer(),
                resourceSymbolInfo.getSourceViewerServer(),
                resourceSymbolInfo.getType(), xhr.getResponseText());
            put(symbolMapUrl, fetchedSymbolMap);
          }
          callback.onSymbolsReady(fetchedSymbolMap);
          dequeuePendingXhrs(symbolMapUrl, xhr, true);
          if (ClientConfig.isDebugMode()) {
            Logging.getLogger().logText("Fetched symbol map: " + symbolMapUrl);
          }
        }

        private void dequeuePendingXhrs(String symbolMapUrl,
            XMLHttpRequest xhr, boolean success) {
          List<XhrCallback> callbacks = queuedSymbolMapRequests.get(symbolMapUrl);
          if (callbacks != null) {
            while (!callbacks.isEmpty()) {
              XhrCallback callback = callbacks.remove(0);
              if (success) {
                callback.onSuccess(xhr);
              } else {
                callback.onFail(xhr);
              }
            }
          }
        }
      };

      // Check to see if we have a request in flight.
      List<XhrCallback> requestCallbacks = queuedSymbolMapRequests.get(symbolMapUrl);
      if (requestCallbacks == null) {
        // Make an entry indicating a request is in flight.
        queuedSymbolMapRequests.put(symbolMapUrl, new ArrayList<XhrCallback>());
        if (ClientConfig.isDebugMode()) {
          Logging.getLogger().logText(
              "Fetching symbol map URL: " + symbolManifestUrl.getResourceBase()
                  + symbolMapUrl);
        }
        Xhr.get(symbolManifestUrl.getResourceBase() + symbolMapUrl, xhrCallback);
      } else {
        // There are pending XHRs out. Which means that we should just queue
        // this request.
        requestCallbacks.add(xhrCallback);
      }
    } else {
      // We have already fetched this and parsed it before. Send it to the
      // callback.
      callback.onSymbolsReady(symbolMap);
    }
  }
View Full Code Here

    for (int i = 0, n = opaqueParams.length(); i < n; i++) {
      OpaqueParam tuple = opaqueParams.get(i);
      url += "&" + tuple.getKey() + "=" + tuple.getValue();
    }
    // Send out the request.
    Xhr.get(url, new XhrCallback() {
      public void onFail(XMLHttpRequest xhr) {
        actionCallback.onSuccess();
      }

      public void onSuccess(XMLHttpRequest xhr) {
View Full Code Here

TOP

Related Classes of com.google.speedtracer.client.util.Xhr.XhrCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.