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..364b19b4c2f45875919087daefe25963284176e2 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,8 @@ bool LoginDatabase::InitLoginsTable() { |
return true; |
} |
-void LoginDatabase::ReportMetrics() { |
+void LoginDatabase::ReportMetrics(const std::string& sync_username, |
+ enum password_manager::SyncState sync_state) { |
Ilya Sherman
2014/06/27 19:37:51
nit: I don't think you need the "enum" keyword her
Garrett Casto
2014/06/27 21:07:34
Done.
|
sql::Statement s(db_.GetCachedStatement( |
SQL_FROM_HERE, |
"SELECT signon_realm, blacklisted_by_user, COUNT(username_value) " |
@@ -302,6 +305,51 @@ void LoginDatabase::ReportMetrics() { |
usage_statement.ColumnInt(1), 0, 100, 10); |
} |
} |
+ |
+ bool syncing_account_saved = false; |
+ int times_syncing_account_used = 0; |
+ if (!sync_username.empty()) { |
+ sql::Statement sync_statement(db_.GetCachedStatement( |
+ SQL_FROM_HERE, |
+ "SELECT username_value, times_used 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); |
+ // It's possible to have multiple stored credentials that all reference |
+ // the same account (different spelling of the same name or different |
+ // URL). |
+ if (gaia::AreEmailsSame(sync_username, username)) { |
+ syncing_account_saved = true; |
+ times_syncing_account_used += sync_statement.ColumnInt(1); |
+ } |
+ } |
+ } |
+ UMA_HISTOGRAM_ENUMERATION("PasswordManager.SyncingAccountState", |
+ 2 * sync_state + syncing_account_saved, |
+ 2 * password_manager::NUM_SYNC_STATES); |
+ |
+ if (syncing_account_saved) { |
+ switch (sync_state) { |
+ case password_manager::PASSWORD_SYNC_ENABLED: |
+ UMA_HISTOGRAM_COUNTS_100( |
+ "PasswordManager.PasswordSyncAccountTimesUsed", |
+ times_syncing_account_used); |
+ break; |
+ case password_manager::PASSWORD_SYNC_DISABLED: |
+ UMA_HISTOGRAM_COUNTS_100( |
+ "PasswordManager.SyncAccountTimesUsed", |
+ times_syncing_account_used); |
+ break; |
+ default: |
Ilya Sherman
2014/06/27 19:37:51
Optional nit: I generally prefer to enumerate all
Garrett Casto
2014/06/27 21:07:34
Done.
|
+ NOTREACHED(); |
+ } |
+ } |
} |
PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) { |