public class

AsyncFragmentLoader

extends Object
java.lang.Object
   ↳ com.google.gwt.core.client.impl.AsyncFragmentLoader

Class Overview

Low-level support to download an extra fragment of code. This should not be invoked directly by user code.

The fragments are numbered as follows, assuming there are m split points:

  • 0 -- the base fragment, which is initially downloaded
  • 1..m -- fragments for each split point
  • m+1 -- the leftovers fragment of code that goes nowhere else

Since the precise way to load code depends on the linker, linkers should specify a rebind of AsyncFragmentLoader.LoadingStrategy. The default rebind is XhrLoadingStrategy.

Summary

Nested Classes
interface AsyncFragmentLoader.LoadTerminatedHandler An interface for handlers of load completion. 
interface AsyncFragmentLoader.LoadingStrategy A strategy for loading code fragments. 
interface AsyncFragmentLoader.Logger A strategy for logging progress. 
class AsyncFragmentLoader.LwmLabels Labels used for runAsync lightweight metrics. 
class AsyncFragmentLoader.StandardLogger The standard logger used in a web browser. 
Fields
public static AsyncFragmentLoader BROWSER_LOADER The standard instance of AsyncFragmentLoader used in a web browser.
Public Constructors
AsyncFragmentLoader(int numEntries, int[] initialLoadSequence, AsyncFragmentLoader.LoadingStrategy loadingStrategy, AsyncFragmentLoader.Logger logger)
Public Methods
static void browserLoaderLeftoversFragmentHasLoaded()
A helper static method that invokes BROWSER_LOADER.leftoversFragmentHasLoaded().
void fragmentHasLoaded(int fragment)
Inform the loader that a fragment has now finished loading.
void inject(int splitPoint, AsyncFragmentLoader.LoadTerminatedHandler loadErrorHandler)
Requests a load of the code for the specified split point.
boolean isAlreadyLoaded(int splitPoint)
boolean isLoading(int splitPoint)
void leftoversFragmentHasLoaded()
void logEventProgress(String eventGroup, String type)
Log an event with the {@Logger } this instance was provided.
void setPrefetchQueue(int... runAsyncSplitPoints)
Request that a sequence of split points be prefetched.
void startPrefetching()
void stopPrefetching()
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static AsyncFragmentLoader BROWSER_LOADER

The standard instance of AsyncFragmentLoader used in a web browser. If not in GWT (i.e our vanilla JUnit tests, or if referenced in a server context), this filed is null. In GWT, the parameters to this call are rewritten by com.google.gwt.dev.jjs.impl.ReplaceRunAsyncs. So this must be a method call of exactly two arguments, or that magic fails.

Public Constructors

public AsyncFragmentLoader (int numEntries, int[] initialLoadSequence, AsyncFragmentLoader.LoadingStrategy loadingStrategy, AsyncFragmentLoader.Logger logger)

Public Methods

public static void browserLoaderLeftoversFragmentHasLoaded ()

A helper static method that invokes BROWSER_LOADER.leftoversFragmentHasLoaded(). Such a call is generated by the compiler, as it is much simpler if there is a static method to wrap up the call.

public void fragmentHasLoaded (int fragment)

Inform the loader that a fragment has now finished loading.

public void inject (int splitPoint, AsyncFragmentLoader.LoadTerminatedHandler loadErrorHandler)

Requests a load of the code for the specified split point. If the load fails, loadErrorHandler will be invoked. If it succeeds, then the code will be installed, and the code is expected to invoke its own on-success hooks, including a call to either leftoversFragmentHasLoaded() or fragmentHasLoaded(int).

Parameters
splitPoint the split point whose code needs to be loaded

public boolean isAlreadyLoaded (int splitPoint)

public boolean isLoading (int splitPoint)

public void leftoversFragmentHasLoaded ()

public void logEventProgress (String eventGroup, String type)

Log an event with the {@Logger } this instance was provided.

public void setPrefetchQueue (int... runAsyncSplitPoints)

Request that a sequence of split points be prefetched. Code for the split points in splitPoints will be downloaded and installed whenever there is nothing else to download. Each call to this method overwrites the entire prefetch queue with the newly specified one.

public void startPrefetching ()

public void stopPrefetching ()