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

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_service.h

Issue 2864293003: [Offline Pages] Add a GCMAppHandler for offline page prefetch. (Closed)
Patch Set: Move Content Suggestions Observer to //components/offline_pages/core and modify lifetime management Created 3 years, 7 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 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 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_H_
7 7
8 #include "components/keyed_service/core/keyed_service.h" 8 #include "components/keyed_service/core/keyed_service.h"
9 #include "components/offline_pages/core/offline_page_item.h" 9 #include "components/offline_pages/core/offline_page_item.h"
10 10
11 class GURL; 11 class GURL;
12 12
13 namespace ntp_snippets {
14 class ContentSuggestionsService;
15 }
16
13 namespace offline_pages { 17 namespace offline_pages {
14 18
15 // Main class for the Offline Pages Prefetching feature, which will ask a server 19 // 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 20 // to package content from interesting URLs and send it to Chrome for
17 // consumption while offline. 21 // consumption while offline.
18 class PrefetchService : public KeyedService { 22 class PrefetchService : public KeyedService {
19 public: 23 public:
20 struct PrefetchURL { 24 struct PrefetchURL {
21 // Used to differentiate URLs from different sources. |name_space| should 25 // Used to differentiate URLs from different sources. |name_space| should
22 // be unique per source. |id| can be anything useful to identify the page, 26 // be unique per source. |id| can be anything useful to identify the page,
(...skipping 12 matching lines...) Expand all
35 ScopedBackgroundTask() = default; 39 ScopedBackgroundTask() = default;
36 virtual ~ScopedBackgroundTask() = default; 40 virtual ~ScopedBackgroundTask() = default;
37 41
38 // Used on destruction to inform the system about whether rescheduling is 42 // Used on destruction to inform the system about whether rescheduling is
39 // required. 43 // required.
40 virtual void SetNeedsReschedule(bool reschedule) = 0; 44 virtual void SetNeedsReschedule(bool reschedule) = 0;
41 }; 45 };
42 46
43 ~PrefetchService() override = default; 47 ~PrefetchService() override = default;
44 48
49 // Called at construction of the ContentSuggestionsService to begin observing
50 // events related to incoming articles.
51 virtual void ObserveContentSuggestionsService(
52 ntp_snippets::ContentSuggestionsService* service) = 0;
53
45 // Called when a consumer has candidate URLs for the system to prefetch. 54 // Called when a consumer has candidate URLs for the system to prefetch.
46 // Duplicates are accepted by the PrefetchService but ignored. 55 // Duplicates are accepted by the PrefetchService but ignored.
47 virtual void AddCandidatePrefetchURLs( 56 virtual void AddCandidatePrefetchURLs(
48 const std::vector<PrefetchURL>& prefetch_urls) = 0; 57 const std::vector<PrefetchURL>& prefetch_urls) = 0;
49 58
50 // Called when all existing suggestions are no longer considered valid for a 59 // Called when all existing suggestions are no longer considered valid for a
51 // given namespace. The prefetch service should remove any URLs that 60 // given namespace. The prefetch service should remove any URLs that
52 // have not yet started downloading within that namespace. 61 // have not yet started downloading within that namespace.
53 virtual void RemoveAllUnprocessedPrefetchURLs( 62 virtual void RemoveAllUnprocessedPrefetchURLs(
54 const std::string& name_space) = 0; 63 const std::string& name_space) = 0;
(...skipping 10 matching lines...) Expand all
65 74
66 // Called when a task must stop immediately due to system constraints. After 75 // Called when a task must stop immediately due to system constraints. After
67 // this call completes, the system will reschedule the task based on whether 76 // this call completes, the system will reschedule the task based on whether
68 // SetNeedsReschedule has been called. 77 // SetNeedsReschedule has been called.
69 virtual void StopBackgroundTask(ScopedBackgroundTask* task) = 0; 78 virtual void StopBackgroundTask(ScopedBackgroundTask* task) = 0;
70 }; 79 };
71 80
72 } // namespace offline_pages 81 } // namespace offline_pages
73 82
74 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ 83 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698