Commit 85e88f55 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

[Android] Stop saving the legacy Sync Directory when app backgrounded

This logically reverts the old https://codereview.chromium.org/551843003
because meanwhile the Sync Directory has been deprecated in favor of a
new codepath, Unified Sync and Storage (USS).

Change-Id: I80e66c304b76a8d9edffe1a4657ba0c2513f2ff4
Bug: 923287
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250042Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779748}
parent 068e4258
...@@ -357,14 +357,6 @@ public class ProfileSyncService { ...@@ -357,14 +357,6 @@ public class ProfileSyncService {
mNativeProfileSyncServiceAndroid, ProfileSyncService.this, allowed); mNativeProfileSyncServiceAndroid, ProfileSyncService.this, allowed);
} }
/**
* Flushes the sync directory to disk.
*/
public void flushDirectory() {
ProfileSyncServiceJni.get().flushDirectory(
mNativeProfileSyncServiceAndroid, ProfileSyncService.this);
}
/** /**
* Returns the actual passphrase type being used for encryption. The sync engine must be * Returns the actual passphrase type being used for encryption. The sync engine must be
* running (isEngineInitialized() returns true) before calling this function. * running (isEngineInitialized() returns true) before calling this function.
...@@ -654,7 +646,6 @@ public class ProfileSyncService { ...@@ -654,7 +646,6 @@ public class ProfileSyncService {
void requestStop(long nativeProfileSyncServiceAndroid, ProfileSyncService caller); void requestStop(long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
void setSyncAllowedByPlatform( void setSyncAllowedByPlatform(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller, boolean allowed); long nativeProfileSyncServiceAndroid, ProfileSyncService caller, boolean allowed);
void flushDirectory(long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
void setSyncSessionsId( void setSyncSessionsId(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller, String tag); long nativeProfileSyncServiceAndroid, ProfileSyncService caller, String tag);
int getAuthError(long nativeProfileSyncServiceAndroid, ProfileSyncService caller); int getAuthError(long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
......
...@@ -5,14 +5,10 @@ ...@@ -5,14 +5,10 @@
package org.chromium.chrome.browser.sync; package org.chromium.chrome.browser.sync;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.ApplicationStatus.ActivityStateListener;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
...@@ -79,16 +75,6 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen ...@@ -79,16 +75,6 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen
updateSyncStateFromAndroid(); updateSyncStateFromAndroid();
// 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) {
mProfileSyncService.flushDirectory();
}
}
});
IdentityServicesProvider.get().getSigninManager().addSignInStateObserver( IdentityServicesProvider.get().getSigninManager().addSignInStateObserver(
new SigninManager.SignInStateObserver() { new SigninManager.SignInStateObserver() {
@Override @Override
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
package org.chromium.chrome.browser.sync; package org.chromium.chrome.browser.sync;
import android.accounts.Account; import android.accounts.Account;
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
...@@ -15,8 +13,6 @@ import org.junit.Rule; ...@@ -15,8 +13,6 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
...@@ -43,23 +39,6 @@ public class SyncTest { ...@@ -43,23 +39,6 @@ public class SyncTest {
private static final String TAG = "SyncTest"; private static final String TAG = "SyncTest";
@Test
@LargeTest
@Feature({"Sync"})
public void testFlushDirectoryDoesntBreakSync() {
mSyncTestRule.setUpAccountAndSignInForTesting();
final Activity activity = mSyncTestRule.getActivity();
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
ApplicationStatus.onStateChangeForTesting(activity, ActivityState.PAUSED);
}
});
// TODO(pvalenzuela): When available, check that sync is still functional.
}
@Test @Test
@LargeTest @LargeTest
@Feature({"Sync"}) @Feature({"Sync"})
......
...@@ -360,12 +360,6 @@ jlong ProfileSyncServiceAndroid::GetExplicitPassphraseTime( ...@@ -360,12 +360,6 @@ jlong ProfileSyncServiceAndroid::GetExplicitPassphraseTime(
return passphrase_time.ToJavaTime(); return passphrase_time.ToJavaTime();
} }
void ProfileSyncServiceAndroid::FlushDirectory(JNIEnv* env,
const JavaParamRef<jobject>&) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
sync_service_->FlushDirectory();
}
void ProfileSyncServiceAndroid::GetAllNodes( void ProfileSyncServiceAndroid::GetAllNodes(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& obj, const JavaParamRef<jobject>& obj,
......
...@@ -116,8 +116,6 @@ class ProfileSyncServiceAndroid : public syncer::SyncServiceObserver { ...@@ -116,8 +116,6 @@ class ProfileSyncServiceAndroid : public syncer::SyncServiceObserver {
const base::android::JavaParamRef<jobject>&); const base::android::JavaParamRef<jobject>&);
jlong GetExplicitPassphraseTime(JNIEnv* env, jlong GetExplicitPassphraseTime(JNIEnv* env,
const base::android::JavaParamRef<jobject>&); const base::android::JavaParamRef<jobject>&);
void FlushDirectory(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void GetAllNodes(JNIEnv* env, void GetAllNodes(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jobject>& callback); const base::android::JavaParamRef<jobject>& callback);
......
...@@ -240,12 +240,6 @@ void SyncEngineImpl::GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const { ...@@ -240,12 +240,6 @@ void SyncEngineImpl::GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const {
} }
} }
void SyncEngineImpl::FlushDirectory() const {
DCHECK(IsInitialized());
sync_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&SyncEngineBackend::SaveChanges, backend_));
}
void SyncEngineImpl::RequestBufferedProtocolEventsAndEnableForwarding() { void SyncEngineImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
sync_task_runner_->PostTask( sync_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
......
...@@ -81,7 +81,6 @@ class SyncEngineImpl : public SyncEngine, public InvalidationHandler { ...@@ -81,7 +81,6 @@ class SyncEngineImpl : public SyncEngine, public InvalidationHandler {
void HasUnsyncedItemsForTest( void HasUnsyncedItemsForTest(
base::OnceCallback<void(bool)> cb) const override; base::OnceCallback<void(bool)> cb) const override;
void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override; void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override;
void FlushDirectory() const override;
void RequestBufferedProtocolEventsAndEnableForwarding() override; void RequestBufferedProtocolEventsAndEnableForwarding() override;
void DisableProtocolEventForwarding() override; void DisableProtocolEventForwarding() override;
void EnableDirectoryTypeDebugInfoForwarding() override; void EnableDirectoryTypeDebugInfoForwarding() override;
......
...@@ -1991,13 +1991,6 @@ void ProfileSyncService::OverrideNetworkForTest( ...@@ -1991,13 +1991,6 @@ void ProfileSyncService::OverrideNetworkForTest(
} }
} }
void ProfileSyncService::FlushDirectory() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (engine_ && engine_->IsInitialized()) {
engine_->FlushDirectory();
}
}
bool ProfileSyncService::IsPassphrasePrompted() const { bool ProfileSyncService::IsPassphrasePrompted() const {
return sync_prefs_.IsPassphrasePrompted(); return sync_prefs_.IsPassphrasePrompted();
} }
......
...@@ -221,11 +221,6 @@ class ProfileSyncService : public SyncService, ...@@ -221,11 +221,6 @@ class ProfileSyncService : public SyncService,
// once (before this object is destroyed). // once (before this object is destroyed).
void Shutdown() override; void Shutdown() override;
// This triggers a Directory::SaveChanges() call on the sync thread.
// It should be used to persist data to disk when the process might be
// killed in the near future.
void FlushDirectory() const;
bool IsPassphrasePrompted() const; bool IsPassphrasePrompted() const;
void SetPassphrasePrompted(bool prompted); void SetPassphrasePrompted(bool prompted);
......
...@@ -81,8 +81,6 @@ void FakeSyncEngine::HasUnsyncedItemsForTest( ...@@ -81,8 +81,6 @@ void FakeSyncEngine::HasUnsyncedItemsForTest(
void FakeSyncEngine::GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const {} void FakeSyncEngine::GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const {}
void FakeSyncEngine::FlushDirectory() const {}
void FakeSyncEngine::RequestBufferedProtocolEventsAndEnableForwarding() {} void FakeSyncEngine::RequestBufferedProtocolEventsAndEnableForwarding() {}
void FakeSyncEngine::DisableProtocolEventForwarding() {} void FakeSyncEngine::DisableProtocolEventForwarding() {}
......
...@@ -77,8 +77,6 @@ class FakeSyncEngine : public SyncEngine { ...@@ -77,8 +77,6 @@ class FakeSyncEngine : public SyncEngine {
void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override; void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override;
void FlushDirectory() const override;
void RequestBufferedProtocolEventsAndEnableForwarding() override; void RequestBufferedProtocolEventsAndEnableForwarding() override;
void DisableProtocolEventForwarding() override; void DisableProtocolEventForwarding() override;
......
...@@ -53,7 +53,6 @@ class MockSyncEngine : public SyncEngine { ...@@ -53,7 +53,6 @@ class MockSyncEngine : public SyncEngine {
MOCK_CONST_METHOD1(HasUnsyncedItemsForTest, MOCK_CONST_METHOD1(HasUnsyncedItemsForTest,
void(base::OnceCallback<void(bool)>)); void(base::OnceCallback<void(bool)>));
MOCK_CONST_METHOD1(GetModelSafeRoutingInfo, void(ModelSafeRoutingInfo*)); MOCK_CONST_METHOD1(GetModelSafeRoutingInfo, void(ModelSafeRoutingInfo*));
MOCK_CONST_METHOD0(FlushDirectory, void());
MOCK_METHOD0(RequestBufferedProtocolEventsAndEnableForwarding, void()); MOCK_METHOD0(RequestBufferedProtocolEventsAndEnableForwarding, void());
MOCK_METHOD0(DisableProtocolEventForwarding, void()); MOCK_METHOD0(DisableProtocolEventForwarding, void());
MOCK_METHOD0(EnableDirectoryTypeDebugInfoForwarding, void()); MOCK_METHOD0(EnableDirectoryTypeDebugInfoForwarding, void());
......
...@@ -168,9 +168,6 @@ class SyncEngine : public ModelTypeConfigurer { ...@@ -168,9 +168,6 @@ class SyncEngine : public ModelTypeConfigurer {
virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const = 0; virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const = 0;
// Send a message to the sync thread to persist the Directory to disk.
virtual void FlushDirectory() const = 0;
// Requests that the backend forward to the fronent any protocol events in // Requests that the backend forward to the fronent any protocol events in
// its buffer and begin forwarding automatically from now on. Repeated calls // its buffer and begin forwarding automatically from now on. Repeated calls
// to this function may result in the same events being emitted several // to this function may result in the same events being emitted several
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment