| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Note: Read the class comment of AffiliationService for the definition of the | 5 // Note: Read the class comment of AffiliationService for the definition of the |
| 6 // terms used below. | 6 // terms used below. |
| 7 // | 7 // |
| 8 // On-demand fetching strategy | 8 // On-demand fetching strategy |
| 9 // | 9 // |
| 10 // A GetAffiliations() request concerning facet X will be served from the cache | 10 // A GetAffiliations() request concerning facet X will be served from the cache |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 keep_fresh_until_thresholds_.upper_bound(clock_->Now()); | 180 keep_fresh_until_thresholds_.upper_bound(clock_->Now()); |
| 181 keep_fresh_until_thresholds_.erase(keep_fresh_until_thresholds_.begin(), | 181 keep_fresh_until_thresholds_.erase(keep_fresh_until_thresholds_.begin(), |
| 182 iter_first_non_expired); | 182 iter_first_non_expired); |
| 183 } | 183 } |
| 184 | 184 |
| 185 bool FacetManager::CanBeDiscarded() const { | 185 bool FacetManager::CanBeDiscarded() const { |
| 186 return pending_requests_.empty() && | 186 return pending_requests_.empty() && |
| 187 GetMaximumKeepFreshUntilThreshold() <= clock_->Now(); | 187 GetMaximumKeepFreshUntilThreshold() <= clock_->Now(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool FacetManager::CanCachedDataBeDiscarded() const { |
| 191 return GetMaximumKeepFreshUntilThreshold() <= clock_->Now() || |
| 192 !IsCachedDataFresh(); |
| 193 } |
| 194 |
| 190 bool FacetManager::DoesRequireFetch() const { | 195 bool FacetManager::DoesRequireFetch() const { |
| 191 return (!pending_requests_.empty() && !IsCachedDataFresh()) || | 196 return (!pending_requests_.empty() && !IsCachedDataFresh()) || |
| 192 GetNextRequiredFetchTimeDueToPrefetch() <= clock_->Now(); | 197 GetNextRequiredFetchTimeDueToPrefetch() <= clock_->Now(); |
| 193 } | 198 } |
| 194 | 199 |
| 195 bool FacetManager::IsCachedDataFresh() const { | 200 bool FacetManager::IsCachedDataFresh() const { |
| 196 return clock_->Now() < GetCacheHardExpiryTime(); | 201 return clock_->Now() < GetCacheHardExpiryTime(); |
| 197 } | 202 } |
| 198 | 203 |
| 199 bool FacetManager::IsCachedDataNearStale() const { | 204 bool FacetManager::IsCachedDataNearStale() const { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 FROM_HERE, base::Bind(request_info.callback, affiliation, true)); | 240 FROM_HERE, base::Bind(request_info.callback, affiliation, true)); |
| 236 } | 241 } |
| 237 | 242 |
| 238 // static | 243 // static |
| 239 void FacetManager::ServeRequestWithFailure(const RequestInfo& request_info) { | 244 void FacetManager::ServeRequestWithFailure(const RequestInfo& request_info) { |
| 240 request_info.callback_task_runner->PostTask( | 245 request_info.callback_task_runner->PostTask( |
| 241 FROM_HERE, base::Bind(request_info.callback, AffiliatedFacets(), false)); | 246 FROM_HERE, base::Bind(request_info.callback, AffiliatedFacets(), false)); |
| 242 } | 247 } |
| 243 | 248 |
| 244 } // namespace password_manager | 249 } // namespace password_manager |
| OLD | NEW |