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

Unified Diff: chrome/browser/password_manager/password_store_mac.cc

Issue 23477015: [sync] Significantly speed up password model association on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/password_store_mac.cc
diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc
index 74456e0a14452e354e109009a7b5377a6f7019ef..b25962d571fd095a50cd9b4ba8aeb4ae62ec73e3 100644
--- a/chrome/browser/password_manager/password_store_mac.cc
+++ b/chrome/browser/password_manager/password_store_mac.cc
@@ -446,14 +446,31 @@ void MergePasswordForms(std::vector<PasswordForm*>* keychain_forms,
std::vector<PasswordForm*> GetPasswordsForForms(
const AppleKeychain& keychain,
std::vector<PasswordForm*>* database_forms) {
+ // We load all passwords added to the keychain by Chrome at the start, instead
stuartmorgan 2013/08/29 20:24:23 This comment is incorrect. You aren't loading all
Raghu Simha 2013/08/29 23:28:46 You are correct. I only stepped through one level
+ // of individually searching through the keychain for passwords matching each
+ // form in |database_forms|. This will result in a significant performance
+ // gain, since we are replacing O(N) keychain search operations with a single
+ // operation that loads all of Chrome's passwords. See crbug.com/263685.
MacKeychainPasswordFormAdapter keychain_adapter(&keychain);
+ std::vector<PasswordForm*> keychain_forms =
+ keychain_adapter.GetAllPasswordFormPasswords();
std::vector<PasswordForm*> merged_forms;
for (std::vector<PasswordForm*>::iterator i = database_forms->begin();
i != database_forms->end();) {
std::vector<PasswordForm*> db_form_container(1, *i);
- std::vector<PasswordForm*> keychain_matches =
- keychain_adapter.PasswordsMergeableWithForm(**i);
+ std::vector<PasswordForm*> keychain_matches;
+ for (std::vector<PasswordForm*>::iterator j = keychain_forms.begin();
+ j != keychain_forms.end(); ++j) {
+ if ((*i)->username_value == (*j)->username_value &&
+ (*i)->scheme == (*j)->scheme &&
+ GURL((*i)->signon_realm) == GURL((*j)->signon_realm)) {
+ // Create a new object, since the caller is responsible for deleting the
+ // returned forms.
+ PasswordForm* form = new PasswordForm(**j);
+ keychain_matches.push_back(form);
+ }
+ }
MergePasswordForms(&keychain_matches, &db_form_container, &merged_forms);
if (db_form_container.empty()) {
i = database_forms->erase(i);
@@ -462,6 +479,7 @@ std::vector<PasswordForm*> GetPasswordsForForms(
}
STLDeleteElements(&keychain_matches);
}
+ STLDeleteElements(&keychain_forms);
return merged_forms;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698