mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Change FakePublicCertificateDb to be more compatible with Chrome unittests.
PiperOrigin-RevId: 603583582
This commit is contained in:
committed by
Copybara-Service
parent
e1dd4fd535
commit
e4fea7a594
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -28,9 +29,7 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/meta/type_traits.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/clock.h"
|
||||
@@ -166,7 +165,7 @@ class NearbyShareCertificateStorageImplTest : public ::testing::Test {
|
||||
prefs::kNearbySharingPrivateCertificateListName);
|
||||
}
|
||||
|
||||
void PrepopulatePublicCertificates(nearby::FakePublicCertificateDb* db) {
|
||||
std::map<std::string, PublicCertificate> PrepopulatePublicCertificates() {
|
||||
std::vector<PublicCertificate> pub_certs;
|
||||
pub_certs.emplace_back(CreatePublicCertificate(
|
||||
kSecretId1, kSecretKey1, kPublicKey1, kStartSeconds1, kStartNanos1,
|
||||
@@ -183,16 +182,18 @@ class NearbyShareCertificateStorageImplTest : public ::testing::Test {
|
||||
kEndSeconds3, kEndNanos3, kForSelectedContacts3,
|
||||
kMetadataEncryptionKey3, kEncryptedMetadataBytes3,
|
||||
kMetadataEncryptionKeyTag3));
|
||||
db->AddCertificates(pub_certs, [](bool) {});
|
||||
std::map<std::string, PublicCertificate> entries;
|
||||
std::vector<std::pair<std::string, int64_t>> expirations;
|
||||
for (const auto& cert : pub_certs) {
|
||||
expirations.emplace_back(
|
||||
EncodeString(cert.secret_id()),
|
||||
absl::ToUnixNanos(TimestampToTime(cert.end_time())));
|
||||
entries.emplace(cert.secret_id(), std::move(cert));
|
||||
}
|
||||
preference_manager_.SetCertificateExpirationArray(
|
||||
prefs::kNearbySharingPublicCertificateExpirationDictName,
|
||||
expirations);
|
||||
return entries;
|
||||
}
|
||||
|
||||
void CaptureBoolCallback(bool* dest, bool src) { *dest = src; }
|
||||
@@ -383,12 +384,12 @@ TEST_F(NearbyShareCertificateStorageImplTest, DeferredCallbackQueue) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, GetPublicCertificateIds) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
auto ids = cert_store->GetPublicCertificateIds();
|
||||
ASSERT_EQ(ids.size(), 3u);
|
||||
@@ -399,12 +400,13 @@ TEST_F(NearbyShareCertificateStorageImplTest, GetPublicCertificateIds) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, GetPublicCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::vector<PublicCertificate> public_certificates;
|
||||
cert_store->GetPublicCertificates([this, &public_certificates, complete = [] {
|
||||
@@ -412,6 +414,7 @@ TEST_F(NearbyShareCertificateStorageImplTest, GetPublicCertificates) {
|
||||
PublicCertificateCallback(&public_certificates, std::move(complete),
|
||||
success, std::move(result));
|
||||
});
|
||||
fake_db->InvokeLoadCallback(true);
|
||||
|
||||
ASSERT_EQ(3u, public_certificates.size());
|
||||
for (const PublicCertificate& cert : public_certificates) {
|
||||
@@ -426,9 +429,9 @@ TEST_F(NearbyShareCertificateStorageImplTest, GetPublicCertificates) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, ReplacePublicCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
std::vector<PublicCertificate> new_certs = {
|
||||
CreatePublicCertificate(kSecretId4, kSecretKey4, kPublicKey4,
|
||||
kStartSeconds4, kStartNanos4, kEndSeconds4,
|
||||
@@ -438,12 +441,15 @@ TEST_F(NearbyShareCertificateStorageImplTest, ReplacePublicCertificates) {
|
||||
};
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
bool succeeded = false;
|
||||
cert_store->ReplacePublicCertificates(
|
||||
new_certs, [this, &succeeded](bool success) {
|
||||
CaptureBoolCallback(&succeeded, success);
|
||||
});
|
||||
fake_db->InvokeDestroyCallback(true);
|
||||
fake_db->InvokeAddCallback(true);
|
||||
|
||||
ASSERT_TRUE(succeeded);
|
||||
auto cert_map = fake_db->GetCertificatesMap();
|
||||
@@ -464,9 +470,9 @@ TEST_F(NearbyShareCertificateStorageImplTest, ReplacePublicCertificates) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, AddPublicCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
std::vector<PublicCertificate> new_certs = {
|
||||
CreatePublicCertificate(kSecretId3, kSecretKey2, kPublicKey2,
|
||||
kStartSeconds2, kStartNanos2, kEndSeconds2,
|
||||
@@ -482,12 +488,14 @@ TEST_F(NearbyShareCertificateStorageImplTest, AddPublicCertificates) {
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
bool succeeded = false;
|
||||
cert_store->AddPublicCertificates(new_certs,
|
||||
[this, &succeeded](bool success) {
|
||||
CaptureBoolCallback(&succeeded, success);
|
||||
});
|
||||
fake_db->InvokeAddCallback(true);
|
||||
|
||||
ASSERT_TRUE(succeeded);
|
||||
auto cert_map = fake_db->GetCertificatesMap();
|
||||
@@ -520,17 +528,19 @@ TEST_F(NearbyShareCertificateStorageImplTest, AddPublicCertificates) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, ClearPublicCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
bool succeeded = false;
|
||||
cert_store->ClearPublicCertificates([this, &succeeded](bool success) {
|
||||
CaptureBoolCallback(&succeeded, success);
|
||||
});
|
||||
fake_db->InvokeDestroyCallback(true);
|
||||
|
||||
ASSERT_TRUE(succeeded);
|
||||
ASSERT_EQ(0u, fake_db->GetCertificatesMap().size());
|
||||
@@ -539,12 +549,13 @@ TEST_F(NearbyShareCertificateStorageImplTest, ClearPublicCertificates) {
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
RemoveExpiredPrivateCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::vector<NearbySharePrivateCertificate> certs = CreatePrivateCertificates(
|
||||
3, DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
@@ -571,12 +582,13 @@ TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, RemoveExpiredPublicCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::vector<absl::Time> expiration_times;
|
||||
for (const auto& pair : fake_db->GetCertificatesMap()) {
|
||||
@@ -595,6 +607,7 @@ TEST_F(NearbyShareCertificateStorageImplTest, RemoveExpiredPublicCertificates) {
|
||||
now, [this, &succeeded](bool success) {
|
||||
CaptureBoolCallback(&succeeded, success);
|
||||
});
|
||||
fake_db->InvokeRemoveCallback(true);
|
||||
|
||||
ASSERT_TRUE(succeeded);
|
||||
auto cert_map = fake_db->GetCertificatesMap();
|
||||
@@ -607,12 +620,13 @@ TEST_F(NearbyShareCertificateStorageImplTest, RemoveExpiredPublicCertificates) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, ReplaceGetPrivateCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
auto certs_before = CreatePrivateCertificates(
|
||||
3, DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
@@ -641,12 +655,13 @@ TEST_F(NearbyShareCertificateStorageImplTest, ReplaceGetPrivateCertificates) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, UpdatePrivateCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::vector<NearbySharePrivateCertificate> initial_certs =
|
||||
CreatePrivateCertificates(
|
||||
@@ -676,12 +691,13 @@ TEST_F(NearbyShareCertificateStorageImplTest, UpdatePrivateCertificates) {
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
NextPrivateCertificateExpirationTime) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
auto certs = CreatePrivateCertificates(
|
||||
3, DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
@@ -701,12 +717,13 @@ TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
NextPublicCertificateExpirationTime) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::optional<absl::Time> next_expiration =
|
||||
cert_store->NextPublicCertificateExpirationTime();
|
||||
@@ -723,12 +740,13 @@ TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest, ClearPrivateCertificates) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::vector<NearbySharePrivateCertificate> certs_before =
|
||||
CreatePrivateCertificates(
|
||||
@@ -744,12 +762,13 @@ TEST_F(NearbyShareCertificateStorageImplTest, ClearPrivateCertificates) {
|
||||
|
||||
TEST_F(NearbyShareCertificateStorageImplTest,
|
||||
ClearPrivateCertificatesOfVisibility) {
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>();
|
||||
auto db = std::make_unique<nearby::FakePublicCertificateDb>(
|
||||
PrepopulatePublicCertificates());
|
||||
nearby::FakePublicCertificateDb* fake_db = db.get();
|
||||
PrepopulatePublicCertificates(fake_db);
|
||||
|
||||
auto cert_store = NearbyShareCertificateStorageImpl::Factory::Create(
|
||||
preference_manager_, std::move(db));
|
||||
fake_db->InvokeInitStatusCallback(FakePublicCertificateDb::InitStatus::kOk);
|
||||
|
||||
std::vector<NearbySharePrivateCertificate> certs_all_contacts =
|
||||
CreatePrivateCertificates(
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
|
||||
#include "sharing/internal/test/fake_public_certificate_db.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "sharing/internal/api/public_certificate_database.h"
|
||||
@@ -29,36 +29,33 @@ namespace nearby {
|
||||
|
||||
using ::nearby::sharing::proto::PublicCertificate;
|
||||
|
||||
FakePublicCertificateDb::FakePublicCertificateDb(
|
||||
std::map<std::string, PublicCertificate> entries)
|
||||
: entries_(std::move(entries)) {}
|
||||
|
||||
void FakePublicCertificateDb::Initialize(
|
||||
absl::AnyInvocable<void(PublicCertificateDatabase::InitStatus) &&>
|
||||
callback) {
|
||||
std::move(callback)(PublicCertificateDatabase::InitStatus::kOk);
|
||||
init_status_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::LoadEntries(
|
||||
absl::AnyInvocable<void(bool,
|
||||
std::unique_ptr<std::vector<PublicCertificate>>) &&>
|
||||
callback) {
|
||||
auto result = std::make_unique<std::vector<PublicCertificate>>();
|
||||
auto it = entries_.begin();
|
||||
while (it != entries_.end()) {
|
||||
result->push_back(it->second);
|
||||
++it;
|
||||
}
|
||||
|
||||
std::move(callback)(true, std::move(result));
|
||||
load_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::AddCertificates(
|
||||
absl::Span<const PublicCertificate> certificates,
|
||||
absl::AnyInvocable<void(bool) &&> callback) {
|
||||
for (const auto& cert : certificates) {
|
||||
if (entries_.contains(cert.secret_id())) {
|
||||
if (entries_.find(cert.secret_id()) != entries_.end()) {
|
||||
entries_.erase(cert.secret_id());
|
||||
}
|
||||
entries_.emplace(cert.secret_id(), cert);
|
||||
}
|
||||
std::move(callback)(true);
|
||||
add_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::RemoveCertificatesById(
|
||||
@@ -69,13 +66,41 @@ void FakePublicCertificateDb::RemoveCertificatesById(
|
||||
entries_.erase(*it);
|
||||
++it;
|
||||
}
|
||||
std::move(callback)(true);
|
||||
remove_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::Destroy(
|
||||
absl::AnyInvocable<void(bool) &&> callback) {
|
||||
entries_.clear();
|
||||
std::move(callback)(true);
|
||||
destroy_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::InvokeInitStatusCallback(
|
||||
PublicCertificateDatabase::InitStatus init_status) {
|
||||
std::move(init_status_callback_)(init_status);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::InvokeLoadCallback(bool success) {
|
||||
auto result = std::make_unique<std::vector<PublicCertificate>>();
|
||||
auto it = entries_.begin();
|
||||
while (it != entries_.end()) {
|
||||
result->push_back(it->second);
|
||||
++it;
|
||||
}
|
||||
std::move(load_callback_)(success, std::move(result));
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::InvokeAddCallback(bool success) {
|
||||
std::move(add_callback_)(success);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::InvokeRemoveCallback(bool success) {
|
||||
std::move(remove_callback_)(success);
|
||||
}
|
||||
|
||||
void FakePublicCertificateDb::InvokeDestroyCallback(bool success) {
|
||||
std::move(destroy_callback_)(success);
|
||||
}
|
||||
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#ifndef THIRD_PARTY_NEARBY_SHARING_INTERNAL_TEST_FAKE_PUBLIC_CERTIFICATE_DB_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_TEST_FAKE_PUBLIC_CERTIFICATE_DB_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "sharing/internal/api/public_certificate_database.h"
|
||||
@@ -29,7 +29,8 @@ namespace nearby {
|
||||
class FakePublicCertificateDb
|
||||
: public nearby::sharing::api::PublicCertificateDatabase {
|
||||
public:
|
||||
FakePublicCertificateDb() = default;
|
||||
explicit FakePublicCertificateDb(
|
||||
std::map<std::string, nearby::sharing::proto::PublicCertificate> entries);
|
||||
~FakePublicCertificateDb() override = default;
|
||||
|
||||
void Initialize(
|
||||
@@ -49,14 +50,32 @@ class FakePublicCertificateDb
|
||||
absl::AnyInvocable<void(bool) &&> callback) override;
|
||||
void Destroy(absl::AnyInvocable<void(bool) &&> callback) override;
|
||||
|
||||
absl::flat_hash_map<std::string, nearby::sharing::proto::PublicCertificate>
|
||||
std::map<std::string, nearby::sharing::proto::PublicCertificate>
|
||||
GetCertificatesMap() {
|
||||
return entries_;
|
||||
}
|
||||
|
||||
// Invoke callbacks
|
||||
void InvokeInitStatusCallback(
|
||||
nearby::sharing::api::PublicCertificateDatabase::InitStatus init_status);
|
||||
void InvokeLoadCallback(bool success);
|
||||
void InvokeAddCallback(bool success);
|
||||
void InvokeRemoveCallback(bool success);
|
||||
void InvokeDestroyCallback(bool success);
|
||||
|
||||
private:
|
||||
absl::flat_hash_map<std::string, nearby::sharing::proto::PublicCertificate>
|
||||
std::map<std::string, nearby::sharing::proto::PublicCertificate>
|
||||
entries_;
|
||||
absl::AnyInvocable<
|
||||
void(nearby::sharing::api::PublicCertificateDatabase::InitStatus) &&>
|
||||
init_status_callback_;
|
||||
absl::AnyInvocable<
|
||||
void(bool, std::unique_ptr<std::vector<
|
||||
nearby::sharing::proto::PublicCertificate>>) &&>
|
||||
load_callback_;
|
||||
absl::AnyInvocable<void(bool) &&> add_callback_;
|
||||
absl::AnyInvocable<void(bool) &&> remove_callback_;
|
||||
absl::AnyInvocable<void(bool) &&> destroy_callback_;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user