Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SEARCH_ONE_GOOGLE_BAR_ONE_GOOGLE_BAR_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_SEARCH_ONE_GOOGLE_BAR_ONE_GOOGLE_BAR_SERVICE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/observer_list.h" | |
| 11 #include "base/optional.h" | |
| 12 #include "chrome/browser/search/one_google_bar/one_google_bar_data.h" | |
| 13 #include "chrome/browser/search/one_google_bar/one_google_bar_service_observer.h " | |
| 14 #include "components/keyed_service/core/keyed_service.h" | |
| 15 | |
| 16 class OneGoogleBarFetcher; | |
| 17 class SigninManagerBase; | |
| 18 | |
| 19 // A service that downloads, caches, and hands out OneGoogleBarData. | |
|
sfiera
2017/04/13 15:18:31
I'd like a little detail about what is expected to
Marc Treib
2017/04/13 15:44:02
It never initiates fetches itself. Comment added.
| |
| 20 class OneGoogleBarService : public KeyedService { | |
|
sfiera
2017/04/13 15:18:31
No expected need to split this into interface/impl
Marc Treib
2017/04/13 15:44:02
Nope :)
| |
| 21 public: | |
| 22 OneGoogleBarService(SigninManagerBase* signin_manager, | |
| 23 std::unique_ptr<OneGoogleBarFetcher> fetcher); | |
| 24 ~OneGoogleBarService() override; | |
| 25 | |
| 26 // KeyedService implementation. | |
| 27 void Shutdown() override; | |
| 28 | |
| 29 // Returns the currently cached OneGoogleBarData, if any. | |
| 30 const base::Optional<OneGoogleBarData>& one_google_bar_data() const { | |
| 31 return one_google_bar_data_; | |
| 32 } | |
| 33 | |
| 34 // Requests an asynchronous refresh from the network. After the update | |
| 35 // completes, the observers will be notified only if something changed. | |
| 36 void Refresh(); | |
|
sfiera
2017/04/13 15:18:31
For my curiosity, who are you expecting to call th
Marc Treib
2017/04/13 15:44:02
The plan was: Open NTP, immediately serve the cach
sfiera
2017/04/13 15:58:33
Do we have a list of all of the places we have thi
Marc Treib
2017/04/13 16:45:15
That seems to be quite a comprehensive list; I can
| |
| 37 | |
| 38 // Add/remove observers. All observers must unregister themselves before the | |
| 39 // OneGoogleBarService is destroyed. | |
| 40 void AddObserver(OneGoogleBarServiceObserver* observer); | |
| 41 void RemoveObserver(OneGoogleBarServiceObserver* observer); | |
| 42 | |
| 43 private: | |
| 44 class SigninObserver; | |
| 45 | |
| 46 void SigninStatusChanged(); | |
| 47 | |
| 48 void SetOneGoogleBarData(const base::Optional<OneGoogleBarData>& data); | |
| 49 | |
| 50 std::unique_ptr<OneGoogleBarFetcher> fetcher_; | |
| 51 | |
| 52 std::unique_ptr<SigninObserver> signin_observer_; | |
| 53 | |
| 54 base::ObserverList<OneGoogleBarServiceObserver, true> observers_; | |
| 55 | |
| 56 base::Optional<OneGoogleBarData> one_google_bar_data_; | |
| 57 }; | |
| 58 | |
| 59 #endif // CHROME_BROWSER_SEARCH_ONE_GOOGLE_BAR_ONE_GOOGLE_BAR_SERVICE_H_ | |
| OLD | NEW |