Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: components/doodle/doodle_service.cc

Issue 2752563003: [Doodle] Make DoodleService a KeyedService and add a factory (Closed)
Patch Set: Move factory to c/b/doodle Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/doodle/doodle_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/doodle/doodle_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698