Chromium Code Reviews| Index: net/cert/sth_distributor.cc |
| diff --git a/net/cert/sth_distributor.cc b/net/cert/sth_distributor.cc |
| index 0b8df2606660cd0e60a47b9756bc7d3d3b5a95fa..38dd525f7320b94b650fc842e363e38789567ada 100644 |
| --- a/net/cert/sth_distributor.cc |
| +++ b/net/cert/sth_distributor.cc |
| @@ -24,6 +24,16 @@ STHDistributor::STHDistributor() |
| STHDistributor::~STHDistributor() {} |
| void STHDistributor::NewSTHObserved(const SignedTreeHead& sth) { |
| + auto it = std::find_if(observed_sths_.begin(), observed_sths_.end(), |
| + [&sth](const SignedTreeHead& other) { |
| + return sth.log_id == other.log_id; |
| + }); |
| + |
| + if (it == observed_sths_.end()) |
| + observed_sths_.push_back(sth); |
| + else |
| + *it = sth; |
| + |
| FOR_EACH_OBSERVER(STHObserver, observer_list_, NewSTHObserved(sth)); |
| if (sth.log_id.compare(0, sth.log_id.size(), kPilotLogID, |
| @@ -38,6 +48,8 @@ void STHDistributor::NewSTHObserved(const SignedTreeHead& sth) { |
| void STHDistributor::RegisterObserver(STHObserver* observer) { |
| observer_list_.AddObserver(observer); |
| + for (const auto& sth : observed_sths_) |
| + observer->NewSTHObserved(sth); |
|
Ryan Sleevi
2016/05/16 19:19:01
DESIGN/DANGER/SAFETY: It seems possible that |obse
Eran Messeri
2016/05/17 09:51:03
Good point - switched to your first suggestion of
|
| } |
| void STHDistributor::UnregisterObserver(STHObserver* observer) { |