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/sequenced_task_runner.h" | |
9 #include "base/threading/sequenced_worker_pool.h" | |
10 #include "chrome/common/chrome_constants.h" | |
11 #include "components/previews/core/previews_io_data.h" | |
12 #include "components/previews/core/previews_opt_out_store.h" | |
13 #include "components/previews/core/previews_opt_out_store_sql.h" | |
7 #include "components/previews/core/previews_ui_service.h" | 14 #include "components/previews/core/previews_ui_service.h" |
8 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
9 | 16 |
10 PreviewsService::PreviewsService() { | 17 PreviewsService::PreviewsService() { |
11 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 18 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
12 } | 19 } |
13 | 20 |
14 PreviewsService::~PreviewsService() { | 21 PreviewsService::~PreviewsService() { |
15 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 22 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
16 } | 23 } |
17 | 24 |
18 void PreviewsService::set_previews_ui_service( | 25 void PreviewsService::Initialize( |
19 std::unique_ptr<previews::PreviewsUIService> previews_ui_service) { | 26 previews::PreviewsIOData* previews_io_data, |
27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | |
28 const base::FilePath& profile_path) { | |
20 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
21 previews_ui_service_ = std::move(previews_ui_service); | 30 |
31 // Get the background thread to run SQLite on. | |
32 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | |
33 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | |
34 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | |
35 | |
36 std::unique_ptr<previews::PreviewsOptOutStore> opt_out_store( | |
37 new previews::PreviewsOptOutStoreSQL( | |
38 io_task_runner, background_task_runner, | |
39 profile_path.Append(chrome::kPreviewsOptOutDirname))); | |
40 previews_ui_service_.reset(new previews::PreviewsUIService( | |
Lei Zhang
2016/10/06 19:16:50
base::MakeUnique?
RyanSturm
2016/10/06 20:05:40
Done.
| |
41 previews_io_data, io_task_runner, std::move(opt_out_store))); | |
22 } | 42 } |
OLD | NEW |