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 #include "components/update_client/update_engine.h" | 5 #include "components/update_client/update_engine.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 metadata_(new PersistedData(config->GetPrefService())), | 59 metadata_(new PersistedData(config->GetPrefService())), |
60 notify_observers_callback_(notify_observers_callback) {} | 60 notify_observers_callback_(notify_observers_callback) {} |
61 | 61 |
62 UpdateEngine::~UpdateEngine() { | 62 UpdateEngine::~UpdateEngine() { |
63 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
64 } | 64 } |
65 | 65 |
66 bool UpdateEngine::GetUpdateState(const std::string& id, | 66 bool UpdateEngine::GetUpdateState(const std::string& id, |
67 CrxUpdateItem* update_item) { | 67 CrxUpdateItem* update_item) { |
68 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
69 for (const auto& context : update_contexts_) { | 69 for (const auto* context : update_contexts_) { |
70 const auto& update_items = context->update_items; | 70 const auto& update_items = context->update_items; |
71 const auto it = std::find_if(update_items.begin(), update_items.end(), | 71 const auto it = std::find_if(update_items.begin(), update_items.end(), |
72 [id](const CrxUpdateItem* update_item) { | 72 [id](const CrxUpdateItem* update_item) { |
73 return id == update_item->id; | 73 return id == update_item->id; |
74 }); | 74 }); |
75 if (it != update_items.end()) { | 75 if (it != update_items.end()) { |
76 *update_item = **it; | 76 *update_item = **it; |
77 return true; | 77 return true; |
78 } | 78 } |
79 } | 79 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 const auto now(base::Time::Now()); | 145 const auto now(base::Time::Now()); |
146 | 146 |
147 // Throttle the calls in the interval (t - 1 day, t) to limit the effect of | 147 // Throttle the calls in the interval (t - 1 day, t) to limit the effect of |
148 // unset clocks or clock drift. | 148 // unset clocks or clock drift. |
149 return throttle_updates_until_ - base::TimeDelta::FromDays(1) < now && | 149 return throttle_updates_until_ - base::TimeDelta::FromDays(1) < now && |
150 now < throttle_updates_until_; | 150 now < throttle_updates_until_; |
151 } | 151 } |
152 | 152 |
153 } // namespace update_client | 153 } // namespace update_client |
OLD | NEW |