OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/offline_pages/core/prefetch/prefetch_dispatcher_impl.h" | 5 #include "components/offline_pages/core/prefetch/prefetch_dispatcher_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "components/offline_pages/core/offline_page_feature.h" | 13 #include "components/offline_pages/core/offline_page_feature.h" |
14 #include "components/offline_pages/core/prefetch/add_unique_urls_task.h" | 14 #include "components/offline_pages/core/prefetch/add_unique_urls_task.h" |
15 #include "components/offline_pages/core/prefetch/prefetch_service.h" | 15 #include "components/offline_pages/core/prefetch/prefetch_service.h" |
| 16 #include "components/offline_pages/core/prefetch/store/prefetch_store_command_fa
ctory.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace offline_pages { | 19 namespace offline_pages { |
19 | 20 |
20 namespace { | 21 namespace { |
21 void DeleteBackgroundTaskHelper( | 22 void DeleteBackgroundTaskHelper( |
22 std::unique_ptr<PrefetchDispatcher::ScopedBackgroundTask> task) { | 23 std::unique_ptr<PrefetchDispatcher::ScopedBackgroundTask> task) { |
23 task.reset(); | 24 task.reset(); |
24 } | 25 } |
25 } // namespace | 26 } // namespace |
26 | 27 |
27 PrefetchDispatcherImpl::PrefetchDispatcherImpl() = default; | 28 PrefetchDispatcherImpl::PrefetchDispatcherImpl() = default; |
28 | 29 |
29 PrefetchDispatcherImpl::~PrefetchDispatcherImpl() = default; | 30 PrefetchDispatcherImpl::~PrefetchDispatcherImpl() = default; |
30 | 31 |
31 void PrefetchDispatcherImpl::SetService(PrefetchService* service) { | 32 void PrefetchDispatcherImpl::SetService(PrefetchService* service) { |
32 CHECK(service); | 33 CHECK(service); |
33 service_ = service; | 34 service_ = service; |
34 } | 35 } |
35 | 36 |
36 void PrefetchDispatcherImpl::AddCandidatePrefetchURLs( | 37 void PrefetchDispatcherImpl::AddCandidatePrefetchURLs( |
| 38 const std::string& name_space, |
37 const std::vector<PrefetchURL>& prefetch_urls) { | 39 const std::vector<PrefetchURL>& prefetch_urls) { |
38 if (!IsPrefetchingOfflinePagesEnabled()) | 40 if (!IsPrefetchingOfflinePagesEnabled()) |
39 return; | 41 return; |
40 | 42 |
| 43 PrefetchStoreCommandFactory* command_factory = |
| 44 service_->GetPrefetchStoreCommandFactory(); |
41 std::unique_ptr<Task> add_task = base::MakeUnique<AddUniqueUrlsTask>( | 45 std::unique_ptr<Task> add_task = base::MakeUnique<AddUniqueUrlsTask>( |
42 service_->GetPrefetchStore(), prefetch_urls); | 46 command_factory->createAddUrls(), command_factory->createCleanupZombies(), |
| 47 name_space, prefetch_urls); |
43 task_queue_.AddTask(std::move(add_task)); | 48 task_queue_.AddTask(std::move(add_task)); |
44 } | 49 } |
45 | 50 |
46 void PrefetchDispatcherImpl::RemoveAllUnprocessedPrefetchURLs( | 51 void PrefetchDispatcherImpl::RemoveAllUnprocessedPrefetchURLs( |
47 const std::string& name_space) { | 52 const std::string& name_space) { |
48 if (!IsPrefetchingOfflinePagesEnabled()) | 53 if (!IsPrefetchingOfflinePagesEnabled()) |
49 return; | 54 return; |
50 | 55 |
51 NOTIMPLEMENTED(); | 56 NOTIMPLEMENTED(); |
52 } | 57 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 96 |
92 void PrefetchDispatcherImpl::GCMOperationCompletedMessageReceived( | 97 void PrefetchDispatcherImpl::GCMOperationCompletedMessageReceived( |
93 const std::string& operation_name) { | 98 const std::string& operation_name) { |
94 if (!IsPrefetchingOfflinePagesEnabled()) | 99 if (!IsPrefetchingOfflinePagesEnabled()) |
95 return; | 100 return; |
96 | 101 |
97 NOTIMPLEMENTED(); | 102 NOTIMPLEMENTED(); |
98 } | 103 } |
99 | 104 |
100 } // namespace offline_pages | 105 } // namespace offline_pages |
OLD | NEW |