| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |