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

Side by Side Diff: chrome/browser/android/signin/account_tracker_service_android.cc

Issue 1405353002: [Android] Replace a synchronous callsite of GetAccounts() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/signin/account_tracker_service_android.h" 5 #include "chrome/browser/android/signin/account_tracker_service_android.h"
6 6
7 #include "base/android/jni_array.h" 7 #include "base/android/jni_array.h"
8 #include "chrome/browser/profiles/profile_manager.h" 8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/signin/account_tracker_service_factory.h" 9 #include "chrome/browser/signin/account_tracker_service_factory.h"
10 #include "components/signin/core/browser/account_info.h" 10 #include "components/signin/core/browser/account_tracker_service.h"
11 #include "jni/AccountTrackerService_jni.h" 11 #include "jni/AccountTrackerService_jni.h"
12 12
13 AccountTrackerServiceAndroid::AccountTrackerServiceAndroid(JNIEnv* env, 13 namespace signin {
14 jobject obj) { 14 namespace android {
15 java_account_tracker_service_.Reset(env, obj);
16 }
17 15
18 void AccountTrackerServiceAndroid::SeedAccountsInfo(JNIEnv* env, 16 void SeedAccountsInfo(JNIEnv* env,
19 jobject obj, 17 const JavaParamRef<jclass>& jcaller,
20 jobjectArray gaiaIds, 18 const JavaParamRef<jobjectArray>& gaiaIds,
21 jobjectArray accountNames) { 19 const JavaParamRef<jobjectArray>& accountNames) {
22 std::vector<std::string> gaia_ids; 20 std::vector<std::string> gaia_ids;
23 std::vector<std::string> account_names; 21 std::vector<std::string> account_names;
24 base::android::AppendJavaStringArrayToStringVector(env, gaiaIds, &gaia_ids); 22 base::android::AppendJavaStringArrayToStringVector(env, gaiaIds, &gaia_ids);
25 base::android::AppendJavaStringArrayToStringVector(env, accountNames, 23 base::android::AppendJavaStringArrayToStringVector(env, accountNames,
26 &account_names); 24 &account_names);
27 DCHECK_EQ(gaia_ids.size(), account_names.size()); 25 DCHECK_EQ(gaia_ids.size(), account_names.size());
28 26
29 DVLOG(1) << "AccountTrackerServiceAndroid::SeedAccountsInfo: " 27 DVLOG(1) << "AccountTrackerServiceAndroid::SeedAccountsInfo: "
30 << " number of accounts " << gaia_ids.size(); 28 << " number of accounts " << gaia_ids.size();
31 Profile* profile = ProfileManager::GetActiveUserProfile(); 29 Profile* profile = ProfileManager::GetActiveUserProfile();
32 AccountTrackerService* account_tracker_service_ = 30 AccountTrackerService* account_tracker_service_ =
33 AccountTrackerServiceFactory::GetForProfile(profile); 31 AccountTrackerServiceFactory::GetForProfile(profile);
34 32
35 for (unsigned int i = 0; i < gaia_ids.size(); i++) { 33 for (size_t i = 0; i < gaia_ids.size(); i++) {
36 account_tracker_service_->SeedAccountInfo(gaia_ids[i], account_names[i]); 34 account_tracker_service_->SeedAccountInfo(gaia_ids[i], account_names[i]);
Roger Tawa OOO till Jul 10th 2015/10/16 17:49:02 Remove trailing _
37 } 35 }
38 } 36 }
39 37
40 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 38 bool RegisterAccountTrackerService(JNIEnv* env) {
41 AccountTrackerServiceAndroid* account_tracker_service_android = 39 return RegisterNativesImpl(env);
42 new AccountTrackerServiceAndroid(env, obj);
43 return reinterpret_cast<intptr_t>(account_tracker_service_android);
44 } 40 }
45 41
46 // static 42 } // namespace android
47 bool AccountTrackerServiceAndroid::Register(JNIEnv* env) { 43 } // namespace signin
48 return RegisterNativesImpl(env);
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698