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" |
11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
12 #include "chrome/browser/android/offline_pages/background_loader_offliner_factor y.h" | 12 #include "chrome/browser/android/offline_pages/background_loader_offliner.h" |
13 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" | 13 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" |
14 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" | 14 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" |
15 #include "chrome/browser/android/offline_pages/prerendering_offliner_factory.h" | 15 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
16 #include "chrome/browser/android/offline_pages/prerendering_offliner.h" | |
16 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" | 17 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" |
17 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" | 18 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
20 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 21 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
21 #include "components/offline_pages/core/background/offliner_factory.h" | 22 #include "components/offline_pages/core/background/offliner.h" |
22 #include "components/offline_pages/core/background/offliner_policy.h" | 23 #include "components/offline_pages/core/background/offliner_policy.h" |
23 #include "components/offline_pages/core/background/request_coordinator.h" | 24 #include "components/offline_pages/core/background/request_coordinator.h" |
24 #include "components/offline_pages/core/background/request_queue.h" | 25 #include "components/offline_pages/core/background/request_queue.h" |
25 #include "components/offline_pages/core/background/request_queue_store.h" | 26 #include "components/offline_pages/core/background/request_queue_store.h" |
26 #include "components/offline_pages/core/background/request_queue_store_sql.h" | 27 #include "components/offline_pages/core/background/request_queue_store_sql.h" |
27 #include "components/offline_pages/core/background/scheduler.h" | 28 #include "components/offline_pages/core/background/scheduler.h" |
28 #include "components/offline_pages/core/downloads/download_notifying_observer.h" | 29 #include "components/offline_pages/core/downloads/download_notifying_observer.h" |
29 #include "components/offline_pages/core/offline_page_feature.h" | 30 #include "components/offline_pages/core/offline_page_feature.h" |
30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
31 #include "net/nqe/network_quality_estimator.h" | 32 #include "net/nqe/network_quality_estimator.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
45 // static | 46 // static |
46 RequestCoordinator* RequestCoordinatorFactory::GetForBrowserContext( | 47 RequestCoordinator* RequestCoordinatorFactory::GetForBrowserContext( |
47 content::BrowserContext* context) { | 48 content::BrowserContext* context) { |
48 return static_cast<RequestCoordinator*>( | 49 return static_cast<RequestCoordinator*>( |
49 GetInstance()->GetServiceForBrowserContext(context, true)); | 50 GetInstance()->GetServiceForBrowserContext(context, true)); |
50 } | 51 } |
51 | 52 |
52 KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor( | 53 KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor( |
53 content::BrowserContext* context) const { | 54 content::BrowserContext* context) const { |
54 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); | 55 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); |
55 std::unique_ptr<OfflinerFactory> offliner; | 56 std::unique_ptr<Offliner> offliner; |
57 OfflinePageModel* model = | |
58 OfflinePageModelFactory::GetInstance()->GetForBrowserContext(context); | |
56 | 59 |
57 // Determines which offliner to use based on flag. | 60 // Determines which offliner to use based on flag. |
58 if (ShouldUseNewBackgroundLoader()) { | 61 if (ShouldUseNewBackgroundLoader()) { |
59 offliner.reset(new BackgroundLoaderOfflinerFactory(context)); | 62 offliner.reset(new BackgroundLoaderOffliner(context, policy.get(), model)); |
Dmitry Titov
2017/01/06 02:30:44
Neither of both offliners ever use 'policy' constr
chili
2017/01/09 18:08:19
Will do in a separate CL. Want to keep this CL re
| |
60 } else { | 63 } else { |
61 offliner.reset(new PrerenderingOfflinerFactory(context)); | 64 offliner.reset(new PrerenderingOffliner(context, policy.get(), model)); |
62 } | 65 } |
63 | 66 |
64 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 67 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
65 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 68 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
66 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 69 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
67 Profile* profile = Profile::FromBrowserContext(context); | 70 Profile* profile = Profile::FromBrowserContext(context); |
68 base::FilePath queue_store_path = | 71 base::FilePath queue_store_path = |
69 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); | 72 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); |
70 | 73 |
71 std::unique_ptr<RequestQueueStoreSQL> queue_store( | 74 std::unique_ptr<RequestQueueStoreSQL> queue_store( |
(...skipping 11 matching lines...) Expand all Loading... | |
83 std::move(scheduler), network_quality_estimator); | 86 std::move(scheduler), network_quality_estimator); |
84 | 87 |
85 DownloadNotifyingObserver::CreateAndStartObserving( | 88 DownloadNotifyingObserver::CreateAndStartObserving( |
86 request_coordinator, | 89 request_coordinator, |
87 base::MakeUnique<android::OfflinePageNotificationBridge>()); | 90 base::MakeUnique<android::OfflinePageNotificationBridge>()); |
88 | 91 |
89 return request_coordinator; | 92 return request_coordinator; |
90 } | 93 } |
91 | 94 |
92 } // namespace offline_pages | 95 } // namespace offline_pages |
OLD | NEW |