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

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, 8 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 5397c93abf64254cdf6bfb79eb57af9213734af5..5d8f0f811c3b080115e4da4a37b9ebccef558053 100644
--- a/chrome/browser/signin/oauth2_token_service_delegate_android.cc
+++ b/chrome/browser/signin/oauth2_token_service_delegate_android.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/metrics/histogram_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"
@@ -362,8 +363,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);
}
@@ -382,15 +382,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);
@@ -399,8 +397,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;
@@ -410,16 +407,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);
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698