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

Unified Diff: chrome/browser/signin/oauth2_token_service_delegate_android.cc

Issue 1715683002: chrome: Use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per latest code Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/oauth2_token_service_delegate_android.cc
diff --git a/chrome/browser/signin/oauth2_token_service_delegate_android.cc b/chrome/browser/signin/oauth2_token_service_delegate_android.cc
index fac9e00caa6d5e389e44997c99739f9da0e9eaac..a656f51173474d14131ea458e910158eedb624c7 100644
--- a/chrome/browser/signin/oauth2_token_service_delegate_android.cc
+++ b/chrome/browser/signin/oauth2_token_service_delegate_android.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_android.h"
@@ -361,8 +362,7 @@ void OAuth2TokenServiceDelegateAndroid::ValidateAccounts(
std::vector<AccountInfo> accounts_info =
account_tracker_service_->GetAccounts();
for (const AccountInfo& info : accounts_info) {
- if (std::find(curr_ids.begin(), curr_ids.end(), info.account_id) ==
- curr_ids.end())
+ if (!ContainsValue(curr_ids, info.account_id))
account_tracker_service_->RemoveAccount(info.account_id);
}
@@ -381,15 +381,13 @@ bool OAuth2TokenServiceDelegateAndroid::ValidateAccounts(
std::vector<std::string>* refreshed_ids,
std::vector<std::string>* revoked_ids,
bool force_notifications) {
- bool currently_signed_in = std::find(curr_ids.begin(), curr_ids.end(),
- signed_in_id) != curr_ids.end();
+ bool currently_signed_in = ContainsValue(curr_ids, signed_in_id);
if (currently_signed_in) {
// Revoke token for ids that have been removed from the device.
for (const std::string& prev_id : prev_ids) {
if (prev_id == signed_in_id)
continue;
- if (std::find(curr_ids.begin(), curr_ids.end(), prev_id) ==
- curr_ids.end()) {
+ if (!ContainsValue(curr_ids, prev_id)) {
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ValidateAccounts:"
<< "revoked=" << prev_id;
revoked_ids->push_back(prev_id);
@@ -398,8 +396,7 @@ bool OAuth2TokenServiceDelegateAndroid::ValidateAccounts(
// Refresh token for new ids or all ids if |force_notifications|.
if (force_notifications ||
- std::find(prev_ids.begin(), prev_ids.end(), signed_in_id) ==
- prev_ids.end()) {
+ !ContainsValue(prev_ids, signed_in_id)) {
// Always fire the primary signed in account first.
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ValidateAccounts:"
<< "refreshed=" << signed_in_id;
@@ -409,16 +406,14 @@ bool OAuth2TokenServiceDelegateAndroid::ValidateAccounts(
if (curr_id == signed_in_id)
continue;
if (force_notifications ||
- std::find(prev_ids.begin(), prev_ids.end(), curr_id) ==
- prev_ids.end()) {
+ !ContainsValue(prev_ids, curr_id)) {
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ValidateAccounts:"
<< "refreshed=" << curr_id;
refreshed_ids->push_back(curr_id);
}
}
} else {
- if (std::find(prev_ids.begin(), prev_ids.end(), signed_in_id) !=
- prev_ids.end()) {
+ if (ContainsValue(prev_ids, signed_in_id)) {
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ValidateAccounts:"
<< "revoked=" << signed_in_id;
revoked_ids->push_back(signed_in_id);

Powered by Google App Engine
This is Rietveld 408576698