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

Unified Diff: components/previews/core/previews_opt_out_store_sql.h

Issue 2390773003: Adding a SQL implementation of the backing store for previews opt outs (Closed)
Patch Set: tbansal comments Created 4 years, 2 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/previews/core/previews_opt_out_store_sql.h
diff --git a/components/previews/core/previews_opt_out_store_sql.h b/components/previews/core/previews_opt_out_store_sql.h
new file mode 100644
index 0000000000000000000000000000000000000000..e446a874c24f5ebcd5b17f50182bcef381b561e1
--- /dev/null
+++ b/components/previews/core/previews_opt_out_store_sql.h
@@ -0,0 +1,67 @@
+// Copyright 2016 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_PREVIEWS_PREVIEWS_OPT_OUT_STORE_SQL_H_
+#define COMPONENTS_PREVIEWS_PREVIEWS_OPT_OUT_STORE_SQL_H_
+
+#include <stdint.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/threading/thread_checker.h"
+#include "components/previews/core/previews_opt_out_store.h"
+
+namespace base {
+class SequencedTaskRunner;
+class SingleThreadTaskRunner;
+}
+
+namespace sql {
+class Connection;
+}
+
+namespace previews {
+
+// PreviewsOptOutStoreSQL is an instance of PreviewsOptOutStore
+// which is implemented using a SQLite database.
+class PreviewsOptOutStoreSQL : public PreviewsOptOutStore {
+ public:
+ PreviewsOptOutStoreSQL(
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner,
+ const base::FilePath& database_dir);
+ ~PreviewsOptOutStoreSQL() override;
+
+ // PreviewsOptOutStore implementation:
+ void AddPreviewNavigation(bool opt_out,
+ const std::string& host_name,
+ PreviewsType type,
+ base::Time now) override;
+ void LoadBlackList(LoadBlackListCallback callback) override;
+
+ private:
+ // Thread this object is accessed on.
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+
+ // Background thread where all SQL access should be run.
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
+
+ // Path to the database on disk.
+ const base::FilePath db_file_path_;
+
+ // SQL connection to the SQLite database.
+ std::unique_ptr<sql::Connection> db_;
+
+ // Whether the database initialization was started yet.
+ bool initialized_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreviewsOptOutStoreSQL);
+};
+
+} // namespace previews
+
+#endif // COMPONENTS_PREVIEWS_PREVIEWS_OPT_OUT_STORE_SQL_H_

Powered by Google App Engine
This is Rietveld 408576698