Chromium Code Reviews| Index: components/password_manager/core/browser/login_database.cc |
| diff --git a/components/password_manager/core/browser/login_database.cc b/components/password_manager/core/browser/login_database.cc |
| index 55cc5eca78b2e59d4c9b4130cc78a5738d7cb001..6f1fc8bc2c0d6b4f81e7ed7c46331861c5c239c8 100644 |
| --- a/components/password_manager/core/browser/login_database.cc |
| +++ b/components/password_manager/core/browser/login_database.cc |
| @@ -15,6 +15,8 @@ |
| #include "base/strings/string_util.h" |
| #include "base/time/time.h" |
| #include "components/autofill/core/common/password_form.h" |
| +#include "google_apis/gaia/gaia_auth_util.h" |
| +#include "google_apis/gaia/gaia_urls.h" |
| #include "sql/connection.h" |
| #include "sql/statement.h" |
| #include "sql/transaction.h" |
| @@ -254,7 +256,7 @@ bool LoginDatabase::InitLoginsTable() { |
| return true; |
| } |
| -void LoginDatabase::ReportMetrics() { |
| +void LoginDatabase::ReportMetrics(const std::string& sync_username) { |
| sql::Statement s(db_.GetCachedStatement( |
| SQL_FROM_HERE, |
| "SELECT signon_realm, blacklisted_by_user, COUNT(username_value) " |
| @@ -302,6 +304,30 @@ void LoginDatabase::ReportMetrics() { |
| usage_statement.ColumnInt(1), 0, 100, 10); |
| } |
| } |
| + |
| + bool syncing_account_saved = false; |
| + if (!sync_username.empty()) { |
| + sql::Statement sync_statement(db_.GetCachedStatement( |
| + SQL_FROM_HERE, |
| + "SELECT username_value FROM logins " |
| + "WHERE signon_realm == ?")); |
| + sync_statement.BindString( |
| + 0, GaiaUrls::GetInstance()->gaia_url().GetOrigin().spec()); |
| + |
| + if (!sync_statement.is_valid()) |
| + return; |
| + |
| + while (sync_statement.Step()) { |
| + std::string username = sync_statement.ColumnString(0); |
| + if (gaia::AreEmailsSame(sync_username, username)) { |
| + syncing_account_saved = true; |
| + break; |
| + } |
| + } |
| + } |
| + UMA_HISTOGRAM_ENUMERATION("PasswordManager.SyncingAccountState", |
| + 2 * sync_username.empty() + syncing_account_saved, |
|
vabr (Chromium)
2014/07/01 08:52:00
This type of boolean mixing arithmetic looks almos
Garrett Casto
2014/07/04 07:27:49
Yeah, verified this with the standard before I use
|
| + 4); |
| } |
| PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) { |