Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4880)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java

Issue 1127233008: Sync: local data verification for Android tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix threading Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b7a8e890b4cb42688b716285e7a8baf2a2303b6e..e7553109567543721c0a5f690329496fac0ad3ed 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
@@ -18,6 +18,8 @@ import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
import org.chromium.sync.internal_api.pub.PassphraseType;
import org.chromium.sync.internal_api.pub.base.ModelType;
+import org.json.JSONArray;
+import org.json.JSONException;
import java.util.HashSet;
import java.util.Iterator;
@@ -48,6 +50,30 @@ public class ProfileSyncService {
public void syncStateChanged();
}
+ /**
+ * Callback for getAllNodes.
+ */
+ public static class GetAllNodesCallback {
+ private String mNodesString;
+ private boolean mHasResult = false;
+
+ // Invoked when getAllNodes completes.
+ public void onResult(String nodesString) {
+ mNodesString = nodesString;
+ mHasResult = true;
+ }
+
+ // Whether this callback contains a result.
+ public boolean hasResult() {
+ return mHasResult;
+ }
+
+ // Returns the result of GetAllNodes as a JSONArray.
+ public JSONArray getNodesAsJsonArray() throws JSONException {
+ return new JSONArray(mNodesString);
+ }
+ }
+
private static final String TAG = "ProfileSyncService";
@VisibleForTesting
@@ -586,6 +612,22 @@ public class ProfileSyncService {
prompted);
}
+ /**
+ * Invokes the onResult method of the callback from native code.
+ */
+ @CalledByNative
+ private static void onGetAllNodesResult(GetAllNodesCallback callback, String nodes) {
+ callback.onResult(nodes);
+ }
+
+ /**
+ * Retrieves a JSON version of local Sync data via the native GetAllNodes method.
+ * This method is asynchronous; the result will be sent to the callback.
+ */
+ public void getAllNodes(GetAllNodesCallback callback) {
+ nativeGetAllNodes(mNativeProfileSyncServiceAndroid, callback);
+ }
+
// Native methods
private native long nativeInit();
private native void nativeEnableSync(long nativeProfileSyncServiceAndroid);
@@ -641,4 +683,6 @@ public class ProfileSyncService {
private native long nativeGetLastSyncedTimeForTest(long nativeProfileSyncServiceAndroid);
private native void nativeOverrideNetworkResourcesForTest(
long nativeProfileSyncServiceAndroid, long networkResources);
+ private native void nativeGetAllNodes(
+ long nativeProfileSyncServiceAndroid, GetAllNodesCallback callback);
}
« no previous file with comments | « no previous file | chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698