Skip to content

Commit a911812

Browse files
Move initWithFactory: and startup: declarations to MTRDeviceController_Concrete.
initWithFactory: and startup: are only called from _startDeviceController:, which was only being called with MTRDeviceController_Concrete instances. Also fixes the argument type declarations for _startDeviceController: and initializeController: to make the types compile-time enforced. The MTRDeviceController implementations of initWithFactory: and startup: are now obviously unreachable and can be removed. Some static variables that are now unused have to be removed so the compiler doesn't complain about them. Further cleanup of now-unused things will follow in separate PRs.
1 parent 8318df9 commit a911812

6 files changed

+46
-455
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

-410
Large diffs are not rendered by default.

src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ - (void)stopControllerFactory
461461
* The provided controller is expected to have just been allocated and to not be
462462
* initialized yet.
463463
*/
464-
- (MTRDeviceController * _Nullable)_startDeviceController:(MTRDeviceController *)controller
464+
- (MTRDeviceController * _Nullable)_startDeviceController:(MTRDeviceController_Concrete *)controller
465465
startupParams:(id)startupParams
466466
fabricChecker:(MTRDeviceControllerStartupParamsInternal * (^)(FabricTable * fabricTable,
467467
MTRDeviceController * controller,
@@ -834,7 +834,7 @@ - (BOOL)findMatchingFabric:(FabricTable &)fabricTable
834834
// Returns nil on failure, the input controller on success.
835835
// If the provider has been initialized already, it is not considered as a failure.
836836
//
837-
- (MTRDeviceController * _Nullable)maybeInitializeOTAProvider:(MTRDeviceController * _Nonnull)controller
837+
- (MTRDeviceController_Concrete * _Nullable)maybeInitializeOTAProvider:(MTRDeviceController_Concrete * _Nonnull)controller
838838
{
839839
[self _assertCurrentQueueIsNotMatterQueue];
840840

@@ -1156,7 +1156,7 @@ - (nullable MTRDeviceController *)_findPendingShutdownControllerWithOperationalC
11561156
return nil;
11571157
}
11581158

1159-
- (nullable MTRDeviceController *)initializeController:(MTRDeviceController *)controller
1159+
- (nullable MTRDeviceController *)initializeController:(MTRDeviceController_Concrete *)controller
11601160
withParameters:(MTRDeviceControllerParameters *)parameters
11611161
error:(NSError * __autoreleasing *)error
11621162
{

src/darwin/Framework/CHIP/MTRDeviceControllerFactory_Internal.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#import "MTRDefines_Internal.h"
3232
#import "MTRDeviceControllerFactory.h"
33+
#import "MTRDeviceController_Concrete.h"
3334
#import "MTROperationalBrowser.h"
3435

3536
#include <credentials/FabricTable.h>
@@ -89,9 +90,9 @@ MTR_DIRECT_MEMBERS
8990
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion;
9091

9192
/**
92-
* Initialize an MTRDeviceController with the given parameters.
93+
* Initialize an MTRDeviceController_Concrete with the given parameters.
9394
*/
94-
- (nullable MTRDeviceController *)initializeController:(MTRDeviceController *)controller
95+
- (nullable MTRDeviceController *)initializeController:(MTRDeviceController_Concrete *)controller
9596
withParameters:(MTRDeviceControllerParameters *)parameters
9697
error:(NSError * __autoreleasing *)error;
9798

src/darwin/Framework/CHIP/MTRDeviceController_Concrete.h

+30
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,40 @@
2020
#import <Matter/MTRDefines.h>
2121
#import <Matter/MTRDeviceController.h>
2222

23+
#import "MTRDeviceControllerStartupParams_Internal.h"
24+
2325
NS_ASSUME_NONNULL_BEGIN
2426

2527
@interface MTRDeviceController_Concrete : MTRDeviceController
2628

29+
/**
30+
* Init a newly created controller.
31+
*
32+
* Only MTRDeviceControllerFactory should be calling this.
33+
*/
34+
- (nullable instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
35+
queue:(dispatch_queue_t)queue
36+
storageDelegate:(id<MTRDeviceControllerStorageDelegate> _Nullable)storageDelegate
37+
storageDelegateQueue:(dispatch_queue_t _Nullable)storageDelegateQueue
38+
otaProviderDelegate:(id<MTROTAProviderDelegate> _Nullable)otaProviderDelegate
39+
otaProviderDelegateQueue:(dispatch_queue_t _Nullable)otaProviderDelegateQueue
40+
uniqueIdentifier:(NSUUID *)uniqueIdentifier
41+
concurrentSubscriptionPoolSize:(NSUInteger)concurrentSubscriptionPoolSize
42+
storageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *)storageBehaviorConfiguration
43+
startSuspended:(BOOL)startSuspended;
44+
45+
/**
46+
* Start a new controller. Returns whether startup succeeded. If this fails,
47+
* it guarantees that it has called controllerShuttingDown on the
48+
* MTRDeviceControllerFactory.
49+
*
50+
* The return value will always match [controller isRunning] for this
51+
* controller.
52+
*
53+
* Only MTRDeviceControllerFactory should be calling this.
54+
*/
55+
- (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams;
56+
2757
/**
2858
* Takes an assertion to keep the controller running. If `-[MTRDeviceController shutdown]` is called while an assertion
2959
* is held, the shutdown will be honored only after all assertions are released. Invoking this method multiple times increases

src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm

+10-10
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ - (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParamete
163163
return controller;
164164
}
165165

166-
- (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
167-
queue:(dispatch_queue_t)queue
168-
storageDelegate:(id<MTRDeviceControllerStorageDelegate> _Nullable)storageDelegate
169-
storageDelegateQueue:(dispatch_queue_t _Nullable)storageDelegateQueue
170-
otaProviderDelegate:(id<MTROTAProviderDelegate> _Nullable)otaProviderDelegate
171-
otaProviderDelegateQueue:(dispatch_queue_t _Nullable)otaProviderDelegateQueue
172-
uniqueIdentifier:(NSUUID *)uniqueIdentifier
173-
concurrentSubscriptionPoolSize:(NSUInteger)concurrentSubscriptionPoolSize
174-
storageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *)storageBehaviorConfiguration
175-
startSuspended:(BOOL)startSuspended
166+
- (nullable instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
167+
queue:(dispatch_queue_t)queue
168+
storageDelegate:(id<MTRDeviceControllerStorageDelegate> _Nullable)storageDelegate
169+
storageDelegateQueue:(dispatch_queue_t _Nullable)storageDelegateQueue
170+
otaProviderDelegate:(id<MTROTAProviderDelegate> _Nullable)otaProviderDelegate
171+
otaProviderDelegateQueue:(dispatch_queue_t _Nullable)otaProviderDelegateQueue
172+
uniqueIdentifier:(NSUUID *)uniqueIdentifier
173+
concurrentSubscriptionPoolSize:(NSUInteger)concurrentSubscriptionPoolSize
174+
storageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *)storageBehaviorConfiguration
175+
startSuspended:(BOOL)startSuspended
176176
{
177177
if (self = [super initForSubclasses:startSuspended]) {
178178
// Make sure our storage is all set up to work as early as possible,

src/darwin/Framework/CHIP/MTRDeviceController_Internal.h

-30
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@
4040
#import <Matter/MTRP256KeypairBridge.h>
4141

4242
#import <Matter/MTRDefines.h>
43-
#import <Matter/MTRDeviceControllerStartupParams.h>
4443
#import <Matter/MTRDeviceControllerStorageDelegate.h>
4544
#import <Matter/MTRDiagnosticLogsType.h>
4645
#import <Matter/MTROTAProviderDelegate.h>
4746

4847
@class MTRDeviceControllerParameters;
49-
@class MTRDeviceControllerStartupParamsInternal;
5048
@class MTRDeviceControllerFactory;
5149
@class MTRDevice;
5250
@class MTRAsyncWorkQueue;
@@ -79,18 +77,6 @@ NS_ASSUME_NONNULL_BEGIN
7977

8078
#pragma mark - MTRDeviceControllerFactory methods
8179

82-
/**
83-
* Start a new controller. Returns whether startup succeeded. If this fails,
84-
* it guarantees that it has called controllerShuttingDown on the
85-
* MTRDeviceControllerFactory.
86-
*
87-
* The return value will always match [controller isRunning] for this
88-
* controller.
89-
*
90-
* Only MTRDeviceControllerFactory should be calling this.
91-
*/
92-
- (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams;
93-
9480
/**
9581
* Will return chip::kUndefinedFabricIndex if we do not have a fabric index.
9682
*/
@@ -135,22 +121,6 @@ NS_ASSUME_NONNULL_BEGIN
135121
*/
136122
@property (nonatomic, retain, nullable) NSData * rootPublicKey;
137123

138-
/**
139-
* Init a newly created controller.
140-
*
141-
* Only MTRDeviceControllerFactory should be calling this.
142-
*/
143-
- (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
144-
queue:(dispatch_queue_t)queue
145-
storageDelegate:(id<MTRDeviceControllerStorageDelegate> _Nullable)storageDelegate
146-
storageDelegateQueue:(dispatch_queue_t _Nullable)storageDelegateQueue
147-
otaProviderDelegate:(id<MTROTAProviderDelegate> _Nullable)otaProviderDelegate
148-
otaProviderDelegateQueue:(dispatch_queue_t _Nullable)otaProviderDelegateQueue
149-
uniqueIdentifier:(NSUUID *)uniqueIdentifier
150-
concurrentSubscriptionPoolSize:(NSUInteger)concurrentSubscriptionPoolSize
151-
storageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *)storageBehaviorConfiguration
152-
startSuspended:(BOOL)startSuspended;
153-
154124
/**
155125
* Check whether this controller is running on the given fabric, as represented
156126
* by the provided FabricTable and fabric index. The provided fabric table may

0 commit comments

Comments
 (0)