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

Side by Side Diff: chrome/browser/password_manager/login_database.cc

Issue 2834009: Implement Password Manager aggregate metrics reporting (Closed)
Patch Set: rebase to head Created 10 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/password_manager/login_database.h" 5 #include "chrome/browser/password_manager/login_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "app/sql/statement.h" 10 #include "app/sql/statement.h"
11 #include "app/sql/transaction.h" 11 #include "app/sql/transaction.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/histogram.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "chrome/common/sqlite_utils.h" 17 #include "chrome/common/sqlite_utils.h"
17 18
18 using webkit_glue::PasswordForm; 19 using webkit_glue::PasswordForm;
19 20
20 static const int kCurrentVersionNumber = 1; 21 static const int kCurrentVersionNumber = 1;
21 static const int kCompatibleVersionNumber = 1; 22 static const int kCompatibleVersionNumber = 1;
22 23
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 120 }
120 if (!db_.Execute("CREATE INDEX logins_signon ON " 121 if (!db_.Execute("CREATE INDEX logins_signon ON "
121 "logins (signon_realm)")) { 122 "logins (signon_realm)")) {
122 NOTREACHED(); 123 NOTREACHED();
123 return false; 124 return false;
124 } 125 }
125 } 126 }
126 return true; 127 return true;
127 } 128 }
128 129
130 void LoginDatabase::ReportMetrics() {
131 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE,
132 "SELECT signon_realm, COUNT(username_value) FROM logins "
133 "GROUP BY signon_realm"));
134 if (!s) {
135 NOTREACHED() << "Statement prepare failed";
136 return;
137 }
138
139 int total_accounts = 0;
140 while (s.Step()) {
141 int accounts_per_site = s.ColumnInt(1);
142 total_accounts += accounts_per_site;
143 UMA_HISTOGRAM_CUSTOM_COUNTS("PasswordManager.AccountsPerSite",
144 accounts_per_site, 0, 32, 6);
145 }
146 UMA_HISTOGRAM_CUSTOM_COUNTS("PasswordManager.TotalAccounts",
147 total_accounts, 0, 32, 6);
148
149 return;
150 }
129 151
130 bool LoginDatabase::AddLogin(const PasswordForm& form) { 152 bool LoginDatabase::AddLogin(const PasswordForm& form) {
131 // You *must* change LoginTableColumns if this query changes. 153 // You *must* change LoginTableColumns if this query changes.
132 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, 154 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE,
133 "INSERT OR REPLACE INTO logins " 155 "INSERT OR REPLACE INTO logins "
134 "(origin_url, action_url, username_element, username_value, " 156 "(origin_url, action_url, username_element, username_value, "
135 " password_element, password_value, submit_element, " 157 " password_element, password_value, submit_element, "
136 " signon_realm, ssl_valid, preferred, date_created, " 158 " signon_realm, ssl_valid, preferred, date_created, "
137 " blacklisted_by_user, scheme) " 159 " blacklisted_by_user, scheme) "
138 "VALUES " 160 "VALUES "
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 s.BindInt(0, blacklisted ? 1 : 0); 383 s.BindInt(0, blacklisted ? 1 : 0);
362 384
363 while (s.Step()) { 385 while (s.Step()) {
364 PasswordForm* new_form = new PasswordForm(); 386 PasswordForm* new_form = new PasswordForm();
365 InitPasswordFormFromStatement(new_form, s); 387 InitPasswordFormFromStatement(new_form, s);
366 388
367 forms->push_back(new_form); 389 forms->push_back(new_form);
368 } 390 }
369 return s.Succeeded(); 391 return s.Succeeded();
370 } 392 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/login_database.h ('k') | chrome/browser/password_manager/password_store_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698