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

Side by Side Diff: net/cert/sth_distributor.h

Issue 1968053002: Certificate Transparency: Notify STH Observers of known STHs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | net/cert/sth_distributor.cc » ('j') | net/cert/sth_distributor.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_CERT_STH_DISTRIBUTOR_H_ 5 #ifndef NET_CERT_STH_DISTRIBUTOR_H_
6 #define NET_CERT_STH_DISTRIBUTOR_H_ 6 #define NET_CERT_STH_DISTRIBUTOR_H_
7 7
8 #include "base/observer_list.h" 8 #include "base/observer_list.h"
9 #include "net/base/net_export.h" 9 #include "net/base/net_export.h"
10 #include "net/cert/sth_observer.h" 10 #include "net/cert/sth_observer.h"
11 #include "net/cert/sth_reporter.h" 11 #include "net/cert/sth_reporter.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 namespace ct { 15 namespace ct {
16 16
17 namespace internal {
18
19 // Compares SignedTreeHeads by their log ID, to facilitate creation of a
20 // map of STHs where there's only one STH for each log.
21 struct STHLogIDComparator {
22 bool operator()(const SignedTreeHead& first, const SignedTreeHead& second);
23 };
24
25 } // namespace internal
Ryan Sleevi 2016/05/12 19:51:28 DESIGN: You don't need to expose this in a public
Eran Messeri 2016/05/13 09:04:08 Done.
26
17 // A proxy for delegating new STH notifications to all registered 27 // A proxy for delegating new STH notifications to all registered
18 // observers. 28 // observers.
19 // For each |observer| registered with RegisterObserver, the 29 // For each |observer| registered with RegisterObserver, the
20 // NewSTHObserved method will be called whenever the STHDistributor's 30 // NewSTHObserved method will be called whenever the STHDistributor's
21 // NewSTHObserved method is invoked. 31 // NewSTHObserved method is invoked.
22 class NET_EXPORT STHDistributor : public STHObserver, public STHReporter { 32 class NET_EXPORT STHDistributor : public STHObserver, public STHReporter {
23 public: 33 public:
24 STHDistributor(); 34 STHDistributor();
25 ~STHDistributor() override; 35 ~STHDistributor() override;
26 36
27 // STHObserver implementation. 37 // STHObserver implementation.
28 void NewSTHObserved(const SignedTreeHead& sth) override; 38 void NewSTHObserved(const SignedTreeHead& sth) override;
29 39
30 // STHReporter implementation 40 // STHReporter implementation
41 // Registers |observer| for new STH notifications and invokes the
42 // new STH notification of this |observer| with observed STHs (one
43 // per log).
31 void RegisterObserver(STHObserver* observer) override; 44 void RegisterObserver(STHObserver* observer) override;
45
46 // Unregisters |observer|, should only be called with observers
47 // that were previously registered via RegisterObserver;
32 void UnregisterObserver(STHObserver* observer) override; 48 void UnregisterObserver(STHObserver* observer) override;
33 49
34 private: 50 private:
51 // Set of unique STHs from logs.
52 std::set<SignedTreeHead, internal::STHLogIDComparator> observed_sths_;
Ryan Sleevi 2016/05/12 19:51:28 DESIGN: An std::set<> is pretty inefficient for yo
Eran Messeri 2016/05/13 09:04:08 Done.
53
54 // The observers for new STH notifications.
35 base::ObserverList<STHObserver> observer_list_; 55 base::ObserverList<STHObserver> observer_list_;
36 }; 56 };
37 57
38 } // namespace ct 58 } // namespace ct
39 59
40 } // namespace net 60 } // namespace net
41 61
42 #endif // NET_CERT_STH_DISTRIBUTOR_H_ 62 #endif // NET_CERT_STH_DISTRIBUTOR_H_
OLDNEW
« no previous file with comments | « no previous file | net/cert/sth_distributor.cc » ('j') | net/cert/sth_distributor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698