Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 | 9 |
| 10 namespace ntp_snippets { | 10 namespace ntp_snippets { |
| 11 | 11 |
| 12 // Interface for informing the scheduler. | 12 class RemoteSuggestionsProvider; |
| 13 struct Status; | |
| 14 | |
| 15 // The scheduler for background fetching of remote suggestions has two callers: | |
| 16 // a) The actual provider that implements the fetching informs the scheduler | |
| 17 // about relevant events and changes in its state. | |
| 18 // b) External parties (such as the UI) that need to inform the scheduler about | |
| 19 // their events. | |
| 13 class RemoteSuggestionsScheduler { | 20 class RemoteSuggestionsScheduler { |
| 14 public: | 21 public: |
| 15 // Internal triggers to consider fetching content suggestions. | 22 // ***** Internal triggers to consider fetching content suggestions. ***** |
| 16 | 23 |
| 17 // Called whenever the remote suggestions provider becomes active (on startup, | 24 // Called whenever the remote suggestions provider becomes active (on startup, |
| 18 // or later on). | 25 // or later on). |
| 19 virtual void OnProviderActivated() = 0; | 26 virtual void OnProviderActivated() = 0; |
| 20 | 27 |
| 21 // Called whenever the remote suggestions provider becomes inactive (on | 28 // Called whenever the remote suggestions provider becomes inactive (on |
| 22 // startup, or later on). | 29 // startup, or later on). |
| 23 virtual void OnProviderDeactivated() = 0; | 30 virtual void OnProviderDeactivated() = 0; |
| 24 | 31 |
| 25 // Called whenever the remote suggestions provider clears all suggestions. | 32 // Called whenever the remote suggestions provider clears all suggestions. |
| 26 virtual void OnSuggestionsCleared() = 0; | 33 virtual void OnSuggestionsCleared() = 0; |
| 27 | 34 |
| 28 // Called whenever the remote suggestions provider clears all suggestions | 35 // Called whenever the remote suggestions provider clears all suggestions |
| 29 // because history gets cleared (and we must not show them any more). | 36 // because history gets cleared (and we must not show them any more). |
| 30 virtual void OnHistoryCleared() = 0; | 37 virtual void OnHistoryCleared() = 0; |
| 31 | 38 |
| 32 // External triggers to consider fetching content suggestions. | 39 // Returns true if quota is available for another request. |
| 40 virtual bool AcquireQuotaForInteractiveFetch() = 0; | |
| 41 | |
| 42 // Called whenever the remote suggestions provider finishes an interactive | |
| 43 // fetch (with provided |fetch_status|). | |
| 44 virtual void OnInteractiveFetchFinished(Status fetch_status) = 0; | |
| 45 | |
| 46 // Set the provider that performs background fetching. Should be only called | |
| 47 // by the factory. | |
| 48 virtual void SetProvider(RemoteSuggestionsProvider* provider) = 0; | |
|
Marc Treib
2017/03/27 14:27:21
This isn't considered part of the "internal trigge
jkrcal
2017/03/29 10:55:57
Done.
| |
| 49 | |
| 50 // ***** External triggers to consider fetching content suggestions. ***** | |
| 33 | 51 |
| 34 // Called whenever chrome is started warm or the user switches to Chrome. | 52 // Called whenever chrome is started warm or the user switches to Chrome. |
| 35 virtual void OnBrowserForegrounded() = 0; | 53 virtual void OnBrowserForegrounded() = 0; |
| 36 | 54 |
| 37 // Called whenever chrome is cold started. | 55 // Called whenever chrome is cold started. |
| 38 // To keep start ups fast, defer any work possible. | 56 // To keep start ups fast, defer any work possible. |
| 39 virtual void OnBrowserColdStart() = 0; | 57 virtual void OnBrowserColdStart() = 0; |
| 40 | 58 |
| 41 // Called whenever a new NTP is opened. This may be called on cold starts. | 59 // Called whenever a new NTP is opened. This may be called on cold starts. |
| 42 // So to keep start ups fast, defer heavy work for cold starts. | 60 // So to keep start ups fast, defer heavy work for cold starts. |
| 43 virtual void OnNTPOpened() = 0; | 61 virtual void OnNTPOpened() = 0; |
| 44 | 62 |
| 45 // Fetch content suggestions. | 63 // Fetch content suggestions. |
| 46 virtual void OnPersistentSchedulerWakeUp() = 0; | 64 virtual void OnPersistentSchedulerWakeUp() = 0; |
| 47 | 65 |
| 48 // Force rescheduling of fetching. | 66 // Force rescheduling of fetching. |
| 49 virtual void RescheduleFetching() = 0; | 67 virtual void RescheduleFetching() = 0; |
| 50 }; | 68 }; |
| 51 | 69 |
| 52 } // namespace ntp_snippets | 70 } // namespace ntp_snippets |
| 53 | 71 |
| 54 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ | 72 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ |
| OLD | NEW |