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 "components/previews/previews_io_data.h" | 5 #include "components/previews/previews_io_data.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/sequenced_task_runner.h" |
| 12 #include "components/previews/previews_black_list.h" |
| 13 #include "components/previews/previews_opt_out_store.h" |
9 #include "components/previews/previews_ui_service.h" | 14 #include "components/previews/previews_ui_service.h" |
10 | 15 |
11 namespace previews { | 16 namespace previews { |
12 | 17 |
13 PreviewsIOData::PreviewsIOData( | 18 PreviewsIOData::PreviewsIOData( |
14 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 19 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
15 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 20 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
16 : ui_task_runner_(ui_task_runner), | 21 : ui_task_runner_(ui_task_runner), |
17 io_task_runner_(io_task_runner), | 22 io_task_runner_(io_task_runner), |
18 weak_factory_(this) {} | 23 weak_factory_(this) {} |
19 | 24 |
20 PreviewsIOData::~PreviewsIOData() {} | 25 PreviewsIOData::~PreviewsIOData() {} |
21 | 26 |
22 void PreviewsIOData::Initialize( | 27 void PreviewsIOData::Initialize( |
23 base::WeakPtr<PreviewsUIService> previews_ui_service) { | 28 base::WeakPtr<PreviewsUIService> previews_ui_service, |
| 29 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) { |
24 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 30 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
25 previews_ui_service_ = previews_ui_service; | 31 previews_ui_service_ = previews_ui_service; |
26 | 32 |
27 // Set up the IO thread portion of |this|. | 33 // Set up the IO thread portion of |this|. |
28 io_task_runner_->PostTask(FROM_HERE, | 34 io_task_runner_->PostTask( |
29 base::Bind(&PreviewsIOData::InitializeOnIOThread, | 35 FROM_HERE, |
30 base::Unretained(this))); | 36 base::Bind(&PreviewsIOData::InitializeOnIOThread, base::Unretained(this), |
| 37 base::Passed(&previews_opt_out_store))); |
31 } | 38 } |
32 | 39 |
33 void PreviewsIOData::InitializeOnIOThread() { | 40 void PreviewsIOData::InitializeOnIOThread( |
| 41 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) { |
34 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 42 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 43 black_list_.reset(new PreviewsBlackList(std::move(previews_opt_out_store))); |
35 ui_task_runner_->PostTask( | 44 ui_task_runner_->PostTask( |
36 FROM_HERE, base::Bind(&PreviewsUIService::SetIOData, previews_ui_service_, | 45 FROM_HERE, base::Bind(&PreviewsUIService::SetIOData, previews_ui_service_, |
37 weak_factory_.GetWeakPtr())); | 46 weak_factory_.GetWeakPtr())); |
38 } | 47 } |
39 | 48 |
40 } // namespace previews | 49 } // namespace previews |
OLD | NEW |