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_ |