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_DOODLE_DOODLE_SERVICE_H_ | 5 #ifndef COMPONENTS_DOODLE_DOODLE_SERVICE_H_ |
6 #define COMPONENTS_DOODLE_DOODLE_SERVICE_H_ | 6 #define COMPONENTS_DOODLE_DOODLE_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 // changes; to get the current (cached) config, call |config()|. | 52 // changes; to get the current (cached) config, call |config()|. |
53 void AddObserver(Observer* observer); | 53 void AddObserver(Observer* observer); |
54 | 54 |
55 // Prevents |observer| from receiving future updates. This is safe to call | 55 // Prevents |observer| from receiving future updates. This is safe to call |
56 // even when the observer is being notified of an update. | 56 // even when the observer is being notified of an update. |
57 void RemoveObserver(Observer* observer); | 57 void RemoveObserver(Observer* observer); |
58 | 58 |
59 // Requests an asynchronous refresh of the DoodleConfig from the network. | 59 // Requests an asynchronous refresh of the DoodleConfig from the network. |
60 // After the update completes, the observers will be notified only if the | 60 // After the update completes, the observers will be notified only if the |
61 // config changed. | 61 // config changed. |
62 void Refresh(); | 62 // Returns true if the refresh actually triggered a fetch. Returns false if |
63 // refreshing was skipped (because the refresh interval hasn't passed yet). | |
tschumann
2017/04/20 18:53:11
nit: i'd simplify the last sentence. what about:
R
fhorschig
2017/04/24 13:52:34
Sounds good!
| |
64 bool Refresh(); | |
63 | 65 |
64 private: | 66 private: |
65 // Note: Keep in sync with the corresponding enum in histograms.xml. Never | 67 // Note: Keep in sync with the corresponding enum in histograms.xml. Never |
66 // remove values, and only insert new values at the end. | 68 // remove values, and only insert new values at the end. |
67 enum DownloadOutcome { | 69 enum DownloadOutcome { |
68 OUTCOME_NEW_DOODLE = 0, | 70 OUTCOME_NEW_DOODLE = 0, |
69 OUTCOME_REVALIDATED_DOODLE = 1, | 71 OUTCOME_REVALIDATED_DOODLE = 1, |
70 OUTCOME_CHANGED_DOODLE = 2, | 72 OUTCOME_CHANGED_DOODLE = 2, |
71 OUTCOME_NO_DOODLE = 3, | 73 OUTCOME_NO_DOODLE = 3, |
72 OUTCOME_EXPIRED = 4, | 74 OUTCOME_EXPIRED = 4, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 | 127 |
126 // The list of observers to be notified when the DoodleConfig changes. | 128 // The list of observers to be notified when the DoodleConfig changes. |
127 base::ObserverList<Observer> observers_; | 129 base::ObserverList<Observer> observers_; |
128 | 130 |
129 DISALLOW_COPY_AND_ASSIGN(DoodleService); | 131 DISALLOW_COPY_AND_ASSIGN(DoodleService); |
130 }; | 132 }; |
131 | 133 |
132 } // namespace doodle | 134 } // namespace doodle |
133 | 135 |
134 #endif // COMPONENTS_DOODLE_DOODLE_SERVICE_H_ | 136 #endif // COMPONENTS_DOODLE_DOODLE_SERVICE_H_ |
OLD | NEW |