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
3 // found in the LICENSE file.
4
5 #include "components/offline_pages/core/prefetch/test_prefetch_dispatcher.h"
6
7 #include "components/offline_pages/core/offline_page_item.h"
8 #include "components/offline_pages/core/prefetch/prefetch_background_task.h"
9
10 namespace offline_pages {
11
12 TestPrefetchDispatcher::TestPrefetchDispatcher() = default;
13 TestPrefetchDispatcher::~TestPrefetchDispatcher() = default;
14
AddCandidatePrefetchURLs(const std::string & name_space,const std::vector<PrefetchURL> & prefetch_urls)15 void TestPrefetchDispatcher::AddCandidatePrefetchURLs(
16 const std::string& name_space,
17 const std::vector<PrefetchURL>& prefetch_urls) {
18 latest_name_space = name_space;
19 latest_prefetch_urls = prefetch_urls;
20 new_suggestions_count++;
21 }
22
NewSuggestionsAvailable(SuggestionsProvider * suggestions_provider)23 void TestPrefetchDispatcher::NewSuggestionsAvailable(
24 SuggestionsProvider* suggestions_provider) {}
25
RemoveSuggestion(const GURL & url)26 void TestPrefetchDispatcher::RemoveSuggestion(const GURL& url) {}
27
RemoveAllUnprocessedPrefetchURLs(const std::string & name_space)28 void TestPrefetchDispatcher::RemoveAllUnprocessedPrefetchURLs(
29 const std::string& name_space) {
30 latest_prefetch_urls.clear();
31 remove_all_suggestions_count++;
32 }
33
RemovePrefetchURLsByClientId(const ClientId & client_id)34 void TestPrefetchDispatcher::RemovePrefetchURLsByClientId(
35 const ClientId& client_id) {
36 remove_by_client_id_count++;
37 last_removed_client_id = std::make_unique<ClientId>(client_id);
38 }
39
BeginBackgroundTask(std::unique_ptr<PrefetchBackgroundTask> task)40 void TestPrefetchDispatcher::BeginBackgroundTask(
41 std::unique_ptr<PrefetchBackgroundTask> task) {}
42
StopBackgroundTask()43 void TestPrefetchDispatcher::StopBackgroundTask() {}
44
SetService(PrefetchService * service)45 void TestPrefetchDispatcher::SetService(PrefetchService* service) {}
46
SchedulePipelineProcessing()47 void TestPrefetchDispatcher::SchedulePipelineProcessing() {
48 processing_schedule_count++;
49 }
50
EnsureTaskScheduled()51 void TestPrefetchDispatcher::EnsureTaskScheduled() {
52 task_schedule_count++;
53 }
54
GCMOperationCompletedMessageReceived(const std::string & operation_name)55 void TestPrefetchDispatcher::GCMOperationCompletedMessageReceived(
56 const std::string& operation_name) {
57 operation_list.push_back(operation_name);
58 }
59
CleanupDownloads(const std::set<std::string> & outstanding_download_ids,const std::map<std::string,std::pair<base::FilePath,int64_t>> & success_downloads)60 void TestPrefetchDispatcher::CleanupDownloads(
61 const std::set<std::string>& outstanding_download_ids,
62 const std::map<std::string, std::pair<base::FilePath, int64_t>>&
63 success_downloads) {
64 cleanup_downloads_count++;
65 }
66
GeneratePageBundleRequested(std::unique_ptr<IdsVector> ids)67 void TestPrefetchDispatcher::GeneratePageBundleRequested(
68 std::unique_ptr<IdsVector> ids) {
69 generate_page_bundle_requested++;
70 ids_from_generate_page_bundle_requested = std::move(ids);
71 }
72
DownloadCompleted(const PrefetchDownloadResult & download_result)73 void TestPrefetchDispatcher::DownloadCompleted(
74 const PrefetchDownloadResult& download_result) {
75 download_results.push_back(download_result);
76 }
77
ItemDownloaded(int64_t offline_id,const ClientId & client_id)78 void TestPrefetchDispatcher::ItemDownloaded(int64_t offline_id,
79 const ClientId& client_id) {
80 item_downloaded_results.push_back(std::make_pair(offline_id, client_id));
81 }
82
ArchiveImported(int64_t offline_id,bool success)83 void TestPrefetchDispatcher::ArchiveImported(int64_t offline_id, bool success) {
84 import_results.push_back(std::make_pair(offline_id, success));
85 }
86
87 } // namespace offline_pages
88