Chromium Code Reviews| 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 59d44f7c8c2986110ba4672df9b8b58a7caf3462..be05ec5e0480add06493c4a4e9117fe244771592 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 (!base::JSONWriter::Write(result.get(), &json_string)) { |
|
Nicolas Zea
2015/05/15 20:09:22
Check for a null scoped ptr as well?
pval...(no longer on Chromium)
2015/05/19 01:38:22
Done. Note: I had to rebase and then do this as th
|
| + 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); |