@@ -65,6 +65,7 @@ CHIP_ERROR DeviceControllerFactory::Init(FactoryInitParams params)
65
65
mOperationalKeystore = params.operationalKeystore ;
66
66
mOpCertStore = params.opCertStore ;
67
67
mCertificateValidityPolicy = params.certificateValidityPolicy ;
68
+ mSessionResumptionStorage = params.sessionResumptionStorage ;
68
69
mEnableServerInteractions = params.enableServerInteractions ;
69
70
70
71
CHIP_ERROR err = InitSystemState (params);
@@ -94,6 +95,7 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState()
94
95
params.operationalKeystore = mOperationalKeystore ;
95
96
params.opCertStore = mOpCertStore ;
96
97
params.certificateValidityPolicy = mCertificateValidityPolicy ;
98
+ params.sessionResumptionStorage = mSessionResumptionStorage ;
97
99
}
98
100
99
101
return InitSystemState (params);
@@ -195,12 +197,24 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
195
197
tempFabricTable = stateParams.fabricTable ;
196
198
}
197
199
198
- auto sessionResumptionStorage = chip::Platform::MakeUnique<SimpleSessionResumptionStorage>();
199
- ReturnErrorOnFailure (sessionResumptionStorage->Init (params.fabricIndependentStorage ));
200
- stateParams.sessionResumptionStorage = std::move (sessionResumptionStorage);
200
+ SessionResumptionStorage * sessionResumptionStorage;
201
+ if (params.sessionResumptionStorage == nullptr )
202
+ {
203
+ auto ownedSessionResumptionStorage = chip::Platform::MakeUnique<SimpleSessionResumptionStorage>();
204
+ ReturnErrorOnFailure (ownedSessionResumptionStorage->Init (params.fabricIndependentStorage ));
205
+ stateParams.ownedSessionResumptionStorage = std::move (ownedSessionResumptionStorage);
206
+ stateParams.externalSessionResumptionStorage = nullptr ;
207
+ sessionResumptionStorage = stateParams.ownedSessionResumptionStorage .get ();
208
+ }
209
+ else
210
+ {
211
+ stateParams.ownedSessionResumptionStorage = nullptr ;
212
+ stateParams.externalSessionResumptionStorage = params.sessionResumptionStorage ;
213
+ sessionResumptionStorage = stateParams.externalSessionResumptionStorage ;
214
+ }
201
215
202
216
auto delegate = chip::Platform::MakeUnique<ControllerFabricDelegate>();
203
- ReturnErrorOnFailure (delegate->Init (stateParams. sessionResumptionStorage . get () , stateParams.groupDataProvider ));
217
+ ReturnErrorOnFailure (delegate->Init (sessionResumptionStorage, stateParams.groupDataProvider ));
204
218
stateParams.fabricTableDelegate = delegate.get ();
205
219
ReturnErrorOnFailure (stateParams.fabricTable ->AddFabricDelegate (stateParams.fabricTableDelegate ));
206
220
delegate.release ();
@@ -222,7 +236,7 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
222
236
223
237
// Enable listening for session establishment messages.
224
238
ReturnErrorOnFailure (stateParams.caseServer ->ListenForSessionEstablishment (
225
- stateParams.exchangeMgr , stateParams.sessionMgr , stateParams.fabricTable , stateParams. sessionResumptionStorage . get () ,
239
+ stateParams.exchangeMgr , stateParams.sessionMgr , stateParams.fabricTable , sessionResumptionStorage,
226
240
stateParams.certificateValidityPolicy , stateParams.groupDataProvider ));
227
241
228
242
//
@@ -256,7 +270,7 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
256
270
257
271
CASEClientInitParams sessionInitParams = {
258
272
.sessionManager = stateParams.sessionMgr ,
259
- .sessionResumptionStorage = stateParams. sessionResumptionStorage . get () ,
273
+ .sessionResumptionStorage = sessionResumptionStorage,
260
274
.certificateValidityPolicy = stateParams.certificateValidityPolicy ,
261
275
.exchangeMgr = stateParams.exchangeMgr ,
262
276
.fabricTable = stateParams.fabricTable ,
@@ -373,6 +387,7 @@ void DeviceControllerFactory::Shutdown()
373
387
mOperationalKeystore = nullptr ;
374
388
mOpCertStore = nullptr ;
375
389
mCertificateValidityPolicy = nullptr ;
390
+ mSessionResumptionStorage = nullptr ;
376
391
}
377
392
378
393
void DeviceControllerSystemState::Shutdown ()
0 commit comments