Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MTRDeviceControllerFactory to store a more generic storage delegate. #28383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ @interface MTRDeviceControllerFactory ()

@property (atomic, readonly) dispatch_queue_t chipWorkQueue;
@property (readonly) DeviceControllerFactory * controllerFactory;
@property (readonly) MTRPersistentStorageDelegateBridge * persistentStorageDelegateBridge;
@property (readonly) PersistentStorageDelegate * persistentStorageDelegate;
@property (readonly) MTRAttestationTrustStoreBridge * attestationTrustStoreBridge;
@property (readonly) MTROTAProviderDelegateBridge * otaProviderDelegateBridge;
@property (readonly) Crypto::RawKeySessionKeystore * sessionKeystore;
Expand Down Expand Up @@ -273,9 +273,9 @@ - (void)cleanupStartupObjects
_opCertStore = nullptr;
}

if (_persistentStorageDelegateBridge) {
delete _persistentStorageDelegateBridge;
_persistentStorageDelegateBridge = nullptr;
if (_persistentStorageDelegate) {
delete _persistentStorageDelegate;
_persistentStorageDelegate = nullptr;
}
}

Expand All @@ -291,7 +291,7 @@ - (void)cleanupStartupObjects
__block BOOL listFilled = NO;
auto fillListBlock = ^{
FabricTable fabricTable;
CHIP_ERROR err = fabricTable.Init({ .storage = self->_persistentStorageDelegateBridge,
CHIP_ERROR err = fabricTable.Init({ .storage = self->_persistentStorageDelegate,
.operationalKeystore = self->_keystore,
.opCertStore = self->_opCertStore });
if (err != CHIP_NO_ERROR) {
Expand Down Expand Up @@ -348,8 +348,8 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams

[MTRControllerAccessControl init];

_persistentStorageDelegateBridge = new MTRPersistentStorageDelegateBridge(startupParams.storage);
if (_persistentStorageDelegateBridge == nil) {
_persistentStorageDelegate = new MTRPersistentStorageDelegateBridge(startupParams.storage);
if (_persistentStorageDelegate == nil) {
MTR_LOG_ERROR("Error: %@", kErrorPersistentStorageInit);
errorCode = CHIP_ERROR_NO_MEMORY;
return;
Expand Down Expand Up @@ -415,7 +415,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams
return;
}

errorCode = _keystore->Init(_persistentStorageDelegateBridge);
errorCode = _keystore->Init(_persistentStorageDelegate);
if (errorCode != CHIP_NO_ERROR) {
MTR_LOG_ERROR("Error: %@", kErrorKeystoreInit);
return;
Expand All @@ -429,7 +429,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams
return;
}

errorCode = _opCertStore->Init(_persistentStorageDelegateBridge);
errorCode = _opCertStore->Init(_persistentStorageDelegate);
if (errorCode != CHIP_NO_ERROR) {
MTR_LOG_ERROR("Error: %@", kErrorCertStoreInit);
return;
Expand Down Expand Up @@ -482,7 +482,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams

params.groupDataProvider = _groupDataProvider;
params.sessionKeystore = _sessionKeystore;
params.fabricIndependentStorage = _persistentStorageDelegateBridge;
params.fabricIndependentStorage = _persistentStorageDelegate;
params.operationalKeystore = _keystore;
params.opCertStore = _opCertStore;
params.certificateValidityPolicy = _certificateValidityPolicy;
Expand Down Expand Up @@ -788,7 +788,7 @@ - (BOOL)findMatchingFabric:(FabricTable &)fabricTable
assertChipStackLockedByCurrentThread();

CHIP_ERROR err = fabricTable.Init(
{ .storage = _persistentStorageDelegateBridge, .operationalKeystore = _keystore, .opCertStore = _opCertStore });
{ .storage = _persistentStorageDelegate, .operationalKeystore = _keystore, .opCertStore = _opCertStore });
if (err != CHIP_NO_ERROR) {
MTR_LOG_ERROR("Can't initialize fabric table: %s", ErrorStr(err));
return NO;
Expand Down Expand Up @@ -937,9 +937,9 @@ - (void)operationalInstanceAdded:(chip::PeerId &)operationalID
}
}

- (MTRPersistentStorageDelegateBridge *)storageDelegateBridge
- (PersistentStorageDelegate *)storageDelegate
{
return _persistentStorageDelegateBridge;
return _persistentStorageDelegate;
}

- (Credentials::GroupDataProvider *)groupData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

#import "MTRDeviceControllerFactory.h"

#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <lib/core/DataModelTypes.h>
#include <lib/core/PeerId.h>

class MTRPersistentStorageDelegateBridge;

namespace chip {
namespace Credentials {
class GroupDataProvider;
Expand All @@ -54,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)operationalInstanceAdded:(chip::PeerId &)operationalID;

@property (readonly) MTRPersistentStorageDelegateBridge * storageDelegateBridge;
@property (readonly) chip::PersistentStorageDelegate * storageDelegate;
@property (readonly) chip::Credentials::GroupDataProvider * groupData;
@property (readonly) chip::Credentials::DeviceAttestationVerifier * deviceAttestationVerifier;
@end
Expand Down