summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt7
-rw-r--r--core/java/android/webkit/CookieManager.java12
-rw-r--r--core/java/android/webkit/CookieSyncManager.java65
-rw-r--r--core/java/android/webkit/WebSyncManager.java100
4 files changed, 70 insertions, 114 deletions
diff --git a/api/current.txt b/api/current.txt
index 2653e54..f9ba781 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -35245,6 +35245,7 @@ package android.webkit {
method public synchronized boolean acceptCookie();
method public synchronized boolean acceptThirdPartyCookies(android.webkit.WebView);
method public static boolean allowFileSchemeCookies();
+ method public void flush();
method public java.lang.String getCookie(java.lang.String);
method public static synchronized android.webkit.CookieManager getInstance();
method public synchronized boolean hasCookies();
@@ -35260,10 +35261,10 @@ package android.webkit {
method public void setCookie(java.lang.String, java.lang.String, android.webkit.ValueCallback<java.lang.Boolean>);
}
- public final class CookieSyncManager extends android.webkit.WebSyncManager {
+ public final deprecated class CookieSyncManager extends android.webkit.WebSyncManager {
method public static synchronized android.webkit.CookieSyncManager createInstance(android.content.Context);
method public static synchronized android.webkit.CookieSyncManager getInstance();
- method protected void syncFromRamToFlash();
+ method protected deprecated void syncFromRamToFlash();
field protected static final java.lang.String LOGTAG = "websync";
field protected android.webkit.WebViewDatabase mDataBase;
field protected android.os.Handler mHandler;
@@ -35616,7 +35617,7 @@ package android.webkit {
method public abstract void updateQuota(long);
}
- abstract class WebSyncManager implements java.lang.Runnable {
+ abstract deprecated class WebSyncManager implements java.lang.Runnable {
ctor protected WebSyncManager(android.content.Context, java.lang.String);
method protected void onSyncInit();
method public void resetSync();
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 2564ff0..e1a7ba2 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -68,7 +68,7 @@ public class CookieManager {
throw new MustOverrideException();
}
- /**
+ /**
* Sets whether the {@link WebView} should allow third party cookies to be set.
* Allowing third party cookies is a per WebView policy and can be set
* differently on different WebView instances.
@@ -252,12 +252,20 @@ public class CookieManager {
}
/**
+ * Ensures all cookies currently accessible through the getCookie API are
+ * written to persistent storage.
+ * This call will block the caller until it is done and may perform I/O.
+ */
+ public void flush() {
+ flushCookieStore();
+ }
+
+ /**
* Flushes all cookies managed by the Chrome HTTP stack to flash.
*
* @hide Package level api, called from CookieSyncManager
*/
protected void flushCookieStore() {
- throw new MustOverrideException();
}
/**
diff --git a/core/java/android/webkit/CookieSyncManager.java b/core/java/android/webkit/CookieSyncManager.java
index 13aa43f..ebfa46b 100644
--- a/core/java/android/webkit/CookieSyncManager.java
+++ b/core/java/android/webkit/CookieSyncManager.java
@@ -21,6 +21,13 @@ import android.util.Log;
/**
+ * @deprecated The WebView now automatically syncs cookies as necessary.
+ * You no longer need to create or use the CookieSyncManager.
+ * To manually force a sync you can use the CookieManager
+ * method {@link CookieManager#flush} which is synchronous
+ * replacement for {@link #sync}.
+ * <p>
+ *
* The CookieSyncManager is used to synchronize the browser cookie store
* between RAM and permanent storage. To get the best performance, browser cookies are
* saved in RAM. A separate thread saves the cookies between, driven by a timer.
@@ -55,21 +62,21 @@ import android.util.Log;
* asynchronously, so don't do it just as your activity is shutting
* down.
*/
+@Deprecated
public final class CookieSyncManager extends WebSyncManager {
private static CookieSyncManager sRef;
-
private static boolean sGetInstanceAllowed = false;
private CookieSyncManager() {
- super("CookieSyncManager");
+ super(null, null);
}
/**
* Singleton access to a {@link CookieSyncManager}. An
* IllegalStateException will be thrown if
* {@link CookieSyncManager#createInstance(Context)} is not called before.
- *
+ *
* @return CookieSyncManager
*/
public static synchronized CookieSyncManager getInstance() {
@@ -89,27 +96,53 @@ public final class CookieSyncManager extends WebSyncManager {
if (context == null) {
throw new IllegalArgumentException("Invalid context argument");
}
-
setGetInstanceIsAllowed();
return getInstance();
}
- protected void syncFromRamToFlash() {
- if (DebugFlags.COOKIE_SYNC_MANAGER) {
- Log.v(LOGTAG, "CookieSyncManager::syncFromRamToFlash STARTS");
- }
+ /**
+ * sync() forces sync manager to sync now
+ * @deprecated Use {@link CookieManager#flush} instead.
+ */
+ @Deprecated
+ public void sync() {
+ CookieManager.getInstance().flush();
+ }
- CookieManager manager = CookieManager.getInstance();
+ /**
+ * @deprecated Use {@link CookieManager#flush} instead.
+ */
+ @Deprecated
+ protected void syncFromRamToFlash() {
+ CookieManager.getInstance().flush();
+ }
- if (!manager.acceptCookie()) {
- return;
- }
+ /**
+ * resetSync() resets sync manager's timer.
+ * @deprecated Calling resetSync is no longer necessary as the WebView automatically
+ * syncs cookies.
+ */
+ @Deprecated
+ public void resetSync() {
+ }
- manager.flushCookieStore();
+ /**
+ * startSync() requests sync manager to start sync.
+ * @deprecated Calling startSync is no longer necessary as the WebView automatically
+ * syncs cookies.
+ */
+ @Deprecated
+ public void startSync() {
+ }
- if (DebugFlags.COOKIE_SYNC_MANAGER) {
- Log.v(LOGTAG, "CookieSyncManager::syncFromRamToFlash DONE");
- }
+ /**
+ * stopSync() requests sync manager to stop sync. remove any SYNC_MESSAGE in
+ * the queue to break the sync loop
+ * @deprecated Calling stopSync is no longer useful as the WebView
+ * automatically syncs cookies.
+ */
+ @Deprecated
+ public void stopSync() {
}
static void setGetInstanceIsAllowed() {
diff --git a/core/java/android/webkit/WebSyncManager.java b/core/java/android/webkit/WebSyncManager.java
index c600a7e..402394f 100644
--- a/core/java/android/webkit/WebSyncManager.java
+++ b/core/java/android/webkit/WebSyncManager.java
@@ -23,52 +23,16 @@ import android.os.Message;
import android.os.Process;
import android.util.Log;
+/*
+ * @deprecated The WebSyncManager no longer does anything.
+ */
+@Deprecated
abstract class WebSyncManager implements Runnable {
- // message code for sync message
- private static final int SYNC_MESSAGE = 101;
- // time delay in millisec for a sync (now) message
- private static int SYNC_NOW_INTERVAL = 100; // 100 millisec
- // time delay in millisec for a sync (later) message
- private static int SYNC_LATER_INTERVAL = 5 * 60 * 1000; // 5 minutes
- // thread for syncing
- private Thread mSyncThread;
- // Name of thread
- private String mThreadName;
- // handler of the sync thread
- protected Handler mHandler;
- // database for the persistent storage. Always null.
- protected WebViewDatabase mDataBase;
- // Ref count for calls to start/stop sync
- private int mStartSyncRefCount;
- // log tag
- protected static final String LOGTAG = "websync";
-
- private class SyncHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == SYNC_MESSAGE) {
- if (DebugFlags.WEB_SYNC_MANAGER) {
- Log.v(LOGTAG, "*** WebSyncManager sync ***");
- }
- syncFromRamToFlash();
-
- // send a delayed message to request sync later
- Message newmsg = obtainMessage(SYNC_MESSAGE);
- sendMessageDelayed(newmsg, SYNC_LATER_INTERVAL);
- }
- }
- }
+ protected static final java.lang.String LOGTAG = "websync";
+ protected android.webkit.WebViewDatabase mDataBase;
+ protected android.os.Handler mHandler;
protected WebSyncManager(Context context, String name) {
- this(name);
- }
-
- /** @hide */
- WebSyncManager(String name) {
- mThreadName = name;
- mSyncThread = new Thread(this);
- mSyncThread.setName(mThreadName);
- mSyncThread.start();
}
protected Object clone() throws CloneNotSupportedException {
@@ -76,64 +40,24 @@ abstract class WebSyncManager implements Runnable {
}
public void run() {
- // 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();
}
/**
* sync() forces sync manager to sync now
*/
public void sync() {
- if (DebugFlags.WEB_SYNC_MANAGER) {
- 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);
}
/**
* resetSync() resets sync manager's timer
*/
public void resetSync() {
- if (DebugFlags.WEB_SYNC_MANAGER) {
- 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);
}
/**
* startSync() requests sync manager to start sync
*/
public void startSync() {
- if (DebugFlags.WEB_SYNC_MANAGER) {
- 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);
- }
}
/**
@@ -141,16 +65,6 @@ abstract class WebSyncManager implements Runnable {
* the queue to break the sync loop
*/
public void stopSync() {
- if (DebugFlags.WEB_SYNC_MANAGER) {
- Log.v(LOGTAG, "*** WebSyncManager stopSync ***, Ref count:" +
- mStartSyncRefCount);
- }
- if (mHandler == null) {
- return;
- }
- if (--mStartSyncRefCount == 0) {
- mHandler.removeMessages(SYNC_MESSAGE);
- }
}
protected void onSyncInit() {