| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/profile_sync_service_android.h" | 5 #include "chrome/browser/sync/profile_sync_service_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "google_apis/gaia/google_service_auth_error.h" | 41 #include "google_apis/gaia/google_service_auth_error.h" |
| 42 #include "jni/ProfileSyncService_jni.h" | 42 #include "jni/ProfileSyncService_jni.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 44 | 44 |
| 45 using base::android::AttachCurrentThread; | 45 using base::android::AttachCurrentThread; |
| 46 using base::android::CheckException; | 46 using base::android::CheckException; |
| 47 using base::android::ConvertJavaStringToUTF8; | 47 using base::android::ConvertJavaStringToUTF8; |
| 48 using base::android::ConvertUTF8ToJavaString; | 48 using base::android::ConvertUTF8ToJavaString; |
| 49 using base::android::JavaParamRef; | 49 using base::android::JavaParamRef; |
| 50 using base::android::ScopedJavaLocalRef; | 50 using base::android::ScopedJavaLocalRef; |
| 51 using browser_sync::ProfileSyncService; |
| 51 using content::BrowserThread; | 52 using content::BrowserThread; |
| 52 | 53 |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 // Native callback for the JNI GetAllNodes method. When | 56 // Native callback for the JNI GetAllNodes method. When |
| 56 // ProfileSyncService::GetAllNodes completes, this method is called and the | 57 // ProfileSyncService::GetAllNodes completes, this method is called and the |
| 57 // results are sent to the Java callback. | 58 // results are sent to the Java callback. |
| 58 void NativeGetAllNodesCallback( | 59 void NativeGetAllNodesCallback( |
| 59 const base::android::ScopedJavaGlobalRef<jobject>& callback, | 60 const base::android::ScopedJavaGlobalRef<jobject>& callback, |
| 60 std::unique_ptr<base::ListValue> result) { | 61 std::unique_ptr<base::ListValue> result) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 std::vector<int> type_vector; | 77 std::vector<int> type_vector; |
| 77 for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { | 78 for (syncer::ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { |
| 78 type_vector.push_back(it.Get()); | 79 type_vector.push_back(it.Get()); |
| 79 } | 80 } |
| 80 return base::android::ToJavaIntArray(env, type_vector); | 81 return base::android::ToJavaIntArray(env, type_vector); |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace | 84 } // namespace |
| 84 | 85 |
| 85 ProfileSyncServiceAndroid::ProfileSyncServiceAndroid(JNIEnv* env, jobject obj) | 86 ProfileSyncServiceAndroid::ProfileSyncServiceAndroid(JNIEnv* env, jobject obj) |
| 86 : profile_(NULL), | 87 : profile_(nullptr), |
| 87 sync_service_(NULL), | 88 sync_service_(nullptr), |
| 88 weak_java_profile_sync_service_(env, obj) { | 89 weak_java_profile_sync_service_(env, obj) { |
| 89 if (g_browser_process == NULL || | 90 if (g_browser_process == nullptr || |
| 90 g_browser_process->profile_manager() == NULL) { | 91 g_browser_process->profile_manager() == nullptr) { |
| 91 NOTREACHED() << "Browser process or profile manager not initialized"; | 92 NOTREACHED() << "Browser process or profile manager not initialized"; |
| 92 return; | 93 return; |
| 93 } | 94 } |
| 94 | 95 |
| 95 profile_ = ProfileManager::GetActiveUserProfile(); | 96 profile_ = ProfileManager::GetActiveUserProfile(); |
| 96 if (profile_ == NULL) { | 97 if (profile_ == nullptr) { |
| 97 NOTREACHED() << "Sync Init: Profile not found."; | 98 NOTREACHED() << "Sync Init: Profile not found."; |
| 98 return; | 99 return; |
| 99 } | 100 } |
| 100 | 101 |
| 101 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); | 102 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); |
| 102 | 103 |
| 103 sync_service_ = | 104 sync_service_ = |
| 104 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 105 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
| 105 } | 106 } |
| 106 | 107 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 514 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 514 ProfileSyncServiceAndroid* profile_sync_service_android = | 515 ProfileSyncServiceAndroid* profile_sync_service_android = |
| 515 new ProfileSyncServiceAndroid(env, obj); | 516 new ProfileSyncServiceAndroid(env, obj); |
| 516 if (profile_sync_service_android->Init()) { | 517 if (profile_sync_service_android->Init()) { |
| 517 return reinterpret_cast<intptr_t>(profile_sync_service_android); | 518 return reinterpret_cast<intptr_t>(profile_sync_service_android); |
| 518 } else { | 519 } else { |
| 519 delete profile_sync_service_android; | 520 delete profile_sync_service_android; |
| 520 return 0; | 521 return 0; |
| 521 } | 522 } |
| 522 } | 523 } |
| OLD | NEW |