| Index: chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
|
| index 53ccdceb55169b4ad418df644d6b61048f51657c..8295724686340852ef71e89c78b1f643be9348cd 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
|
| @@ -4,11 +4,15 @@
|
|
|
| package org.chromium.chrome.browser.sync;
|
|
|
| +import android.app.Activity;
|
| import android.content.Context;
|
| import android.util.Log;
|
|
|
| import com.google.common.base.Joiner;
|
|
|
| +import org.chromium.base.ActivityState;
|
| +import org.chromium.base.ApplicationStatus;
|
| +import org.chromium.base.ApplicationStatus.ActivityStateListener;
|
| import org.chromium.base.CalledByNative;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.VisibleForTesting;
|
| @@ -36,6 +40,9 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
| */
|
| public class ProfileSyncService {
|
|
|
| + /**
|
| + * Listener for sync status changes.
|
| + */
|
| public interface SyncStateChangedListener {
|
| // Invoked when the underlying sync status has changed.
|
| public void syncStateChanged();
|
| @@ -86,6 +93,16 @@ public class ProfileSyncService {
|
| // been set up, but ProfileSyncService::Startup() won't be called until
|
| // credentials are available.
|
| mNativeProfileSyncServiceAndroid = nativeInit();
|
| +
|
| + // When the application gets paused, tell sync to flush the directory to disk.
|
| + ApplicationStatus.registerStateListenerForAllActivities(new ActivityStateListener() {
|
| + @Override
|
| + public void onActivityStateChange(Activity activity, int newState) {
|
| + if (newState == ActivityState.PAUSED) {
|
| + flushDirectory();
|
| + }
|
| + }
|
| + });
|
| }
|
|
|
| @CalledByNative
|
| @@ -503,6 +520,13 @@ public class ProfileSyncService {
|
| }
|
|
|
| /**
|
| + * Flushes the sync directory.
|
| + */
|
| + public void flushDirectory() {
|
| + nativeFlushDirectory(mNativeProfileSyncServiceAndroid);
|
| + }
|
| +
|
| + /**
|
| * Returns the time when the last sync cycle was completed.
|
| *
|
| * @return The difference measured in microseconds, between last sync cycle completion time
|
| @@ -544,6 +568,7 @@ public class ProfileSyncService {
|
| private native long nativeInit();
|
| private native void nativeEnableSync(long nativeProfileSyncServiceAndroid);
|
| private native void nativeDisableSync(long nativeProfileSyncServiceAndroid);
|
| + private native void nativeFlushDirectory(long nativeProfileSyncServiceAndroid);
|
| private native void nativeSignInSync(long nativeProfileSyncServiceAndroid);
|
| private native void nativeSignOutSync(long nativeProfileSyncServiceAndroid);
|
| private native boolean nativeSetSyncSessionsId(
|
|
|