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

Side by Side Diff: net/cert/sth_observer.cc

Issue 1845113003: Certificate Transparency: Start tracking logs' state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « net/cert/sth_observer.h ('k') | net/net.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/cert/sth_observer.h"
6
7 #include "base/logging.h"
8
9 namespace net {
10
11 namespace ct {
12
13 STHReporterRegistrar::STHReporterRegistrar() : reporter_(nullptr) {}
14
15 STHReporterRegistrar::~STHReporterRegistrar() {
16 DCHECK(reporter_ == nullptr || pending_observers_.empty());
17 }
18
19 void STHReporterRegistrar::SignUpForRegistration(STHObserver* observer) {
20 pending_observers_.insert(observer);
21 if (reporter_) {
22 reporter_->RegisterObserver(observer);
23 }
24 }
25
26 void STHReporterRegistrar::AssignReporter(STHReporter* reporter) {
27 DCHECK(reporter_ == nullptr);
28 reporter_ = reporter;
29
30 for (auto observer : pending_observers_) {
31 reporter_->RegisterObserver(observer);
32 }
33 }
34
35 void STHReporterRegistrar::UnregisterAll() {
36 if (reporter_) {
37 for (auto observer : pending_observers_) {
38 reporter_->UnregisterObserver(observer);
39 }
40 }
41
42 pending_observers_.clear();
43 }
44
45 void STHReporterRegistrar::UnregisterObserver(STHObserver* observer) {
46 DCHECK(pending_observers_.find(observer) != pending_observers_.end());
47
48 reporter_->UnregisterObserver(observer);
49 pending_observers_.erase(observer);
50 }
51
52 } // namespace ct
53
54 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/sth_observer.h ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698