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

Clean up asyncGetCommissionerOnMatterQueue on MTRDeviceController. #35947

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
25 changes: 2 additions & 23 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#import "MTRLogging_Internal.h"
#import "MTRMetricKeys.h"
#import "MTRMetricsCollector.h"
#import "MTROperationalCredentialsDelegate.h"
#import "MTRP256KeypairBridge.h"
#import "MTRPersistentStorageDelegateBridge.h"
#import "MTRServerEndpoint_Internal.h"
Expand Down Expand Up @@ -124,7 +123,6 @@ @implementation MTRDeviceController {
chip::Credentials::PartialDACVerifier * _partialDACVerifier;
chip::Credentials::DefaultDACVerifier * _defaultDACVerifier;
MTRDeviceControllerDelegateBridge * _deviceControllerDelegateBridge;
MTROperationalCredentialsDelegate * _operationalCredentialsDelegate;
MTRDeviceAttestationDelegateBridge * _deviceAttestationDelegateBridge;
os_unfair_lock _underlyingDeviceMapLock;
MTRCommissionableBrowser * _commissionableBrowser;
Expand Down Expand Up @@ -592,27 +590,8 @@ - (MTRTransportType)sessionTransportTypeForDevice:(MTRBaseDevice *)device
- (void)asyncGetCommissionerOnMatterQueue:(void (^)(chip::Controller::DeviceCommissioner *))block
errorHandler:(nullable MTRDeviceErrorHandler)errorHandler
{
{
NSError * error;
if (![self checkIsRunning:&error]) {
if (errorHandler != nil) {
errorHandler(error);
}
return;
}
}

dispatch_async(_chipWorkQueue, ^{
NSError * error;
if (![self checkIsRunning:&error]) {
if (errorHandler != nil) {
errorHandler(error);
}
return;
}

block(self->_cppCommissioner);
});
MTR_ABSTRACT_METHOD();
errorHandler([MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]);
}

- (void)asyncDispatchToMatterQueue:(dispatch_block_t)block errorHandler:(nullable MTRDeviceErrorHandler)errorHandler
Expand Down
1 change: 0 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#import "MTRLogging_Internal.h"
#import "MTRMetricKeys.h"
#import "MTRMetricsCollector.h"
#import "MTROperationalCredentialsDelegate.h"
#import "MTRP256KeypairBridge.h"
#import "MTRPersistentStorageDelegateBridge.h"
#import "MTRServerEndpoint_Internal.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#import <Foundation/Foundation.h>
#import <Security/Security.h>

#import "MTRDeviceController.h"
#import "MTRDeviceController_Concrete.h"
#import "MTRError_Internal.h"
#import "MTRKeypair.h"
#import "MTROperationalCertificateIssuer.h"
Expand All @@ -38,7 +38,7 @@ class MTROperationalCredentialsDelegate : public chip::Controller::OperationalCr
public:
using ChipP256KeypairPtr = chip::Crypto::P256Keypair *;

MTROperationalCredentialsDelegate(MTRDeviceController * deviceController);
MTROperationalCredentialsDelegate(MTRDeviceController_Concrete * deviceController);
~MTROperationalCredentialsDelegate() {}

CHIP_ERROR Init(ChipP256KeypairPtr nocSigner, NSData * ipk, NSData * rootCert, NSData * _Nullable icaCert);
Expand Down Expand Up @@ -147,7 +147,7 @@ class MTROperationalCredentialsDelegate : public chip::Controller::OperationalCr
NSData * _Nullable mRootCert;
NSData * _Nullable mIntermediateCert;

MTRDeviceController * __weak mWeakController;
MTRDeviceController_Concrete * __weak mWeakController;
chip::Controller::DeviceCommissioner * _Nullable mCppCommissioner = nullptr;
id<MTROperationalCertificateIssuer> _Nullable mOperationalCertificateIssuer;
dispatch_queue_t _Nullable mOperationalCertificateIssuerQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
using namespace Credentials;
using namespace Crypto;

MTROperationalCredentialsDelegate::MTROperationalCredentialsDelegate(MTRDeviceController * deviceController)
MTROperationalCredentialsDelegate::MTROperationalCredentialsDelegate(MTRDeviceController_Concrete * deviceController)
: mWeakController(deviceController)
{
}
Expand Down Expand Up @@ -129,7 +129,7 @@

VerifyOrReturnError(mCppCommissioner != nullptr, CHIP_ERROR_INCORRECT_STATE);

MTRDeviceController * strongController = mWeakController;
MTRDeviceController_Concrete * strongController = mWeakController;
VerifyOrReturnError(strongController != nil, CHIP_ERROR_INCORRECT_STATE);

mOnNOCCompletionCallback = onCompletion;
Expand Down Expand Up @@ -168,14 +168,14 @@
certificationDeclaration:AsData(certificationDeclarationSpan)
firmwareInfo:firmwareInfo];

MTRDeviceController * __weak weakController = mWeakController;
MTRDeviceController_Concrete * __weak weakController = mWeakController;
dispatch_async(mOperationalCertificateIssuerQueue, ^{
[mOperationalCertificateIssuer
issueOperationalCertificateForRequest:csrInfo
attestationInfo:attestationInfo
controller:strongController
completion:^(MTROperationalCertificateChain * _Nullable chain, NSError * _Nullable error) {
MTRDeviceController * strongController = weakController;
MTRDeviceController_Concrete * strongController = weakController;
if (strongController == nil || !strongController.isRunning) {
// No longer safe to touch "this"
return;
Expand Down
Loading