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

Side by Side Diff: components/password_manager/core/browser/statistics_table.cc

Issue 2262843002: Make PasswordFormManager::best_matches_ const (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@621355_pass_creds_to_update_by_value
Patch Set: Just rebased Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/statistics_table.h" 5 #include "components/password_manager/core/browser/statistics_table.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 17 matching lines...) Expand all
28 28
29 InteractionsStats::InteractionsStats() = default; 29 InteractionsStats::InteractionsStats() = default;
30 30
31 bool operator==(const InteractionsStats& lhs, const InteractionsStats& rhs) { 31 bool operator==(const InteractionsStats& lhs, const InteractionsStats& rhs) {
32 return lhs.origin_domain == rhs.origin_domain && 32 return lhs.origin_domain == rhs.origin_domain &&
33 lhs.username_value == rhs.username_value && 33 lhs.username_value == rhs.username_value &&
34 lhs.dismissal_count == rhs.dismissal_count && 34 lhs.dismissal_count == rhs.dismissal_count &&
35 lhs.update_time == rhs.update_time; 35 lhs.update_time == rhs.update_time;
36 } 36 }
37 37
38 InteractionsStats* FindStatsByUsername( 38 const InteractionsStats* FindStatsByUsername(
39 const std::vector<std::unique_ptr<InteractionsStats>>& stats, 39 const std::vector<const InteractionsStats*>& stats,
40 const base::string16& username) { 40 const base::string16& username) {
41 auto it = std::find_if( 41 auto it = std::find_if(stats.begin(), stats.end(),
42 stats.begin(), stats.end(), 42 [&username](const InteractionsStats* element) {
43 [&username](const std::unique_ptr<InteractionsStats>& element) { 43 return username == element->username_value;
44 return username == element->username_value; 44 });
45 }); 45 return it == stats.end() ? nullptr : *it;
46 return it == stats.end() ? nullptr : it->get();
47 } 46 }
48 47
49 StatisticsTable::StatisticsTable() : db_(nullptr) { 48 StatisticsTable::StatisticsTable() : db_(nullptr) {
50 } 49 }
51 50
52 StatisticsTable::~StatisticsTable() = default; 51 StatisticsTable::~StatisticsTable() = default;
53 52
54 void StatisticsTable::Init(sql::Connection* db) { 53 void StatisticsTable::Init(sql::Connection* db) {
55 db_ = db; 54 db_ = db;
56 } 55 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 sql::Statement s(db_->GetCachedStatement( 131 sql::Statement s(db_->GetCachedStatement(
133 SQL_FROM_HERE, 132 SQL_FROM_HERE,
134 "DELETE FROM stats WHERE update_time >= ? AND update_time < ?")); 133 "DELETE FROM stats WHERE update_time >= ? AND update_time < ?"));
135 s.BindInt64(0, delete_begin.ToInternalValue()); 134 s.BindInt64(0, delete_begin.ToInternalValue());
136 s.BindInt64(1, delete_end.is_null() ? std::numeric_limits<int64_t>::max() 135 s.BindInt64(1, delete_end.is_null() ? std::numeric_limits<int64_t>::max()
137 : delete_end.ToInternalValue()); 136 : delete_end.ToInternalValue());
138 return s.Run(); 137 return s.Run();
139 } 138 }
140 139
141 } // namespace password_manager 140 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698