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 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" | |
|
Marc Treib
2017/03/27 11:31:00
I think this can just be forward declared.
jkrcal
2017/03/27 14:09:31
Done.
| |
| 9 | 10 |
| 10 namespace ntp_snippets { | 11 namespace ntp_snippets { |
| 11 | 12 |
| 12 // Interface for informing the scheduler. | 13 // Interface for informing the scheduler. |
| 13 class RemoteSuggestionsScheduler { | 14 class RemoteSuggestionsScheduler { |
| 14 public: | 15 public: |
| 15 // Internal triggers to consider fetching content suggestions. | 16 // Internal triggers to consider fetching content suggestions. |
| 16 | 17 |
| 17 // Called whenever the remote suggestions provider becomes active (on startup, | 18 // Called whenever the remote suggestions provider becomes active (on startup, |
| 18 // or later on). | 19 // or later on). |
| 19 virtual void OnProviderActivated() = 0; | 20 virtual void OnProviderActivated() = 0; |
| 20 | 21 |
| 21 // Called whenever the remote suggestions provider becomes inactive (on | 22 // Called whenever the remote suggestions provider becomes inactive (on |
| 22 // startup, or later on). | 23 // startup, or later on). |
| 23 virtual void OnProviderDeactivated() = 0; | 24 virtual void OnProviderDeactivated() = 0; |
| 24 | 25 |
| 25 // Called whenever the remote suggestions provider clears all suggestions. | 26 // Called whenever the remote suggestions provider clears all suggestions. |
| 26 virtual void OnSuggestionsCleared() = 0; | 27 virtual void OnSuggestionsCleared() = 0; |
| 27 | 28 |
| 28 // Called whenever the remote suggestions provider clears all suggestions | 29 // Called whenever the remote suggestions provider clears all suggestions |
| 29 // because history gets cleared (and we must not show them any more). | 30 // because history gets cleared (and we must not show them any more). |
| 30 virtual void OnHistoryCleared() = 0; | 31 virtual void OnHistoryCleared() = 0; |
| 31 | 32 |
| 33 // Returns true if quota is available for another request. | |
| 34 virtual bool AcquireQuotaForInteractiveFetch() = 0; | |
| 35 | |
| 36 // Called whenever the remote suggestions provider finishes an interactive | |
| 37 // fetch (with provided |fetch_status|). | |
| 38 virtual void OnInteractiveFetchFinished(Status fetch_status) = 0; | |
|
Marc Treib
2017/03/27 11:31:00
#include for Status?
jkrcal
2017/03/27 14:09:31
I forward-declared it.
| |
| 39 | |
| 32 // External triggers to consider fetching content suggestions. | 40 // External triggers to consider fetching content suggestions. |
| 33 | 41 |
| 34 // Called whenever chrome is started warm or the user switches to Chrome. | 42 // Called whenever chrome is started warm or the user switches to Chrome. |
| 35 virtual void OnBrowserForegrounded() = 0; | 43 virtual void OnBrowserForegrounded() = 0; |
| 36 | 44 |
| 37 // Called whenever chrome is cold started. | 45 // Called whenever chrome is cold started. |
| 38 // To keep start ups fast, defer any work possible. | 46 // To keep start ups fast, defer any work possible. |
| 39 virtual void OnBrowserColdStart() = 0; | 47 virtual void OnBrowserColdStart() = 0; |
| 40 | 48 |
| 41 // Called whenever a new NTP is opened. This may be called on cold starts. | 49 // 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. | 50 // So to keep start ups fast, defer heavy work for cold starts. |
| 43 virtual void OnNTPOpened() = 0; | 51 virtual void OnNTPOpened() = 0; |
| 44 | 52 |
| 45 // Fetch content suggestions. | 53 // Fetch content suggestions. |
| 46 virtual void OnPersistentSchedulerWakeUp() = 0; | 54 virtual void OnPersistentSchedulerWakeUp() = 0; |
| 47 | 55 |
| 48 // Force rescheduling of fetching. | 56 // Force rescheduling of fetching. |
| 49 virtual void RescheduleFetching() = 0; | 57 virtual void RescheduleFetching() = 0; |
| 58 | |
| 59 void set_provider(RemoteSuggestionsProvider* provider) { | |
| 60 provider_ = provider; | |
| 61 }; | |
| 62 | |
| 63 protected: | |
| 64 // Interface for doing all the actual work (apart from scheduling). | |
| 65 RemoteSuggestionsProvider* provider_; | |
|
Marc Treib
2017/03/27 11:31:00
Maybe move this out of the interface and into the
jkrcal
2017/03/27 14:09:31
Moved out.
| |
| 50 }; | 66 }; |
| 51 | 67 |
| 52 } // namespace ntp_snippets | 68 } // namespace ntp_snippets |
| 53 | 69 |
| 54 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ | 70 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_ |
| OLD | NEW |