| 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/android/offline_pages/request_coordinator_factory.h" | 5 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 // Determines which offliner to use based on flag. | 62 // Determines which offliner to use based on flag. |
| 63 if (ShouldUseNewBackgroundLoader()) { | 63 if (ShouldUseNewBackgroundLoader()) { |
| 64 offliner.reset(new BackgroundLoaderOffliner(context, policy.get(), model)); | 64 offliner.reset(new BackgroundLoaderOffliner(context, policy.get(), model)); |
| 65 } else { | 65 } else { |
| 66 offliner.reset(new PrerenderingOffliner(context, policy.get(), model)); | 66 offliner.reset(new PrerenderingOffliner(context, policy.get(), model)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 69 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 70 base::CreateSequencedTaskRunnerWithTraits( | 70 base::CreateSequencedTaskRunnerWithTraits( |
| 71 base::TaskTraits().MayBlock().WithPriority( | 71 {base::MayBlock(), base::TaskPriority::BACKGROUND}); |
| 72 base::TaskPriority::BACKGROUND)); | |
| 73 Profile* profile = Profile::FromBrowserContext(context); | 72 Profile* profile = Profile::FromBrowserContext(context); |
| 74 base::FilePath queue_store_path = | 73 base::FilePath queue_store_path = |
| 75 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); | 74 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); |
| 76 | 75 |
| 77 std::unique_ptr<RequestQueueStoreSQL> queue_store( | 76 std::unique_ptr<RequestQueueStoreSQL> queue_store( |
| 78 new RequestQueueStoreSQL(background_task_runner, queue_store_path)); | 77 new RequestQueueStoreSQL(background_task_runner, queue_store_path)); |
| 79 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store))); | 78 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store))); |
| 80 std::unique_ptr<Scheduler> | 79 std::unique_ptr<Scheduler> |
| 81 scheduler(new android::BackgroundSchedulerBridge()); | 80 scheduler(new android::BackgroundSchedulerBridge()); |
| 82 net::NetworkQualityEstimator::NetworkQualityProvider* | 81 net::NetworkQualityEstimator::NetworkQualityProvider* |
| 83 network_quality_estimator = | 82 network_quality_estimator = |
| 84 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile); | 83 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile); |
| 85 RequestCoordinator* request_coordinator = new RequestCoordinator( | 84 RequestCoordinator* request_coordinator = new RequestCoordinator( |
| 86 std::move(policy), std::move(offliner), std::move(queue), | 85 std::move(policy), std::move(offliner), std::move(queue), |
| 87 std::move(scheduler), network_quality_estimator); | 86 std::move(scheduler), network_quality_estimator); |
| 88 | 87 |
| 89 DownloadNotifyingObserver::CreateAndStartObserving( | 88 DownloadNotifyingObserver::CreateAndStartObserving( |
| 90 request_coordinator, | 89 request_coordinator, |
| 91 base::MakeUnique<android::OfflinePageNotificationBridge>()); | 90 base::MakeUnique<android::OfflinePageNotificationBridge>()); |
| 92 | 91 |
| 93 return request_coordinator; | 92 return request_coordinator; |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace offline_pages | 95 } // namespace offline_pages |
| OLD | NEW |