| 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/core/previews_io_data.h" | 5 #include "components/previews/core/previews_io_data.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 weak_factory_(this) {} | 25 weak_factory_(this) {} |
| 26 | 26 |
| 27 PreviewsIOData::~PreviewsIOData() {} | 27 PreviewsIOData::~PreviewsIOData() {} |
| 28 | 28 |
| 29 void PreviewsIOData::Initialize( | 29 void PreviewsIOData::Initialize( |
| 30 base::WeakPtr<PreviewsUIService> previews_ui_service, | 30 base::WeakPtr<PreviewsUIService> previews_ui_service, |
| 31 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) { | 31 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) { |
| 32 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 32 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 33 previews_ui_service_ = previews_ui_service; | 33 previews_ui_service_ = previews_ui_service; |
| 34 | 34 |
| 35 // Set up the IO thread portion of |this|. | |
| 36 io_task_runner_->PostTask( | |
| 37 FROM_HERE, | |
| 38 base::Bind(&PreviewsIOData::InitializeOnIOThread, base::Unretained(this), | |
| 39 base::Passed(&previews_opt_out_store))); | |
| 40 } | |
| 41 | |
| 42 void PreviewsIOData::InitializeOnIOThread( | |
| 43 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) { | |
| 44 DCHECK(io_task_runner_->BelongsToCurrentThread()); | |
| 45 previews_black_list_.reset( | 35 previews_black_list_.reset( |
| 46 new PreviewsBlackList(std::move(previews_opt_out_store), | 36 new PreviewsBlackList(std::move(previews_opt_out_store), |
| 47 base::MakeUnique<base::DefaultClock>())); | 37 base::MakeUnique<base::DefaultClock>())); |
| 38 |
| 39 // Set up the IO thread portion of |this|. |
| 40 io_task_runner_->PostTask(FROM_HERE, |
| 41 base::Bind(&PreviewsIOData::InitializeOnIOThread, |
| 42 base::Unretained(this))); |
| 43 } |
| 44 |
| 45 void PreviewsIOData::InitializeOnIOThread() { |
| 46 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 47 previews_black_list_->Initialize(); |
| 48 |
| 48 ui_task_runner_->PostTask( | 49 ui_task_runner_->PostTask( |
| 49 FROM_HERE, base::Bind(&PreviewsUIService::SetIOData, previews_ui_service_, | 50 FROM_HERE, base::Bind(&PreviewsUIService::SetIOData, previews_ui_service_, |
| 50 weak_factory_.GetWeakPtr())); | 51 weak_factory_.GetWeakPtr())); |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace previews | 54 } // namespace previews |
| OLD | NEW |