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

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

Issue 1267843003: Fix reconcilor loop when the primary account is in an auth error state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 4 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 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/oauth2_token_service_delegate_android.h" 5 #include "chrome/browser/signin/oauth2_token_service_delegate_android.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 scope += " "; 124 scope += " ";
125 scope += *it; 125 scope += *it;
126 } 126 }
127 return scope; 127 return scope;
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 bool OAuth2TokenServiceDelegateAndroid::is_testing_profile_ = false; 132 bool OAuth2TokenServiceDelegateAndroid::is_testing_profile_ = false;
133 133
134 OAuth2TokenServiceDelegateAndroid::ErrorInfo::ErrorInfo()
135 : error(GoogleServiceAuthError::NONE) {}
136
137 OAuth2TokenServiceDelegateAndroid::ErrorInfo::ErrorInfo(
138 const GoogleServiceAuthError& error)
139 : error(error) {}
140
134 OAuth2TokenServiceDelegateAndroid::OAuth2TokenServiceDelegateAndroid() { 141 OAuth2TokenServiceDelegateAndroid::OAuth2TokenServiceDelegateAndroid() {
135 DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ctor"; 142 DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ctor";
136 JNIEnv* env = AttachCurrentThread(); 143 JNIEnv* env = AttachCurrentThread();
137 base::android::ScopedJavaLocalRef<jobject> local_java_ref = 144 base::android::ScopedJavaLocalRef<jobject> local_java_ref =
138 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this)); 145 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this));
139 java_ref_.Reset(env, local_java_ref.obj()); 146 java_ref_.Reset(env, local_java_ref.obj());
140 } 147 }
141 148
142 OAuth2TokenServiceDelegateAndroid::~OAuth2TokenServiceDelegateAndroid() { 149 OAuth2TokenServiceDelegateAndroid::~OAuth2TokenServiceDelegateAndroid() {
143 } 150 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const std::string& account_id) const { 182 const std::string& account_id) const {
176 JNIEnv* env = AttachCurrentThread(); 183 JNIEnv* env = AttachCurrentThread();
177 ScopedJavaLocalRef<jstring> j_account_id = 184 ScopedJavaLocalRef<jstring> j_account_id =
178 ConvertUTF8ToJavaString(env, account_id); 185 ConvertUTF8ToJavaString(env, account_id);
179 jboolean refresh_token_is_available = 186 jboolean refresh_token_is_available =
180 Java_OAuth2TokenService_hasOAuth2RefreshToken( 187 Java_OAuth2TokenService_hasOAuth2RefreshToken(
181 env, base::android::GetApplicationContext(), j_account_id.obj()); 188 env, base::android::GetApplicationContext(), j_account_id.obj());
182 return refresh_token_is_available == JNI_TRUE; 189 return refresh_token_is_available == JNI_TRUE;
183 } 190 }
184 191
192 bool OAuth2TokenServiceDelegateAndroid::RefreshTokenHasError(
193 const std::string& account_id) const {
194 auto it = errors_.find(account_id);
195 // TODO(rogerta): should we distinguish between transient and persistent?
196 return it == errors_.end()
197 ? false
198 : it->second.error.state() != GoogleServiceAuthError::NONE;
anthonyvd 2015/08/11 15:43:10 Any way to put at least part of this in the base c
Roger Tawa OOO till Jul 10th 2015/08/11 16:25:25 Done.
199 }
200
185 void OAuth2TokenServiceDelegateAndroid::UpdateAuthError( 201 void OAuth2TokenServiceDelegateAndroid::UpdateAuthError(
186 const std::string& account_id, 202 const std::string& account_id,
187 const GoogleServiceAuthError& error) { 203 const GoogleServiceAuthError& error) {
188 // TODO(rogerta): do we need to update anything, or does the system handle it? 204 if (error.state() == GoogleServiceAuthError::NONE) {
205 errors_.erase(account_id);
206 } else {
207 // TODO(rogerta): should we distinguish between transient and persistent?
208 errors_[account_id] = ErrorInfo(error);
209 }
189 } 210 }
190 211
191 std::vector<std::string> OAuth2TokenServiceDelegateAndroid::GetAccounts() { 212 std::vector<std::string> OAuth2TokenServiceDelegateAndroid::GetAccounts() {
192 std::vector<std::string> accounts; 213 std::vector<std::string> accounts;
193 JNIEnv* env = AttachCurrentThread(); 214 JNIEnv* env = AttachCurrentThread();
194 ScopedJavaLocalRef<jobjectArray> j_accounts = 215 ScopedJavaLocalRef<jobjectArray> j_accounts =
195 Java_OAuth2TokenService_getAccounts( 216 Java_OAuth2TokenService_getAccounts(
196 env, base::android::GetApplicationContext()); 217 env, base::android::GetApplicationContext());
197 // TODO(fgorski): We may decide to filter out some of the accounts. 218 // TODO(fgorski): We may decide to filter out some of the accounts.
198 base::android::AppendJavaStringArrayToStringVector(env, j_accounts.obj(), 219 base::android::AppendJavaStringArrayToStringVector(env, j_accounts.obj(),
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 GoogleServiceAuthError err(authToken 469 GoogleServiceAuthError err(authToken
449 ? GoogleServiceAuthError::NONE 470 ? GoogleServiceAuthError::NONE
450 : GoogleServiceAuthError::CONNECTION_FAILED); 471 : GoogleServiceAuthError::CONNECTION_FAILED);
451 heap_callback->Run(err, token, base::Time()); 472 heap_callback->Run(err, token, base::Time());
452 } 473 }
453 474
454 // static 475 // static
455 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) { 476 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) {
456 return RegisterNativesImpl(env); 477 return RegisterNativesImpl(env);
457 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698