| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "net/cert/sth_distributor.h" | 5 #include "net/cert/sth_distributor.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "net/cert/signed_tree_head.h" | 9 #include "net/cert/signed_tree_head.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 auto it = std::find_if(observed_sths_.begin(), observed_sths_.end(), | 28 auto it = std::find_if(observed_sths_.begin(), observed_sths_.end(), |
| 29 [&sth](const SignedTreeHead& other) { | 29 [&sth](const SignedTreeHead& other) { |
| 30 return sth.log_id == other.log_id; | 30 return sth.log_id == other.log_id; |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 if (it == observed_sths_.end()) | 33 if (it == observed_sths_.end()) |
| 34 observed_sths_.push_back(sth); | 34 observed_sths_.push_back(sth); |
| 35 else | 35 else |
| 36 *it = sth; | 36 *it = sth; |
| 37 | 37 |
| 38 FOR_EACH_OBSERVER(STHObserver, observer_list_, NewSTHObserved(sth)); | 38 for (auto& observer : observer_list_) |
| 39 observer.NewSTHObserved(sth); |
| 39 | 40 |
| 40 if (sth.log_id.compare(0, sth.log_id.size(), | 41 if (sth.log_id.compare(0, sth.log_id.size(), |
| 41 reinterpret_cast<const char*>(kPilotLogID), | 42 reinterpret_cast<const char*>(kPilotLogID), |
| 42 sizeof(kPilotLogID)) != 0) | 43 sizeof(kPilotLogID)) != 0) |
| 43 return; | 44 return; |
| 44 | 45 |
| 45 const base::TimeDelta sth_age = base::Time::Now() - sth.timestamp; | 46 const base::TimeDelta sth_age = base::Time::Now() - sth.timestamp; |
| 46 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertificateTransparency.PilotSTHAge", sth_age, | 47 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertificateTransparency.PilotSTHAge", sth_age, |
| 47 base::TimeDelta::FromHours(1), | 48 base::TimeDelta::FromHours(1), |
| 48 base::TimeDelta::FromDays(4), 100); | 49 base::TimeDelta::FromDays(4), 100); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 observer->NewSTHObserved(sth); | 60 observer->NewSTHObserved(sth); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void STHDistributor::UnregisterObserver(STHObserver* observer) { | 63 void STHDistributor::UnregisterObserver(STHObserver* observer) { |
| 63 observer_list_.RemoveObserver(observer); | 64 observer_list_.RemoveObserver(observer); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace ct | 67 } // namespace ct |
| 67 | 68 |
| 68 } // namespace net | 69 } // namespace net |
| OLD | NEW |