Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/browser/android/offline_pages/request_coordinator_factory.cc

Issue 2260963003: [Offline pages] Enabling notifications for pages saved later (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing missed TODO Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/singleton.h" 10 #include "base/memory/singleton.h"
10 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
11 #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"
12 #include "chrome/browser/android/offline_pages/prerendering_offliner_factory.h" 14 #include "chrome/browser/android/offline_pages/prerendering_offliner_factory.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" 17 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 #include "components/offline_pages/background/offliner_factory.h" 18 #include "components/offline_pages/background/offliner_factory.h"
17 #include "components/offline_pages/background/offliner_policy.h" 19 #include "components/offline_pages/background/offliner_policy.h"
18 #include "components/offline_pages/background/request_coordinator.h" 20 #include "components/offline_pages/background/request_coordinator.h"
19 #include "components/offline_pages/background/request_queue.h" 21 #include "components/offline_pages/background/request_queue.h"
20 #include "components/offline_pages/background/request_queue_store.h" 22 #include "components/offline_pages/background/request_queue_store.h"
21 #include "components/offline_pages/background/request_queue_store_sql.h" 23 #include "components/offline_pages/background/request_queue_store_sql.h"
22 #include "components/offline_pages/background/scheduler.h" 24 #include "components/offline_pages/background/scheduler.h"
25 #include "components/offline_pages/downloads/download_notifying_observer.h"
23 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
24 27
25 namespace offline_pages { 28 namespace offline_pages {
26 29
27 RequestCoordinatorFactory::RequestCoordinatorFactory() 30 RequestCoordinatorFactory::RequestCoordinatorFactory()
28 : BrowserContextKeyedServiceFactory( 31 : BrowserContextKeyedServiceFactory(
29 "OfflineRequestCoordinator", 32 "OfflineRequestCoordinator",
30 BrowserContextDependencyManager::GetInstance()) {} 33 BrowserContextDependencyManager::GetInstance()) {}
31 34
32 // static 35 // static
(...skipping 19 matching lines...) Expand all
52 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 55 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
53 base::FilePath queue_store_path = 56 base::FilePath queue_store_path =
54 Profile::FromBrowserContext(context)->GetPath().Append( 57 Profile::FromBrowserContext(context)->GetPath().Append(
55 chrome::kOfflinePageRequestQueueDirname); 58 chrome::kOfflinePageRequestQueueDirname);
56 59
57 std::unique_ptr<RequestQueueStoreSQL> queue_store( 60 std::unique_ptr<RequestQueueStoreSQL> queue_store(
58 new RequestQueueStoreSQL(background_task_runner, queue_store_path)); 61 new RequestQueueStoreSQL(background_task_runner, queue_store_path));
59 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store))); 62 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(queue_store)));
60 std::unique_ptr<Scheduler> 63 std::unique_ptr<Scheduler>
61 scheduler(new android::BackgroundSchedulerBridge()); 64 scheduler(new android::BackgroundSchedulerBridge());
65 // TODO(fgorski): Something needs to keep the handle to the Notification
66 // dispatcher.
67 RequestCoordinator* request_coordinator =
68 new RequestCoordinator(std::move(policy), std::move(prerenderer_offliner),
69 std::move(queue), std::move(scheduler));
62 70
63 return new RequestCoordinator(std::move(policy), 71 DownloadNotifyingObserver::CreateAndStartObserving(
64 std::move(prerenderer_offliner), 72 request_coordinator,
65 std::move(queue), 73 base::MakeUnique<android::OfflinePageNotificationBridge>());
66 std::move(scheduler)); 74
75 return request_coordinator;
67 } 76 }
68 77
69 content::BrowserContext* RequestCoordinatorFactory::GetBrowserContextToUse( 78 content::BrowserContext* RequestCoordinatorFactory::GetBrowserContextToUse(
70 content::BrowserContext* context) const { 79 content::BrowserContext* context) const {
71 // TODO(petewil): Make sure we support incognito properly. 80 // TODO(petewil): Make sure we support incognito properly.
72 return context; 81 return context;
73 } 82 }
74 83
75 } // namespace offline_pages 84 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698