FileDocCategorySizeDatePackage
CacheLoader.javaAPI DocAndroid 1.5 API2169Wed May 06 22:41:56 BST 2009android.webkit

CacheLoader

public class CacheLoader extends StreamLoader
This class is a concrete implementation of StreamLoader that uses a CacheResult as the source for the stream. The CacheResult stored mimetype and encoding is added to the HTTP response headers.

Fields Summary
CacheManager.CacheResult
mCacheResult
Constructors Summary
CacheLoader(LoadListener loadListener, CacheManager.CacheResult result)
Constructs a CacheLoader for use when loading content from the cache.

param
loadListener LoadListener to pass the content to
param
result CacheResult used as the source for the content.

        super(loadListener);
        mCacheResult = result;
    
Methods Summary
protected voidbuildHeaders(android.net.http.Headers headers)

        StringBuilder sb = new StringBuilder(mCacheResult.mimeType);
        if (mCacheResult.encoding != null &&
                mCacheResult.encoding.length() > 0) {
            sb.append(';");
            sb.append(mCacheResult.encoding);
        }
        headers.setContentType(sb.toString());

        if (mCacheResult.location != null &&
                mCacheResult.location.length() > 0) {
            headers.setLocation(mCacheResult.location);
        }
    
protected booleansetupStreamAndSendStatus()

        mDataStream = mCacheResult.inStream;
        mContentLength = mCacheResult.contentLength;
        mHandler.status(1, 1, mCacheResult.httpStatusCode, "OK");
        return true;