@Override public void startLoadingFragment(int fragment, final LoadTerminatedHandler loadErrorHandler) { String url = gwtStartLoadingFragment(fragment, loadErrorHandler); if (url == null) { // The linker is going to handle this fetch - nothing more to do return; } // Browsers will ignore too many script tags if it has previously failed // to download that url, so we add a parameter to the url if // this is not the first time we've tried to download this fragment. int manualRetry = getManualRetryNum(fragment); if (manualRetry > 0) { char connector = url.contains("?") ? '&' : '?'; url += connector + "manualRetry=" + manualRetry; } RequestData request = new RequestData(url, loadErrorHandler, fragment, downloadStrategy, getMaxAutoRetryCount()); request.tryDownload(); }
@SuppressWarnings("unused") // Called via JSNI private static void onLoad(RequestData request, int status, String statusText, String response) { if ((status == HTTP_STATUS_OK || status == HTTP_STATUS_NON_HTTP) && response != null && response.length() != 0) { request.tryInstall(response); } else { // If the download fails request.onLoadError(new HttpDownloadFailure(request.getUrl(), status, statusText), true); } }
@Override public void startLoadingFragment(int fragment, final LoadTerminatedHandler loadErrorHandler) { String url = gwtStartLoadingFragment(fragment, loadErrorHandler); if (url == null) { // The linker is going to handle this fetch - nothing more to do return; } // Browsers will ignore too many script tags if it has previously failed // to download that url, so we add a parameter to the url if // this is not the first time we've tried to download this fragment. int manualRetry = getManualRetryNum(fragment); if (manualRetry > 0) { char connector = url.contains("?") ? '&' : '?'; url += connector + "manualRetry=" + manualRetry; } RequestData request = new RequestData(url, loadErrorHandler, fragment, downloadStrategy, getMaxAutoRetryCount()); request.tryDownload(); }
@Override public void startLoadingFragment(int fragment, final LoadTerminatedHandler loadErrorHandler) { String url = gwtStartLoadingFragment(fragment, loadErrorHandler); if (url == null) { // The linker is going to handle this fetch - nothing more to do return; } // Browsers will ignore too many script tags if it has previously failed // to download that url, so we add a parameter to the url if // this is not the first time we've tried to download this fragment. int manualRetry = getManualRetryNum(fragment); if (manualRetry > 0) { char connector = url.contains("?") ? '&' : '?'; url += connector + "manualRetry=" + manualRetry; } RequestData request = new RequestData(url, loadErrorHandler, fragment, downloadStrategy, getMaxAutoRetryCount()); request.tryDownload(); }
@Override public void tryDownload(final RequestData request) { setAsyncCallback(request.getFragment(), request); ScriptInjector.fromUrl(request.getUrl()).setRemoveTag(true).setCallback( new Callback<Void, Exception>() { @Override public void onFailure(Exception reason) { cleanup(request); } @Override public void onSuccess(Void result) { cleanup(request); } }).inject(); } }
@Override public void tryDownload(final RequestData request) { setAsyncCallback(request.getFragment(), request); ScriptInjector.fromUrl(request.getUrl()).setRemoveTag(true).setCallback( new Callback<Void, Exception>() { @Override public void onFailure(Exception reason) { cleanup(request); } @Override public void onSuccess(Void result) { cleanup(request); } }).inject(); } }
public void tryInstall(String code) { try { gwtInstallCode(code); } catch (RuntimeException e) { String textIntro = code; if (textIntro != null && textIntro.length() > MAX_LOG_LENGTH) { textIntro = textIntro.substring(0, MAX_LOG_LENGTH) + "..."; } onLoadError(new HttpInstallFailure(url, textIntro, e), false); } } }
public void tryInstall(String code) { try { gwtInstallCode(code); } catch (RuntimeException e) { String textIntro = code; if (textIntro != null && textIntro.length() > MAX_LOG_LENGTH) { textIntro = textIntro.substring(0, MAX_LOG_LENGTH) + "..."; } onLoadError(new HttpInstallFailure(url, textIntro, e), false); } } }
private static void cleanup(RequestData request) { boolean neverCalled = clearAsyncCallback(request.getFragment()); if (neverCalled) { request.onLoadError(new HttpDownloadFailure(request.getUrl(), 404, "Script Tag Failure - no status available"), true); } }
@SuppressWarnings("unused") // Called via JSNI private static void onLoad(RequestData request, int status, String statusText, String response) { if ((status == HTTP_STATUS_OK || status == HTTP_STATUS_NON_HTTP) && response != null && response.length() != 0) { request.tryInstall(response); } else { // If the download fails request.onLoadError(new HttpDownloadFailure(request.getUrl(), status, statusText), true); } }
private static void cleanup(RequestData request) { boolean neverCalled = clearAsyncCallback(request.getFragment()); if (neverCalled) { request.onLoadError(new HttpDownloadFailure(request.getUrl(), 404, "Script Tag Failure - no status available"), true); } }
@SuppressWarnings("unused") // Called via JSNI private static void onLoad(RequestData request, int status, String statusText, String response) { if ((status == HTTP_STATUS_OK || status == HTTP_STATUS_NON_HTTP) && response != null && response.length() != 0) { request.tryInstall(response); } else { // If the download fails request.onLoadError(new HttpDownloadFailure(request.getUrl(), status, statusText), true); } }
private static void asyncCallback(RequestData request, String code) { boolean firstTimeCalled = clearAsyncCallback(request.getFragment()); if (firstTimeCalled) { request.tryInstall(code); } }
private static void asyncCallback(RequestData request, String code) { boolean firstTimeCalled = clearAsyncCallback(request.getFragment()); if (firstTimeCalled) { request.tryInstall(code); } }
@Override public void tryDownload(final RequestData request) { setAsyncCallback(request.getFragment(), request); ScriptInjector.fromUrl(request.getUrl()).setRemoveTag(true).setCallback( new Callback<Void, Exception>() { @Override public void onFailure(Exception reason) { cleanup(request); } @Override public void onSuccess(Void result) { cleanup(request); } }).inject(); } }
public void tryInstall(String code) { try { gwtInstallCode(code); } catch (RuntimeException e) { String textIntro = code; if (textIntro != null && textIntro.length() > MAX_LOG_LENGTH) { textIntro = textIntro.substring(0, MAX_LOG_LENGTH) + "..."; } onLoadError(new HttpInstallFailure(url, textIntro, e), false); } } }
private static void asyncCallback(RequestData request, String code) { boolean firstTimeCalled = clearAsyncCallback(request.getFragment()); if (firstTimeCalled) { request.tryInstall(code); } }
private static void cleanup(RequestData request) { boolean neverCalled = clearAsyncCallback(request.getFragment()); if (neverCalled) { request.onLoadError(new HttpDownloadFailure(request.getUrl(), 404, "Script Tag Failure - no status available"), true); } }