Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/password_manager/core/browser/login_database.h" | 5 #include "components/password_manager/core/browser/login_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 return false; | 304 return false; |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 return true; | 307 return true; |
| 308 } | 308 } |
| 309 | 309 |
| 310 void LoginDatabase::ReportMetrics(const std::string& sync_username, | 310 void LoginDatabase::ReportMetrics(const std::string& sync_username, |
| 311 bool custom_passphrase_sync_enabled) { | 311 bool custom_passphrase_sync_enabled) { |
| 312 sql::Statement s(db_.GetCachedStatement( | 312 sql::Statement s(db_.GetCachedStatement( |
| 313 SQL_FROM_HERE, | 313 SQL_FROM_HERE, |
| 314 "SELECT signon_realm, blacklisted_by_user, COUNT(username_value) " | 314 "SELECT signon_realm, password_type, blacklisted_by_user," |
| 315 "FROM logins GROUP BY signon_realm, blacklisted_by_user")); | 315 "COUNT(username_value) FROM logins GROUP BY " |
| 316 "signon_realm, password_type, blacklisted_by_user")); | |
| 316 | 317 |
| 317 if (!s.is_valid()) | 318 if (!s.is_valid()) |
| 318 return; | 319 return; |
| 319 | 320 |
| 320 std::string custom_passphrase = "WithoutCustomPassphrase"; | 321 std::string custom_passphrase = "WithoutCustomPassphrase"; |
| 321 if (custom_passphrase_sync_enabled) { | 322 if (custom_passphrase_sync_enabled) { |
| 322 custom_passphrase = "WithCustomPassphrase"; | 323 custom_passphrase = "WithCustomPassphrase"; |
| 323 } | 324 } |
| 324 | 325 |
| 325 int total_accounts = 0; | 326 int total_accounts = 0; |
|
Ilya Sherman
2014/11/13 01:54:53
Perhaps this should be renamed to something like "
Garrett Casto
2014/11/18 22:30:24
Done.
| |
| 327 int total_generated_accounts = 0; | |
| 326 int blacklisted_sites = 0; | 328 int blacklisted_sites = 0; |
| 327 while (s.Step()) { | 329 while (s.Step()) { |
| 328 int blacklisted = s.ColumnInt(1); | 330 PasswordForm::Type password_type = |
| 329 int accounts_per_site = s.ColumnInt(2); | 331 static_cast<PasswordForm::Type>(s.ColumnInt(1)); |
| 332 int blacklisted = s.ColumnInt(2); | |
| 333 int accounts_per_site = s.ColumnInt(3); | |
| 330 if (blacklisted) { | 334 if (blacklisted) { |
| 331 ++blacklisted_sites; | 335 ++blacklisted_sites; |
| 336 } else if (password_type == PasswordForm::TYPE_GENERATED) { | |
| 337 total_generated_accounts += accounts_per_site; | |
| 338 LogAccountStat( | |
| 339 base::StringPrintf("PasswordManager.AccountsPerSite.AutoGenerated.%s", | |
| 340 custom_passphrase.c_str()), | |
| 341 accounts_per_site); | |
| 332 } else { | 342 } else { |
| 333 total_accounts += accounts_per_site; | 343 total_accounts += accounts_per_site; |
| 334 LogAccountStat(base::StringPrintf("PasswordManager.AccountsPerSite.%s", | 344 LogAccountStat( |
| 335 custom_passphrase.c_str()), | 345 base::StringPrintf("PasswordManager.AccountsPerSite.UserCreated.%s", |
| 336 accounts_per_site); | 346 custom_passphrase.c_str()), |
| 347 accounts_per_site); | |
| 337 } | 348 } |
| 338 } | 349 } |
| 339 LogAccountStat(base::StringPrintf("PasswordManager.TotalAccounts.%s", | 350 LogAccountStat( |
| 340 custom_passphrase.c_str()), | 351 base::StringPrintf("PasswordManager.TotalAccounts.UserCreated.%s", |
| 341 total_accounts); | 352 custom_passphrase.c_str()), |
| 353 total_accounts); | |
| 354 LogAccountStat( | |
| 355 base::StringPrintf("PasswordManager.TotalAccounts.AutoGenerated.%s", | |
| 356 custom_passphrase.c_str()), | |
| 357 total_generated_accounts); | |
| 342 LogAccountStat(base::StringPrintf("PasswordManager.BlacklistedSites.%s", | 358 LogAccountStat(base::StringPrintf("PasswordManager.BlacklistedSites.%s", |
| 343 custom_passphrase.c_str()), | 359 custom_passphrase.c_str()), |
| 344 blacklisted_sites); | 360 blacklisted_sites); |
| 345 | 361 |
| 346 sql::Statement usage_statement(db_.GetCachedStatement( | 362 sql::Statement usage_statement(db_.GetCachedStatement( |
| 347 SQL_FROM_HERE, | 363 SQL_FROM_HERE, |
| 348 "SELECT password_type, times_used FROM logins")); | 364 "SELECT password_type, times_used FROM logins")); |
| 349 | 365 |
| 350 if (!usage_statement.is_valid()) | 366 if (!usage_statement.is_valid()) |
| 351 return; | 367 return; |
| 352 | 368 |
| 353 while (usage_statement.Step()) { | 369 while (usage_statement.Step()) { |
| 354 PasswordForm::Type type = static_cast<PasswordForm::Type>( | 370 PasswordForm::Type type = static_cast<PasswordForm::Type>( |
| 355 usage_statement.ColumnInt(0)); | 371 usage_statement.ColumnInt(0)); |
| 356 | 372 |
| 357 if (type == PasswordForm::TYPE_GENERATED) { | 373 if (type == PasswordForm::TYPE_GENERATED) { |
| 358 LogTimesUsedStat( | 374 LogTimesUsedStat(base::StringPrintf( |
| 359 base::StringPrintf("PasswordManager.TimesGeneratedPasswordUsed.%s", | 375 "PasswordManager.TimesPasswordUsed.AutoGenerated.%s", |
| 360 custom_passphrase.c_str()), | 376 custom_passphrase.c_str()), |
| 361 usage_statement.ColumnInt(1)); | 377 usage_statement.ColumnInt(1)); |
| 362 } else { | 378 } else { |
| 363 LogTimesUsedStat( | 379 LogTimesUsedStat( |
| 364 base::StringPrintf("PasswordManager.TimesPasswordUsed.%s", | 380 base::StringPrintf("PasswordManager.TimesPasswordUsed.UserCreated.%s", |
| 365 custom_passphrase.c_str()), | 381 custom_passphrase.c_str()), |
| 366 usage_statement.ColumnInt(1)); | 382 usage_statement.ColumnInt(1)); |
| 367 } | 383 } |
| 368 } | 384 } |
| 369 | 385 |
| 370 bool syncing_account_saved = false; | 386 bool syncing_account_saved = false; |
| 371 if (!sync_username.empty()) { | 387 if (!sync_username.empty()) { |
| 372 sql::Statement sync_statement(db_.GetCachedStatement( | 388 sql::Statement sync_statement(db_.GetCachedStatement( |
| 373 SQL_FROM_HERE, | 389 SQL_FROM_HERE, |
| 374 "SELECT username_value FROM logins " | 390 "SELECT username_value FROM logins " |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 | 817 |
| 802 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 818 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
| 803 DCHECK(db_.is_open()); | 819 DCHECK(db_.is_open()); |
| 804 meta_table_.Reset(); | 820 meta_table_.Reset(); |
| 805 db_.Close(); | 821 db_.Close(); |
| 806 sql::Connection::Delete(db_path_); | 822 sql::Connection::Delete(db_path_); |
| 807 return Init(db_path_); | 823 return Init(db_path_); |
| 808 } | 824 } |
| 809 | 825 |
| 810 } // namespace password_manager | 826 } // namespace password_manager |
| OLD | NEW |