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

Side by Side Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 2395243002: [Autofill] Log count histogram for the number of server cards (Closed)
Patch Set: addressed nits Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/core/browser/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 is_data_loaded_(false), 256 is_data_loaded_(false),
257 pending_profiles_query_(0), 257 pending_profiles_query_(0),
258 pending_server_profiles_query_(0), 258 pending_server_profiles_query_(0),
259 pending_creditcards_query_(0), 259 pending_creditcards_query_(0),
260 pending_server_creditcards_query_(0), 260 pending_server_creditcards_query_(0),
261 app_locale_(app_locale), 261 app_locale_(app_locale),
262 pref_service_(NULL), 262 pref_service_(NULL),
263 account_tracker_(NULL), 263 account_tracker_(NULL),
264 is_off_the_record_(false), 264 is_off_the_record_(false),
265 has_logged_profile_count_(false), 265 has_logged_profile_count_(false),
266 has_logged_credit_card_count_(false) {} 266 has_logged_local_credit_card_count_(false),
267 has_logged_server_credit_card_counts_(false) {}
267 268
268 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, 269 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database,
269 PrefService* pref_service, 270 PrefService* pref_service,
270 AccountTrackerService* account_tracker, 271 AccountTrackerService* account_tracker,
271 SigninManagerBase* signin_manager, 272 SigninManagerBase* signin_manager,
272 bool is_off_the_record) { 273 bool is_off_the_record) {
273 CountryNames::SetLocaleString(app_locale_); 274 CountryNames::SetLocaleString(app_locale_);
274 275
275 database_ = database; 276 database_ = database;
276 SetPrefService(pref_service); 277 SetPrefService(pref_service);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 &local_credit_cards_); 382 &local_credit_cards_);
382 LogLocalCreditCardCount(); 383 LogLocalCreditCardCount();
383 } else { 384 } else {
384 ReceiveLoadedDbValues(h, result, &pending_server_creditcards_query_, 385 ReceiveLoadedDbValues(h, result, &pending_server_creditcards_query_,
385 &server_credit_cards_); 386 &server_credit_cards_);
386 387
387 // If the user has a saved unmasked server card and the experiment is 388 // If the user has a saved unmasked server card and the experiment is
388 // disabled, force mask all cards back to the unsaved state. 389 // disabled, force mask all cards back to the unsaved state.
389 if (!OfferStoreUnmaskedCards()) 390 if (!OfferStoreUnmaskedCards())
390 ResetFullServerCards(); 391 ResetFullServerCards();
392
393 LogServerCreditCardCounts();
391 } 394 }
392 break; 395 break;
393 default: 396 default:
394 NOTREACHED(); 397 NOTREACHED();
395 } 398 }
396 399
397 // If all requests have responded, then all personal data is loaded. 400 // If all requests have responded, then all personal data is loaded.
398 if (pending_profiles_query_ == 0 && 401 if (pending_profiles_query_ == 0 &&
399 pending_creditcards_query_ == 0 && 402 pending_creditcards_query_ == 0 &&
400 pending_server_profiles_query_ == 0 && 403 pending_server_profiles_query_ == 0 &&
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 } 1280 }
1278 1281
1279 void PersonalDataManager::LogProfileCount() const { 1282 void PersonalDataManager::LogProfileCount() const {
1280 if (!has_logged_profile_count_) { 1283 if (!has_logged_profile_count_) {
1281 AutofillMetrics::LogStoredProfileCount(web_profiles_.size()); 1284 AutofillMetrics::LogStoredProfileCount(web_profiles_.size());
1282 has_logged_profile_count_ = true; 1285 has_logged_profile_count_ = true;
1283 } 1286 }
1284 } 1287 }
1285 1288
1286 void PersonalDataManager::LogLocalCreditCardCount() const { 1289 void PersonalDataManager::LogLocalCreditCardCount() const {
1287 if (!has_logged_credit_card_count_) { 1290 if (!has_logged_local_credit_card_count_) {
1288 AutofillMetrics::LogStoredLocalCreditCardCount(local_credit_cards_.size()); 1291 AutofillMetrics::LogStoredLocalCreditCardCount(local_credit_cards_.size());
1289 has_logged_credit_card_count_ = true; 1292 has_logged_local_credit_card_count_ = true;
1290 } 1293 }
1291 } 1294 }
1292 1295
1296 void PersonalDataManager::LogServerCreditCardCounts() const {
1297 if (!has_logged_server_credit_card_counts_) {
1298 size_t unmasked_cards = 0, masked_cards = 0;
1299 for (CreditCard* card : server_credit_cards_) {
1300 if (card->record_type() == CreditCard::MASKED_SERVER_CARD) {
1301 masked_cards++;
1302 } else if (card->record_type() == CreditCard::FULL_SERVER_CARD) {
1303 unmasked_cards++;
1304 }
1305 }
1306 AutofillMetrics::LogStoredServerCreditCardCounts(masked_cards,
1307 unmasked_cards);
1308 has_logged_server_credit_card_counts_ = true;
1309 }
1310 }
1311
1293 std::string PersonalDataManager::MostCommonCountryCodeFromProfiles() const { 1312 std::string PersonalDataManager::MostCommonCountryCodeFromProfiles() const {
1294 if (!IsAutofillEnabled()) 1313 if (!IsAutofillEnabled())
1295 return std::string(); 1314 return std::string();
1296 1315
1297 // Count up country codes from existing profiles. 1316 // Count up country codes from existing profiles.
1298 std::map<std::string, int> votes; 1317 std::map<std::string, int> votes;
1299 // TODO(estade): can we make this GetProfiles() instead? It seems to cause 1318 // TODO(estade): can we make this GetProfiles() instead? It seems to cause
1300 // errors in tests on mac trybots. See http://crbug.com/57221 1319 // errors in tests on mac trybots. See http://crbug.com/57221
1301 const std::vector<AutofillProfile*>& profiles = web_profiles(); 1320 const std::vector<AutofillProfile*>& profiles = web_profiles();
1302 const std::vector<std::string>& country_codes = 1321 const std::vector<std::string>& country_codes =
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 if (profile_to_merge->IsVerified()) 1775 if (profile_to_merge->IsVerified())
1757 break; 1776 break;
1758 } 1777 }
1759 } 1778 }
1760 } 1779 }
1761 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe( 1780 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe(
1762 profiles_to_delete->size()); 1781 profiles_to_delete->size());
1763 } 1782 }
1764 1783
1765 } // namespace autofill 1784 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698