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

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

Issue 2914703002: [Offline Prefetch] Backoff support for PrefetchBackgroundTask (Closed)
Patch Set: Fix trybots Created 3 years, 6 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_DISPATCHER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 }; 32 };
33 33
34 // A |ScopedBackgroundTask| is created when we are running in a background 34 // A |ScopedBackgroundTask| is created when we are running in a background
35 // task. Destroying this object should notify the system that we are done 35 // task. Destroying this object should notify the system that we are done
36 // processing the background task. 36 // processing the background task.
37 class ScopedBackgroundTask { 37 class ScopedBackgroundTask {
38 public: 38 public:
39 ScopedBackgroundTask() = default; 39 ScopedBackgroundTask() = default;
40 virtual ~ScopedBackgroundTask() = default; 40 virtual ~ScopedBackgroundTask() = default;
41 41
42 // Used on destruction to inform the system about whether rescheduling is 42 // Used on destruction to inform the system about whether rescheduling with
43 // required. 43 // or without backoff is required.
44 virtual void SetNeedsReschedule(bool reschedule) = 0; 44 virtual void SetNeedsReschedule(bool reschedule, bool backoff) = 0;
45 }; 45 };
46 46
47 virtual ~PrefetchDispatcher() = default; 47 virtual ~PrefetchDispatcher() = default;
48 48
49 // Called when a consumer has candidate URLs for the system to prefetch. 49 // Called when a consumer has candidate URLs for the system to prefetch.
50 // Duplicates are accepted by the PrefetchDispatcher but ignored. 50 // Duplicates are accepted by the PrefetchDispatcher but ignored.
51 virtual void AddCandidatePrefetchURLs( 51 virtual void AddCandidatePrefetchURLs(
52 const std::vector<PrefetchURL>& prefetch_urls) = 0; 52 const std::vector<PrefetchURL>& prefetch_urls) = 0;
53 53
54 // Called when all existing suggestions are no longer considered valid for a 54 // Called when all existing suggestions are no longer considered valid for a
55 // given namespace. The prefetch system should remove any URLs that 55 // given namespace. The prefetch system should remove any URLs that
56 // have not yet started downloading within that namespace. 56 // have not yet started downloading within that namespace.
57 virtual void RemoveAllUnprocessedPrefetchURLs( 57 virtual void RemoveAllUnprocessedPrefetchURLs(
58 const std::string& name_space) = 0; 58 const std::string& name_space) = 0;
59 59
60 // Called to invalidate a single PrefetchURL entry identified by |client_id|. 60 // Called to invalidate a single PrefetchURL entry identified by |client_id|.
61 // If multiple have the same |client_id|, they will all be removed. 61 // If multiple have the same |client_id|, they will all be removed.
62 virtual void RemovePrefetchURLsByClientId(const ClientId& client_id) = 0; 62 virtual void RemovePrefetchURLsByClientId(const ClientId& client_id) = 0;
63 63
64 // Called when Android OS has scheduled us for background work. When 64 // Called when Android OS has scheduled us for background work. When
65 // destroyed, |task| will call back and inform the OS that we are done work 65 // destroyed, |task| will call back and inform the OS that we are done work
66 // (if required). |task| also manages rescheduling behavior. 66 // (if required). |task| also manages rescheduling behavior.
67 virtual void BeginBackgroundTask( 67 virtual void BeginBackgroundTask(
68 std::unique_ptr<ScopedBackgroundTask> task) = 0; 68 std::unique_ptr<ScopedBackgroundTask> task) = 0;
69 69
70 // Called when a task must stop immediately due to system constraints. After 70 // Called when a task must stop immediately due to system constraints. After
71 // this call completes, the system will reschedule the task based on whether 71 // this call completes, the system will reschedule the task based on whether
72 // SetNeedsReschedule has been called. 72 // SetNeedsReschedule has been called.
73 virtual void StopBackgroundTask(ScopedBackgroundTask* task) = 0; 73 virtual void StopBackgroundTask(bool signaled_by_system) = 0;
dewittj 2017/05/31 21:33:33 Instead of signaled_by_system, can you please have
jianli 2017/06/01 00:09:59 Done.
74 }; 74 };
75 75
76 } // namespace offline_pages 76 } // namespace offline_pages
77 77
78 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_ 78 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698