| 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 #include "components/doodle/doodle_service.h" | 5 #include "components/doodle/doodle_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 base::Time expiry_date = base::Time::FromInternalValue( | 41 base::Time expiry_date = base::Time::FromInternalValue( |
| 42 pref_service_->GetInt64(prefs::kCachedConfigExpiry)); | 42 pref_service_->GetInt64(prefs::kCachedConfigExpiry)); |
| 43 base::Optional<DoodleConfig> config = DoodleConfig::FromDictionary( | 43 base::Optional<DoodleConfig> config = DoodleConfig::FromDictionary( |
| 44 *pref_service_->GetDictionary(prefs::kCachedConfig), base::nullopt); | 44 *pref_service_->GetDictionary(prefs::kCachedConfig), base::nullopt); |
| 45 UpdateCachedConfig(expiry_date - clock_->Now(), config); | 45 UpdateCachedConfig(expiry_date - clock_->Now(), config); |
| 46 } | 46 } |
| 47 | 47 |
| 48 DoodleService::~DoodleService() = default; | 48 DoodleService::~DoodleService() = default; |
| 49 | 49 |
| 50 void DoodleService::Shutdown() {} |
| 51 |
| 50 void DoodleService::AddObserver(Observer* observer) { | 52 void DoodleService::AddObserver(Observer* observer) { |
| 51 observers_.AddObserver(observer); | 53 observers_.AddObserver(observer); |
| 52 } | 54 } |
| 53 | 55 |
| 54 void DoodleService::RemoveObserver(Observer* observer) { | 56 void DoodleService::RemoveObserver(Observer* observer) { |
| 55 observers_.RemoveObserver(observer); | 57 observers_.RemoveObserver(observer); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void DoodleService::Refresh() { | 60 void DoodleService::Refresh() { |
| 59 fetcher_->FetchDoodle( | 61 fetcher_->FetchDoodle( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 expiry_timer_->Stop(); | 108 expiry_timer_->Stop(); |
| 107 } | 109 } |
| 108 } | 110 } |
| 109 | 111 |
| 110 void DoodleService::DoodleExpired() { | 112 void DoodleService::DoodleExpired() { |
| 111 DCHECK(cached_config_.has_value()); | 113 DCHECK(cached_config_.has_value()); |
| 112 UpdateCachedConfig(base::TimeDelta(), base::nullopt); | 114 UpdateCachedConfig(base::TimeDelta(), base::nullopt); |
| 113 } | 115 } |
| 114 | 116 |
| 115 } // namespace doodle | 117 } // namespace doodle |
| OLD | NEW |