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

Side by Side Diff: chrome/browser/signin/android_profile_oauth2_token_service.cc

Issue 63253003: Fix issues with token refresh in AccountReconcilor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 7 years, 1 month 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 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/signin/android_profile_oauth2_token_service.h" 5 #include "chrome/browser/signin/android_profile_oauth2_token_service.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Notify native observers. 188 // Notify native observers.
189 OAuth2TokenService::FireRefreshTokenAvailable(account_id); 189 OAuth2TokenService::FireRefreshTokenAvailable(account_id);
190 // Notify Java observers. 190 // Notify Java observers.
191 JNIEnv* env = AttachCurrentThread(); 191 JNIEnv* env = AttachCurrentThread();
192 ScopedJavaLocalRef<jstring> account_name = 192 ScopedJavaLocalRef<jstring> account_name =
193 ConvertUTF8ToJavaString(env, account_id); 193 ConvertUTF8ToJavaString(env, account_id);
194 Java_OAuth2TokenService_notifyRefreshTokenAvailable( 194 Java_OAuth2TokenService_notifyRefreshTokenAvailable(
195 env, java_ref_.obj(), account_name.obj()); 195 env, java_ref_.obj(), account_name.obj());
196 } 196 }
197 197
198 void AndroidProfileOAuth2TokenService::FireRefreshTokenAvailable(
199 const std::deque<std::string>& account_ids) {
200 // Notify native observers.
201 OAuth2TokenService::FireRefreshTokenAvailable(account_ids);
202 // Notify Java observers.
203 JNIEnv* env = AttachCurrentThread();
204
205 for (std::deque<std::string>::const_iterator it = account_ids.begin();
206 it != account_ids.end(); it++) {
207 std::string account_id = *it;
208 ScopedJavaLocalRef<jstring> account_name =
209 ConvertUTF8ToJavaString(env, account_id);
210 Java_OAuth2TokenService_notifyRefreshTokenAvailable(
211 env, java_ref_.obj(), account_name.obj());
212 }
213 }
214
198 void AndroidProfileOAuth2TokenService::FireRefreshTokenRevokedFromJava( 215 void AndroidProfileOAuth2TokenService::FireRefreshTokenRevokedFromJava(
199 JNIEnv* env, 216 JNIEnv* env,
200 jobject obj, 217 jobject obj,
201 const jstring account_name) { 218 const jstring account_name) {
202 std::string account_id = ConvertJavaStringToUTF8(env, account_name); 219 std::string account_id = ConvertJavaStringToUTF8(env, account_name);
203 AndroidProfileOAuth2TokenService::FireRefreshTokenRevoked(account_id); 220 AndroidProfileOAuth2TokenService::FireRefreshTokenRevoked(account_id);
204 } 221 }
205 222
206 void AndroidProfileOAuth2TokenService::FireRefreshTokenRevoked( 223 void AndroidProfileOAuth2TokenService::FireRefreshTokenRevoked(
207 const std::string& account_id) { 224 const std::string& account_id) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 GoogleServiceAuthError err(result ? 261 GoogleServiceAuthError err(result ?
245 GoogleServiceAuthError::NONE : 262 GoogleServiceAuthError::NONE :
246 GoogleServiceAuthError::CONNECTION_FAILED); 263 GoogleServiceAuthError::CONNECTION_FAILED);
247 heap_callback->Run(err, token, base::Time()); 264 heap_callback->Run(err, token, base::Time());
248 } 265 }
249 266
250 // static 267 // static
251 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { 268 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) {
252 return RegisterNativesImpl(env); 269 return RegisterNativesImpl(env);
253 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698