| 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 #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 11 matching lines...) Expand all Loading... |
| 22 class PrefetchDispatcher { | 22 class PrefetchDispatcher { |
| 23 public: | 23 public: |
| 24 // A |ScopedBackgroundTask| is created when we are running in a background | 24 // A |ScopedBackgroundTask| is created when we are running in a background |
| 25 // task. Destroying this object should notify the system that we are done | 25 // task. Destroying this object should notify the system that we are done |
| 26 // processing the background task. | 26 // processing the background task. |
| 27 class ScopedBackgroundTask { | 27 class ScopedBackgroundTask { |
| 28 public: | 28 public: |
| 29 ScopedBackgroundTask() = default; | 29 ScopedBackgroundTask() = default; |
| 30 virtual ~ScopedBackgroundTask() = default; | 30 virtual ~ScopedBackgroundTask() = default; |
| 31 | 31 |
| 32 // Used on destruction to inform the system about whether rescheduling is | 32 // Used on destruction to inform the system about whether rescheduling with |
| 33 // required. | 33 // or without backoff is required. |
| 34 virtual void SetNeedsReschedule(bool reschedule) = 0; | 34 virtual void SetNeedsReschedule(bool reschedule, bool backoff) = 0; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 virtual ~PrefetchDispatcher() = default; | 37 virtual ~PrefetchDispatcher() = default; |
| 38 | 38 |
| 39 // Initializes the dispatcher with its respective service instance. This must | 39 // Initializes the dispatcher with its respective service instance. This must |
| 40 // be done before any other methods are called. | 40 // be done before any other methods are called. |
| 41 virtual void SetService(PrefetchService* service) = 0; | 41 virtual void SetService(PrefetchService* service) = 0; |
| 42 | 42 |
| 43 // Called when a client has candidate URLs for the system to prefetch, along | 43 // Called when a client has candidate URLs for the system to prefetch, along |
| 44 // with the client's unique namespace. URLs that are currently in the system | 44 // with the client's unique namespace. URLs that are currently in the system |
| (...skipping 13 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 // Called when Android OS has scheduled us for background work. When | 59 // Called when Android OS has scheduled us for background work. When |
| 60 // destroyed, |task| will call back and inform the OS that we are done work | 60 // destroyed, |task| will call back and inform the OS that we are done work |
| 61 // (if required). |task| also manages rescheduling behavior. | 61 // (if required). |task| also manages rescheduling behavior. |
| 62 virtual void BeginBackgroundTask( | 62 virtual void BeginBackgroundTask( |
| 63 std::unique_ptr<ScopedBackgroundTask> task) = 0; | 63 std::unique_ptr<ScopedBackgroundTask> task) = 0; |
| 64 | 64 |
| 65 // Called when a task must stop immediately due to system constraints. After | 65 // Called when a task must stop immediately due to system constraints. After |
| 66 // this call completes, the system will reschedule the task based on whether | 66 // this call completes, the system will reschedule the task based on whether |
| 67 // SetNeedsReschedule has been called. | 67 // SetNeedsReschedule has been called. |
| 68 virtual void StopBackgroundTask(ScopedBackgroundTask* task) = 0; | 68 virtual void StopBackgroundTask() = 0; |
| 69 |
| 70 // Used by the test to signal the completion of the background task. |
| 71 virtual void RequestFinishBackgroundTaskForTest() = 0; |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace offline_pages | 74 } // namespace offline_pages |
| 72 | 75 |
| 73 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_ | 76 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_DISPATCHER_H_ |
| OLD | NEW |