OLD | NEW |
(Empty) | |
| 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 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_H_ |
| 7 |
| 8 #include "components/keyed_service/core/keyed_service.h" |
| 9 #include "components/offline_pages/core/offline_page_item.h" |
| 10 |
| 11 class GURL; |
| 12 |
| 13 namespace offline_pages { |
| 14 |
| 15 // Main class for the Offline Pages Prefetching feature, which will ask a server |
| 16 // to package content from interesting URLs and send it to Chrome for |
| 17 // consumption while offline. |
| 18 class PrefetchService : public KeyedService { |
| 19 public: |
| 20 struct PrefetchURL { |
| 21 // Used to differentiate URLs from different sources. |name_space| should |
| 22 // be unique per source. |id| can be anything useful to identify the page, |
| 23 // but will not be used for deduplication. |
| 24 ClientId client_id; |
| 25 |
| 26 // This URL will be prefetched by the service. |
| 27 GURL url; |
| 28 }; |
| 29 |
| 30 ~PrefetchService() override = default; |
| 31 |
| 32 // Called when a consumer has candidate URLs for the system to prefetch. |
| 33 // Duplicates are accepted by the PrefetchService but ignored. |
| 34 virtual void AddCandidatePrefetchURLs( |
| 35 const std::vector<PrefetchURL>& prefetch_urls) = 0; |
| 36 |
| 37 // Called when all existing suggestions are no longer considered valid for a |
| 38 // given namespace. The prefetch service should remove any URLs that |
| 39 // have not yet started downloading within that namespace. |
| 40 virtual void RemoveAllUnprocessedPrefetchURLs( |
| 41 const std::string& name_space) = 0; |
| 42 |
| 43 // Called to invalidate a single PrefetchURL entry identified by |client_id|. |
| 44 // If multiple have the same |client_id|, they will all be removed. |
| 45 virtual void RemovePrefetchURLsByClientId(const ClientId& client_id) = 0; |
| 46 }; |
| 47 |
| 48 } // namespace offline_pages |
| 49 |
| 50 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ |
OLD | NEW |