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 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_ |
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace sql { | 16 namespace sql { |
17 class Connection; | 17 class Connection; |
18 } | 18 } |
19 | 19 |
20 namespace password_manager { | 20 namespace password_manager { |
21 | 21 |
(...skipping 11 matching lines...) Expand all Loading... |
33 int dismissal_count = 0; | 33 int dismissal_count = 0; |
34 | 34 |
35 // The date when the row was updated. | 35 // The date when the row was updated. |
36 base::Time update_time; | 36 base::Time update_time; |
37 }; | 37 }; |
38 | 38 |
39 bool operator==(const InteractionsStats& lhs, const InteractionsStats& rhs); | 39 bool operator==(const InteractionsStats& lhs, const InteractionsStats& rhs); |
40 | 40 |
41 // Returns an element from |stats| with |username| or nullptr if not found. | 41 // Returns an element from |stats| with |username| or nullptr if not found. |
42 InteractionsStats* FindStatsByUsername( | 42 InteractionsStats* FindStatsByUsername( |
43 const std::vector<scoped_ptr<InteractionsStats>>& stats, | 43 const std::vector<std::unique_ptr<InteractionsStats>>& stats, |
44 const base::string16& username); | 44 const base::string16& username); |
45 | 45 |
46 // Represents the 'stats' table in the Login Database. | 46 // Represents the 'stats' table in the Login Database. |
47 class StatisticsTable { | 47 class StatisticsTable { |
48 public: | 48 public: |
49 StatisticsTable(); | 49 StatisticsTable(); |
50 ~StatisticsTable(); | 50 ~StatisticsTable(); |
51 | 51 |
52 // Initializes |db_|. | 52 // Initializes |db_|. |
53 void Init(sql::Connection* db); | 53 void Init(sql::Connection* db); |
54 | 54 |
55 // Creates the statistics table if it doesn't exist. | 55 // Creates the statistics table if it doesn't exist. |
56 bool CreateTableIfNecessary(); | 56 bool CreateTableIfNecessary(); |
57 | 57 |
58 // Migrates this table to |version|. The current version should be less than | 58 // Migrates this table to |version|. The current version should be less than |
59 // |version|. Returns false if there was migration work to do and it failed, | 59 // |version|. Returns false if there was migration work to do and it failed, |
60 // true otherwise. | 60 // true otherwise. |
61 bool MigrateToVersion(int version); | 61 bool MigrateToVersion(int version); |
62 | 62 |
63 // Adds or replaces the statistics about |stats.origin_domain| and | 63 // Adds or replaces the statistics about |stats.origin_domain| and |
64 // |stats.username_value|. | 64 // |stats.username_value|. |
65 bool AddRow(const InteractionsStats& stats); | 65 bool AddRow(const InteractionsStats& stats); |
66 | 66 |
67 // Removes the statistics for |domain|. Returns true if the SQL completed | 67 // Removes the statistics for |domain|. Returns true if the SQL completed |
68 // successfully. | 68 // successfully. |
69 bool RemoveRow(const GURL& domain); | 69 bool RemoveRow(const GURL& domain); |
70 | 70 |
71 // Returns the statistics for |domain| if it exists. | 71 // Returns the statistics for |domain| if it exists. |
72 std::vector<scoped_ptr<InteractionsStats>> GetRows(const GURL& domain); | 72 std::vector<std::unique_ptr<InteractionsStats>> GetRows(const GURL& domain); |
73 | 73 |
74 // Removes the statistics between the dates. Returns true if the SQL completed | 74 // Removes the statistics between the dates. Returns true if the SQL completed |
75 // successfully. | 75 // successfully. |
76 bool RemoveStatsBetween(base::Time delete_begin, base::Time delete_end); | 76 bool RemoveStatsBetween(base::Time delete_begin, base::Time delete_end); |
77 | 77 |
78 private: | 78 private: |
79 sql::Connection* db_; | 79 sql::Connection* db_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(StatisticsTable); | 81 DISALLOW_COPY_AND_ASSIGN(StatisticsTable); |
82 }; | 82 }; |
83 | 83 |
84 } // namespace password_manager | 84 } // namespace password_manager |
85 | 85 |
86 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_ | 86 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_ |
OLD | NEW |