Skip to content

Commit 04d38a5

Browse files
committed
Darwin: Namespace Download and Downloads
1 parent c7f7984 commit 04d38a5

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/darwin/Framework/CHIP/MTRDiagnosticLogsDownloader.mm

+26-26
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
NS_ASSUME_NONNULL_BEGIN
4343

44-
@interface Download : NSObject
44+
@interface MTRDownload : NSObject
4545
@property (nonatomic) NSString * fileDesignator;
4646
@property (nonatomic) NSNumber * fabricIndex;
4747
@property (nonatomic) NSNumber * nodeID;
@@ -55,7 +55,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
5555
nodeID:(NSNumber *)nodeID
5656
queue:(dispatch_queue_t)queue
5757
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
58-
done:(void (^)(Download * finishedDownload))done;
58+
done:(void (^)(MTRDownload * finishedDownload))done;
5959

6060
- (void)writeToFile:(NSData *)data error:(out NSError **)error;
6161

@@ -69,24 +69,24 @@ - (void)success;
6969
- (void)failure:(NSError * _Nullable)error;
7070
@end
7171

72-
@interface Downloads : NSObject
73-
@property (nonatomic, strong) NSMutableArray<Download *> * downloads;
72+
@interface MTRDownloads : NSObject
73+
@property (nonatomic, strong) NSMutableArray<MTRDownload *> * downloads;
7474

75-
- (Download * _Nullable)get:(NSString *)fileDesignator
75+
- (MTRDownload * _Nullable)get:(NSString *)fileDesignator
7676
fabricIndex:(NSNumber *)fabricIndex
7777
nodeID:(NSNumber *)nodeID;
7878

79-
- (Download * _Nullable)add:(MTRDiagnosticLogType)type
79+
- (MTRDownload * _Nullable)add:(MTRDiagnosticLogType)type
8080
fabricIndex:(NSNumber *)fabricIndex
8181
nodeID:(NSNumber *)nodeID
8282
queue:(dispatch_queue_t)queue
8383
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
84-
done:(void (^)(Download * finishedDownload))done;
84+
done:(void (^)(MTRDownload * finishedDownload))done;
8585
@end
8686

8787
@interface MTRDiagnosticLogsDownloader ()
8888
@property (readonly) DiagnosticLogsDownloaderBridge * bridge;
89-
@property (nonatomic, strong) Downloads * downloads;
89+
@property (nonatomic, strong) MTRDownloads * downloads;
9090

9191
/**
9292
* Notify the delegate when a BDX Session starts for some logs.
@@ -134,21 +134,21 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
134134
CHIP_ERROR OnTransferEnd(chip::bdx::BDXTransferProxy * transfer, CHIP_ERROR error) override;
135135
CHIP_ERROR OnTransferData(chip::bdx::BDXTransferProxy * transfer, const chip::ByteSpan & data) override;
136136

137-
CHIP_ERROR StartBDXTransferTimeout(Download * download, uint16_t timeoutInSeconds);
138-
void CancelBDXTransferTimeout(Download * download);
137+
CHIP_ERROR StartBDXTransferTimeout(MTRDownload * download, uint16_t timeoutInSeconds);
138+
void CancelBDXTransferTimeout(MTRDownload * download);
139139

140140
private:
141141
static void OnTransferTimeout(chip::System::Layer * layer, void * context);
142142
MTRDiagnosticLogsDownloader * __weak mDelegate;
143143
};
144144

145-
@implementation Download
145+
@implementation MTRDownload
146146
- (instancetype)initWithType:(MTRDiagnosticLogType)type
147147
fabricIndex:(NSNumber *)fabricIndex
148148
nodeID:(NSNumber *)nodeID
149149
queue:(dispatch_queue_t)queue
150150
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
151-
done:(void (^)(Download * finishedDownload))done;
151+
done:(void (^)(MTRDownload * finishedDownload))done;
152152
{
153153
self = [super init];
154154
if (self) {
@@ -158,7 +158,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
158158
__weak typeof(self) weakSelf = self;
159159
auto bdxTransferDone = ^(NSError * bdxError) {
160160
dispatch_async(queue, ^{
161-
Download * strongSelf = weakSelf;
161+
MTRDownload * strongSelf = weakSelf;
162162
if (strongSelf) {
163163
// If a fileHandle exists, it means that the BDX session has been initiated and a file has
164164
// been created to host the data of the session. So even if there is an error there may be some
@@ -303,7 +303,7 @@ - (NSString *)_toTypeString:(MTRDiagnosticLogType)type
303303

304304
@end
305305

306-
@implementation Downloads
306+
@implementation MTRDownloads
307307
- (instancetype)init
308308
{
309309
if (self = [super init]) {
@@ -315,15 +315,15 @@ - (instancetype)init
315315
- (void)dealloc
316316
{
317317
auto error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INTERNAL];
318-
for (Download * download in _downloads) {
318+
for (MTRDownload * download in _downloads) {
319319
[download failure:error];
320320
}
321321
_downloads = nil;
322322
}
323323

324-
- (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)fabricIndex nodeID:(NSNumber *)nodeID
324+
- (MTRDownload * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)fabricIndex nodeID:(NSNumber *)nodeID
325325
{
326-
for (Download * download in _downloads) {
326+
for (MTRDownload * download in _downloads) {
327327
if ([download matches:fileDesignator fabricIndex:fabricIndex nodeID:nodeID]) {
328328
return download;
329329
}
@@ -332,23 +332,23 @@ - (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)f
332332
return nil;
333333
}
334334

335-
- (Download * _Nullable)add:(MTRDiagnosticLogType)type
335+
- (MTRDownload * _Nullable)add:(MTRDiagnosticLogType)type
336336
fabricIndex:(NSNumber *)fabricIndex
337337
nodeID:(NSNumber *)nodeID
338338
queue:(dispatch_queue_t)queue
339339
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
340-
done:(void (^)(Download * finishedDownload))done
340+
done:(void (^)(MTRDownload * finishedDownload))done
341341
{
342342
assertChipStackLockedByCurrentThread();
343343

344-
auto download = [[Download alloc] initWithType:type fabricIndex:fabricIndex nodeID:nodeID queue:queue completion:completion done:done];
344+
auto download = [[MTRDownload alloc] initWithType:type fabricIndex:fabricIndex nodeID:nodeID queue:queue completion:completion done:done];
345345
VerifyOrReturnValue(nil != download, nil);
346346

347347
[_downloads addObject:download];
348348
return download;
349349
}
350350

351-
- (void)remove:(Download *)download
351+
- (void)remove:(MTRDownload *)download
352352
{
353353
assertChipStackLockedByCurrentThread();
354354

@@ -362,7 +362,7 @@ - (instancetype)init
362362
assertChipStackLockedByCurrentThread();
363363

364364
if (self = [super init]) {
365-
_downloads = [[Downloads alloc] init];
365+
_downloads = [[MTRDownloads alloc] init];
366366
_bridge = new DiagnosticLogsDownloaderBridge(self);
367367
if (_bridge == nullptr) {
368368
MTR_LOG_ERROR("Error: %@", kErrorInitDiagnosticLogsDownloader);
@@ -406,7 +406,7 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID
406406
}
407407

408408
// This block is always called when a download is finished.
409-
auto done = ^(Download * finishedDownload) {
409+
auto done = ^(MTRDownload * finishedDownload) {
410410
[controller asyncDispatchToMatterQueue:^() {
411411
[self->_downloads remove:finishedDownload];
412412

@@ -593,13 +593,13 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
593593
return CHIP_NO_ERROR;
594594
}
595595

596-
CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout(Download * download, uint16_t timeoutInSeconds)
596+
CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout(MTRDownload * download, uint16_t timeoutInSeconds)
597597
{
598598
assertChipStackLockedByCurrentThread();
599599
return chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(timeoutInSeconds), OnTransferTimeout, (__bridge void *) download);
600600
}
601601

602-
void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout(Download * download)
602+
void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout(MTRDownload * download)
603603
{
604604
assertChipStackLockedByCurrentThread();
605605
chip::DeviceLayer::SystemLayer().CancelTimer(OnTransferTimeout, (__bridge void *) download);
@@ -609,7 +609,7 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
609609
{
610610
assertChipStackLockedByCurrentThread();
611611

612-
auto * download = (__bridge Download *) context;
612+
auto * download = (__bridge MTRDownload *) context;
613613
VerifyOrReturn(nil != download);
614614

615615
// If there is no abortHandler, it means that the BDX transfer has not started.

0 commit comments

Comments
 (0)