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

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

Issue 2748033002: Revert of Moving previews code from components/ to chrome/ (Closed)
Patch Set: Created 3 years, 9 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.cc
diff --git a/components/previews/core/previews_opt_out_store_sql.cc b/components/previews/core/previews_opt_out_store_sql.cc
index 835f645ac2fba42672481b23224d73d0435e626f..b1e4f582621e10258ca79044c1d2f0ecf38bf842 100644
--- a/components/previews/core/previews_opt_out_store_sql.cc
+++ b/components/previews/core/previews_opt_out_store_sql.cc
@@ -262,11 +262,11 @@
// Checks the current set of enabled previews (with their current version)
// and where a preview is now disabled or has a different version, cleans up
// any associated blacklist entries.
-void CheckAndReconcileEnabledPreviewsWithDataBase(
- sql::Connection* db,
- PreviewsTypeList* enabled_previews) {
+void CheckAndReconcileEnabledPreviewsWithDataBase(sql::Connection* db) {
std::unique_ptr<std::map<PreviewsType, int>> stored_previews(
GetStoredPreviews(db));
+
+ std::unique_ptr<PreviewsTypeList> enabled_previews(GetEnabledPreviews());
for (auto enabled_it = enabled_previews->begin();
enabled_it != enabled_previews->end(); ++enabled_it) {
@@ -297,11 +297,10 @@
void LoadBlackListFromDataBase(
sql::Connection* db,
- PreviewsTypeList* enabled_previews,
scoped_refptr<base::SingleThreadTaskRunner> runner,
LoadBlackListCallback callback) {
// First handle any update needed wrt enabled previews and their versions.
- CheckAndReconcileEnabledPreviewsWithDataBase(db, enabled_previews);
+ CheckAndReconcileEnabledPreviewsWithDataBase(db);
// Gets the table sorted by host and time. Limits the number of hosts using
// most recent opt_out time as the limiting function. Sorting is free due to
@@ -366,13 +365,12 @@
// and actually do the work to access the SQL data base.
void LoadBlackListSync(sql::Connection* db,
const base::FilePath& path,
- PreviewsTypeList* enabled_previews,
scoped_refptr<base::SingleThreadTaskRunner> runner,
LoadBlackListCallback callback) {
if (!db->is_open())
InitDatabase(db, path);
- LoadBlackListFromDataBase(db, enabled_previews, runner, callback);
+ LoadBlackListFromDataBase(db, runner, callback);
}
// Deletes every row in the table that has entry time between |begin_time| and
@@ -407,14 +405,10 @@
PreviewsOptOutStoreSQL::PreviewsOptOutStoreSQL(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
- const base::FilePath& path,
- std::unique_ptr<PreviewsTypeList> enabled_previews)
+ const base::FilePath& path)
: io_task_runner_(io_task_runner),
background_task_runner_(background_task_runner),
- db_file_path_(path),
- enabled_previews_(std::move(enabled_previews)) {
- DCHECK(enabled_previews_);
-}
+ db_file_path_(path) {}
PreviewsOptOutStoreSQL::~PreviewsOptOutStoreSQL() {
DCHECK(io_task_runner_->BelongsToCurrentThread());
@@ -449,7 +443,6 @@
db_ = base::MakeUnique<sql::Connection>();
background_task_runner_->PostTask(
FROM_HERE, base::Bind(&LoadBlackListSync, db_.get(), db_file_path_,
- enabled_previews_.get(),
base::ThreadTaskRunnerHandle::Get(), callback));
}
« no previous file with comments | « components/previews/core/previews_opt_out_store_sql.h ('k') | components/previews/core/previews_opt_out_store_sql_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698