FileDocCategorySizeDatePackage
WebSyncManager.javaAPI DocAndroid 1.5 API5150Wed May 06 22:41:56 BST 2009android.webkit

WebSyncManager

public abstract class WebSyncManager extends Object implements Runnable

Fields Summary
private static final int
SYNC_MESSAGE
private static int
SYNC_NOW_INTERVAL
private static int
SYNC_LATER_INTERVAL
private Thread
mSyncThread
private String
mThreadName
protected android.os.Handler
mHandler
protected WebViewDatabase
mDataBase
private int
mStartSyncRefCount
protected static final String
LOGTAG
Constructors Summary
protected WebSyncManager(android.content.Context context, String name)

        mThreadName = name;
        if (context != null) {
            mDataBase = WebViewDatabase.getInstance(context);
            mSyncThread = new Thread(this);
            mSyncThread.setName(mThreadName);
            mSyncThread.start();
        } else {
            throw new IllegalStateException(
                    "WebSyncManager can't be created without context");
        }
    
Methods Summary
protected java.lang.Objectclone()

        throw new CloneNotSupportedException("doesn't implement Cloneable");
    
protected voidonSyncInit()

    
public voidresetSync()
resetSync() resets sync manager's timer

        if (Config.LOGV) {
            Log.v(LOGTAG, "*** WebSyncManager resetSync ***");
        }
        if (mHandler == null) {
            return;
        }
        mHandler.removeMessages(SYNC_MESSAGE);
        Message msg = mHandler.obtainMessage(SYNC_MESSAGE);
        mHandler.sendMessageDelayed(msg, SYNC_LATER_INTERVAL);
    
public voidrun()

        // prepare Looper for sync handler
        Looper.prepare();
        mHandler = new SyncHandler();
        onSyncInit();
        // lower the priority after onSyncInit() is done
       Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

        Message msg = mHandler.obtainMessage(SYNC_MESSAGE);
        mHandler.sendMessageDelayed(msg, SYNC_LATER_INTERVAL);

        Looper.loop();
    
public voidstartSync()
startSync() requests sync manager to start sync

        if (Config.LOGV) {
            Log.v(LOGTAG, "***  WebSyncManager startSync ***, Ref count:" + 
                    mStartSyncRefCount);
        }
        if (mHandler == null) {
            return;
        }
        if (++mStartSyncRefCount == 1) {
            Message msg = mHandler.obtainMessage(SYNC_MESSAGE);
            mHandler.sendMessageDelayed(msg, SYNC_LATER_INTERVAL);
        }
    
public voidstopSync()
stopSync() requests sync manager to stop sync. remove any SYNC_MESSAGE in the queue to break the sync loop

        if (Config.LOGV) {
            Log.v(LOGTAG, "*** WebSyncManager stopSync ***, Ref count:" + 
                    mStartSyncRefCount);
        }
        if (mHandler == null) {
            return;
        }
        if (--mStartSyncRefCount == 0) {
            mHandler.removeMessages(SYNC_MESSAGE);
        }
    
public voidsync()
sync() forces sync manager to sync now

        if (Config.LOGV) {
            Log.v(LOGTAG, "*** WebSyncManager sync ***");
        }
        if (mHandler == null) {
            return;
        }
        mHandler.removeMessages(SYNC_MESSAGE);
        Message msg = mHandler.obtainMessage(SYNC_MESSAGE);
        mHandler.sendMessageDelayed(msg, SYNC_NOW_INTERVAL);
    
abstract voidsyncFromRamToFlash()