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

Unified Diff: components/password_manager/core/browser/statistics_table.h

Issue 1083293004: Implement the statistics table for the passwords. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address the comments Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/core/browser/statistics_table.h
diff --git a/components/password_manager/core/browser/statistics_table.h b/components/password_manager/core/browser/statistics_table.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1353093f736b40c672efe573ae0451f736579a4
--- /dev/null
+++ b/components/password_manager/core/browser/statistics_table.h
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_
+#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "url/gurl.h"
+
+namespace sql {
+class Connection;
+}
+
+namespace password_manager {
+
+// The statistics containing user interactions with a site.
+struct InteractionsStats {
+ // The domain of the site.
+ GURL origin_domain;
+
+ // Number of times the user clicked "Don't save the password".
+ int nopes_count;
+
+ // Number of times the user dismissed the bubble.
+ int dismissal_count;
+
+ // The beginning date of the measurements.
+ base::Time start_date;
+};
+
+// Represents 'stats' table in the Login Database.
+class StatisticsTable {
+ public:
+ StatisticsTable();
+ ~StatisticsTable();
+
+ // Initializes |db_| and creates the statistics table if it doesn't exist.
+ bool Init(sql::Connection* db);
+
+ // Adds or replaces the statistics about |stats.origin_domain|.
+ bool AddRow(const InteractionsStats& stats);
+
+ // Removes the statistics for |domain|. Returns true if the SQL completed
+ // successfully.
+ bool RemoveRow(const GURL& domain);
+
+ // Returns the statistics for |domain| if it exists.
+ scoped_ptr<InteractionsStats> GetRow(const GURL& domain);
+
+ private:
+ sql::Connection* db_;
+
+ DISALLOW_COPY_AND_ASSIGN(StatisticsTable);
+};
+
+} // namespace password_manager
+
+#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STATISTICS_TABLE_H_

Powered by Google App Engine
This is Rietveld 408576698