Index: chrome/browser/sync/profile_sync_service_android.cc |
diff --git a/chrome/browser/sync/profile_sync_service_android.cc b/chrome/browser/sync/profile_sync_service_android.cc |
index d8e536e1c8f8ca7187e84d91d7a38cfd3c8e5591..3cc460c8481ad6349000e9601acd79af7775199b 100644 |
--- a/chrome/browser/sync/profile_sync_service_android.cc |
+++ b/chrome/browser/sync/profile_sync_service_android.cc |
@@ -68,6 +68,26 @@ enum ModelTypeSelection { |
AUTOFILL_WALLET = 1 << 15, |
}; |
+// Native callback for the JNI GetAllNodes method. When |
+// ProfileSyncService::GetAllNodes completes, this method is called and the |
+// results are sent to the Java callback. |
+void NativeGetAllNodesCallback( |
+ const base::android::ScopedJavaGlobalRef<jobject>& callback, |
+ scoped_ptr<base::ListValue> result) { |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ std::string json_string; |
+ if (!result.get() || !base::JSONWriter::Write(*result, &json_string)) { |
+ DVLOG(1) << "Writing as JSON failed. Passing empty string to Java code."; |
+ json_string = std::string(); |
+ } |
+ |
+ ScopedJavaLocalRef<jstring> java_json_string = |
+ ConvertUTF8ToJavaString(env, json_string); |
+ Java_ProfileSyncService_onGetAllNodesResult(env, |
+ callback.obj(), |
+ java_json_string.obj()); |
+} |
+ |
} // namespace |
ProfileSyncServiceAndroid::ProfileSyncServiceAndroid(JNIEnv* env, jobject obj) |
@@ -188,6 +208,17 @@ ScopedJavaLocalRef<jstring> ProfileSyncServiceAndroid::QuerySyncStatusSummary( |
return ConvertUTF8ToJavaString(env, status); |
} |
+void ProfileSyncServiceAndroid::GetAllNodes(JNIEnv* env, |
+ jobject obj, |
+ jobject callback) { |
+ base::android::ScopedJavaGlobalRef<jobject> java_callback; |
+ java_callback.Reset(env, callback); |
+ |
+ base::Callback<void(scoped_ptr<base::ListValue>)> native_callback = |
+ base::Bind(&NativeGetAllNodesCallback, java_callback); |
+ sync_service_->GetAllNodes(native_callback); |
+} |
+ |
jboolean ProfileSyncServiceAndroid::SetSyncSessionsId( |
JNIEnv* env, jobject obj, jstring tag) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |