Chromium Code Reviews| 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 b1e4f582621e10258ca79044c1d2f0ecf38bf842..a4ab1c666efe85bbb3fc02c000771c62923fc5ce 100644 |
| --- a/components/previews/core/previews_opt_out_store_sql.cc |
| +++ b/components/previews/core/previews_opt_out_store_sql.cc |
| @@ -262,12 +262,12 @@ void DeleteEnabledPreviewInDataBase(sql::Connection* db, PreviewsType type) { |
| // 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) { |
| +void CheckAndReconcileEnabledPreviewsWithDataBase( |
| + sql::Connection* db, |
| + PreviewsTypeList* enabled_previews) { |
| 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) { |
| PreviewsType type = enabled_it->first; |
| @@ -297,10 +297,11 @@ void CheckAndReconcileEnabledPreviewsWithDataBase(sql::Connection* db) { |
| 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); |
| + CheckAndReconcileEnabledPreviewsWithDataBase(db, enabled_previews); |
| // 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 |
| @@ -365,12 +366,13 @@ void LoadBlackListFromDataBase( |
| // 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, runner, callback); |
| + LoadBlackListFromDataBase(db, enabled_previews, runner, callback); |
| } |
| // Deletes every row in the table that has entry time between |begin_time| and |
| @@ -405,10 +407,12 @@ void AddPreviewNavigationSync(bool opt_out, |
| PreviewsOptOutStoreSQL::PreviewsOptOutStoreSQL( |
| scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
| - const base::FilePath& path) |
| + const base::FilePath& path, |
| + std::unique_ptr<PreviewsTypeList> enabled_previews) |
| : io_task_runner_(io_task_runner), |
| background_task_runner_(background_task_runner), |
| - db_file_path_(path) {} |
| + db_file_path_(path), |
| + enabled_previews_(std::move(enabled_previews)) {} |
|
tbansal1
2017/03/10 23:06:24
DCHECK(enabled_previews_);
RyanSturm
2017/03/13 21:12:47
Done.
|
| PreviewsOptOutStoreSQL::~PreviewsOptOutStoreSQL() { |
| DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| @@ -443,6 +447,7 @@ void PreviewsOptOutStoreSQL::LoadBlackList(LoadBlackListCallback callback) { |
| 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)); |
| } |