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_scheduler_bridge.h" | 12 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" |
13 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" | 13 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" |
14 #include "chrome/browser/android/offline_pages/prerendering_offliner_factory.h" | 14 #include "chrome/browser/android/offline_pages/prerendering_offliner_factory.h" |
15 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" | |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
17 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
18 #include "components/offline_pages/background/offliner_factory.h" | 19 #include "components/offline_pages/background/offliner_factory.h" |
19 #include "components/offline_pages/background/offliner_policy.h" | 20 #include "components/offline_pages/background/offliner_policy.h" |
20 #include "components/offline_pages/background/request_coordinator.h" | 21 #include "components/offline_pages/background/request_coordinator.h" |
21 #include "components/offline_pages/background/request_queue.h" | 22 #include "components/offline_pages/background/request_queue.h" |
22 #include "components/offline_pages/background/request_queue_store.h" | 23 #include "components/offline_pages/background/request_queue_store.h" |
23 #include "components/offline_pages/background/request_queue_store_sql.h" | 24 #include "components/offline_pages/background/request_queue_store_sql.h" |
24 #include "components/offline_pages/background/scheduler.h" | 25 #include "components/offline_pages/background/scheduler.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
46 | 47 |
47 KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor( | 48 KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor( |
48 content::BrowserContext* context) const { | 49 content::BrowserContext* context) const { |
49 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); | 50 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); |
50 std::unique_ptr<OfflinerFactory> prerenderer_offliner( | 51 std::unique_ptr<OfflinerFactory> prerenderer_offliner( |
51 new PrerenderingOfflinerFactory(context)); | 52 new PrerenderingOfflinerFactory(context)); |
52 | 53 |
53 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 54 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
54 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 55 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
55 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 56 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
57 Profile* profile = Profile::FromBrowserContext(context); | |
56 base::FilePath queue_store_path = | 58 base::FilePath queue_store_path = |
57 Profile::FromBrowserContext(context)->GetPath().Append( | 59 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); |
58 chrome::kOfflinePageRequestQueueDirname); | |
59 | 60 |
60 std::unique_ptr<RequestQueueStoreSQL> queue_store( | 61 std::unique_ptr<RequestQueueStoreSQL> queue_store( |
61 new RequestQueueStoreSQL(background_task_runner, queue_store_path)); | 62 new RequestQueueStoreSQL(background_task_runner, queue_store_path)); |
62 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store))); | 63 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store))); |
63 std::unique_ptr<Scheduler> | 64 std::unique_ptr<Scheduler> |
64 scheduler(new android::BackgroundSchedulerBridge()); | 65 scheduler(new android::BackgroundSchedulerBridge()); |
66 std::unique_ptr<net::NetworkQualityEstimator::NetworkQualityProvider> | |
tbansal1
2016/09/16 19:13:50
The caller can't take ownership of the raw ptr sin
dougarnett
2016/09/16 21:24:42
thanks
| |
67 network_quality_provider( | |
68 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile)); | |
RyanSturm
2016/09/16 18:54:46
This returns a raw pointer and doesn't expect owne
RyanSturm
2016/09/16 19:08:26
There is a KeyedService method, Shutdown that coul
dougarnett
2016/09/16 21:24:42
I'm not clear if you mean just invalidate in Reque
RyanSturm
2016/09/19 17:15:40
Perfect.
| |
65 // TODO(fgorski): Something needs to keep the handle to the Notification | 69 // TODO(fgorski): Something needs to keep the handle to the Notification |
66 // dispatcher. | 70 // dispatcher. |
67 RequestCoordinator* request_coordinator = | 71 RequestCoordinator* request_coordinator = new RequestCoordinator( |
68 new RequestCoordinator(std::move(policy), std::move(prerenderer_offliner), | 72 std::move(policy), std::move(prerenderer_offliner), std::move(queue), |
69 std::move(queue), std::move(scheduler)); | 73 std::move(scheduler), std::move(network_quality_provider)); |
70 | 74 |
71 DownloadNotifyingObserver::CreateAndStartObserving( | 75 DownloadNotifyingObserver::CreateAndStartObserving( |
72 request_coordinator, | 76 request_coordinator, |
73 base::MakeUnique<android::OfflinePageNotificationBridge>()); | 77 base::MakeUnique<android::OfflinePageNotificationBridge>()); |
74 | 78 |
75 return request_coordinator; | 79 return request_coordinator; |
76 } | 80 } |
77 | 81 |
78 content::BrowserContext* RequestCoordinatorFactory::GetBrowserContextToUse( | 82 content::BrowserContext* RequestCoordinatorFactory::GetBrowserContextToUse( |
79 content::BrowserContext* context) const { | 83 content::BrowserContext* context) const { |
80 // TODO(petewil): Make sure we support incognito properly. | 84 // TODO(petewil): Make sure we support incognito properly. |
81 return context; | 85 return context; |
82 } | 86 } |
83 | 87 |
84 } // namespace offline_pages | 88 } // namespace offline_pages |
OLD | NEW |