public class LoadingStrategyBase extends Object implements AsyncFragmentLoader.LoadingStrategy
__gwtStartLoadingFragment
. This function is called by
this class with two arguments: an integer fragment number that needs
to be downloaded, and a one-argument loadFinished function. If the load
fails, that function should be called with a descriptive exception as the
argument. If the load succeeds, that function may also be called, so long as
it isn't called until the downloaded code has been installed.
If the mechanism for loading the contents of fragments is provided by the
linker, the __gwtStartLoadingFragment
function should return
null
or undefined
, and the linker should handle
installing the code as well. Note that in this case, all the code in this
class is pretty much moot.
Alternatively, the function can return a URL designating from where the code
for the requested fragment can be downloaded. In that case, the linker should
also provide a function __gwtInstallCode
for actually installing
the code once it is downloaded. That function will be passed the loaded code
once it has been downloaded.Modifier and Type | Class and Description |
---|---|
protected static interface |
LoadingStrategyBase.DownloadStrategy
Subclasses will need to implement this and pass it in in the constructor.
|
protected static class |
LoadingStrategyBase.RequestData
Since LoadingStrategy must support concurrent requests, we keep most of the
relevant info in the RequestData, and pass it around.
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_AUTO_RETRY_COUNT
The number of times that we will retry a download.
|
Constructor and Description |
---|
LoadingStrategyBase(LoadingStrategyBase.DownloadStrategy downloadStrategy)
Subclasses should create a DownloadStrategy and pass it into this constructor.
|
Modifier and Type | Method and Description |
---|---|
LoadingStrategyBase.DownloadStrategy |
getDownloadStrategy() |
protected int |
getMaxAutoRetryCount() |
protected static void |
gwtInstallCode(String text)
Call the linker-supplied
__gwtInstallCode method. |
protected static String |
gwtStartLoadingFragment(int fragment,
AsyncFragmentLoader.LoadTerminatedHandler loadErrorHandler)
Call the linker-supplied __gwtStartLoadingFragment function.
|
void |
startLoadingFragment(int fragment,
AsyncFragmentLoader.LoadTerminatedHandler loadErrorHandler) |
public static int MAX_AUTO_RETRY_COUNT
public LoadingStrategyBase(LoadingStrategyBase.DownloadStrategy downloadStrategy)
protected static void gwtInstallCode(String text)
__gwtInstallCode
method. This method
will attempt to install the code, and throw a runtime exception if it fails,
which will get caught by the RequestData.tryInstall() function.protected static String gwtStartLoadingFragment(int fragment, AsyncFragmentLoader.LoadTerminatedHandler loadErrorHandler)
public LoadingStrategyBase.DownloadStrategy getDownloadStrategy()
public void startLoadingFragment(int fragment, AsyncFragmentLoader.LoadTerminatedHandler loadErrorHandler)
startLoadingFragment
in interface AsyncFragmentLoader.LoadingStrategy
protected int getMaxAutoRetryCount()
Copyright © 2018. All rights reserved.