OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/previews/previews_service.h" | 5 #include "chrome/browser/previews/previews_service.h" |
6 | 6 |
7 #include "base/files/file_path.h" | |
8 #include "base/memory/ptr_util.h" | |
9 #include "base/sequenced_task_runner.h" | |
10 #include "base/threading/sequenced_worker_pool.h" | |
11 #include "chrome/common/chrome_constants.h" | |
12 #include "components/previews/core/previews_io_data.h" | |
13 #include "components/previews/core/previews_opt_out_store.h" | |
14 #include "components/previews/core/previews_opt_out_store_sql.h" | |
7 #include "components/previews/core/previews_ui_service.h" | 15 #include "components/previews/core/previews_ui_service.h" |
8 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
9 | 17 |
10 PreviewsService::PreviewsService() { | 18 PreviewsService::PreviewsService() { |
11 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 19 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
12 } | 20 } |
13 | 21 |
14 PreviewsService::~PreviewsService() { | 22 PreviewsService::~PreviewsService() { |
15 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 23 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
16 } | 24 } |
17 | 25 |
18 void PreviewsService::set_previews_ui_service( | 26 void PreviewsService::Initialize( |
19 std::unique_ptr<previews::PreviewsUIService> previews_ui_service) { | 27 previews::PreviewsIOData* previews_io_data, |
28 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | |
29 const base::FilePath& profile_path) { | |
20 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
21 previews_ui_service_ = std::move(previews_ui_service); | 31 |
32 // Get the background thread to run SQLite on. | |
33 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | |
34 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | |
35 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | |
36 | |
37 std::unique_ptr<previews::PreviewsOptOutStore> opt_out_store( | |
38 new previews::PreviewsOptOutStoreSQL( | |
Scott Hess - ex-Googler
2016/10/08 00:04:22
Did MakeUnique<>() not work for this one?
RyanSturm
2016/10/10 18:50:35
Done.
| |
39 io_task_runner, background_task_runner, | |
40 profile_path.Append(chrome::kPreviewsOptOutDBFilename))); | |
41 previews_ui_service_ = base::MakeUnique<previews::PreviewsUIService>( | |
42 previews_io_data, io_task_runner, std::move(opt_out_store)); | |
22 } | 43 } |
OLD | NEW |