-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kcer-over-NSS: Implement AddObserver and notifications
Bug: b:244408716 Test: Kcer* unit tests Change-Id: I5d0faa19e08fb0bd75dc76cebe55eaa9bc9e2cf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4527198 Reviewed-by: Pavol Marko <pmarko@chromium.org> Commit-Queue: Michael Ershov <miersh@google.com> Cr-Commit-Position: refs/heads/main@{#1151960}
- Loading branch information
Michael Ershov
authored and
Chromium LUCI CQ
committed
Jun 1, 2023
1 parent
6234eb0
commit ee8c3ad
Showing
7 changed files
with
219 additions
and
10 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chromeos/components/kcer/kcer_notifier_net.h" | ||
#include "base/callback_list.h" | ||
|
||
namespace kcer::internal { | ||
|
||
KcerNotifierNet::KcerNotifierNet() = default; | ||
|
||
KcerNotifierNet::~KcerNotifierNet() { | ||
net::CertDatabase::GetInstance()->RemoveObserver(this); | ||
} | ||
|
||
void KcerNotifierNet::Initialize() { | ||
net::CertDatabase::GetInstance()->AddObserver(this); | ||
} | ||
|
||
base::CallbackListSubscription KcerNotifierNet::AddObserver( | ||
base::RepeatingClosure callback) { | ||
return observers_.Add(std::move(callback)); | ||
} | ||
|
||
void KcerNotifierNet::OnCertDBChanged() { | ||
observers_.Notify(); | ||
} | ||
|
||
} // namespace kcer::internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROMEOS_COMPONENTS_KCER_KCER_NOTIFIER_NET_H_ | ||
#define CHROMEOS_COMPONENTS_KCER_KCER_NOTIFIER_NET_H_ | ||
|
||
#include "base/callback_list.h" | ||
#include "net/cert/cert_database.h" | ||
|
||
namespace kcer::internal { | ||
|
||
// A helper class that implements notifications for Kcer. This implementation | ||
// just listens to the notifications from net::CertDatabase and forwards them to | ||
// the observers. | ||
// In the future this is planned to be replaced by listening to notifications | ||
// from Chaps. KcerToken-s will receive notifications related to them and | ||
// forward them to KcerImpl to notify the observers. | ||
class KcerNotifierNet : public net::CertDatabase::Observer { | ||
public: | ||
KcerNotifierNet(); | ||
~KcerNotifierNet() override; | ||
|
||
// Starts observing the notifications from net::CertDatabase. | ||
void Initialize(); | ||
|
||
base::CallbackListSubscription AddObserver(base::RepeatingClosure callback); | ||
|
||
// Implements net::CertDatabase::Observer | ||
void OnCertDBChanged() override; | ||
|
||
private: | ||
base::RepeatingCallbackList<void()> observers_; | ||
}; | ||
|
||
} // namespace kcer::internal | ||
|
||
#endif // CHROMEOS_COMPONENTS_KCER_KCER_NOTIFIER_NET_H_ |