Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / password_manager / core / browser / statistics_table.h
blobd1353093f736b40c672efe573ae0451f736579a4
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h"
11 #include "url/gurl.h"
13 namespace sql {
14 class Connection;
17 namespace password_manager {
19 // The statistics containing user interactions with a site.
20 struct InteractionsStats {
21 // The domain of the site.
22 GURL origin_domain;
24 // Number of times the user clicked "Don't save the password".
25 int nopes_count;
27 // Number of times the user dismissed the bubble.
28 int dismissal_count;
30 // The beginning date of the measurements.
31 base::Time start_date;
34 // Represents 'stats' table in the Login Database.
35 class StatisticsTable {
36 public:
37 StatisticsTable();
38 ~StatisticsTable();
40 // Initializes |db_| and creates the statistics table if it doesn't exist.
41 bool Init(sql::Connection* db);
43 // Adds or replaces the statistics about |stats.origin_domain|.
44 bool AddRow(const InteractionsStats& stats);
46 // Removes the statistics for |domain|. Returns true if the SQL completed
47 // successfully.
48 bool RemoveRow(const GURL& domain);
50 // Returns the statistics for |domain| if it exists.
51 scoped_ptr<InteractionsStats> GetRow(const GURL& domain);
53 private:
54 sql::Connection* db_;
56 DISALLOW_COPY_AND_ASSIGN(StatisticsTable);
59 } // namespace password_manager
61 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_