Skip to content

Commit

Permalink
Merge pull request #984 from Microsoft/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
iamclement authored May 16, 2018
2 parents cd9d157 + 7b8d83f commit 405757b
Show file tree
Hide file tree
Showing 49 changed files with 937 additions and 849 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

**/IDEWorkspaceChecks.plist

# App Code
**/.idea/
Expand Down
2 changes: 1 addition & 1 deletion AppCenter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AppCenter'
s.version = '1.6.0'
s.version = '1.6.1'

s.summary = 'Visual Studio App Center is your continuous integration, delivery and learning solution for iOS and macOS apps.'
s.description = <<-DESC
Expand Down
12 changes: 1 addition & 11 deletions AppCenter/AppCenter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@
354274202016769C00BE766F /* MSChannelGroupProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3542741A2012AF0500BE766F /* MSChannelGroupProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
354274212016769C00BE766F /* MSChannelProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 354274162012AE4000BE766F /* MSChannelProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
3542742320167DD500BE766F /* MSEnable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3542742220167DA400BE766F /* MSEnable.h */; settings = {ATTRIBUTES = (Public, ); }; };
354274262017A50D00BE766F /* MSExpectantChannelDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 354274252017A50D00BE766F /* MSExpectantChannelDelegate.m */; };
354274272017A50D00BE766F /* MSExpectantChannelDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 354274252017A50D00BE766F /* MSExpectantChannelDelegate.m */; };
354274282017A50D00BE766F /* MSExpectantChannelDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 354274252017A50D00BE766F /* MSExpectantChannelDelegate.m */; };
3568A7E2201A8A6300F3B860 /* MSChannelUnitDefault.h in Headers */ = {isa = PBXBuildFile; fileRef = 3542741C2012B53B00BE766F /* MSChannelUnitDefault.h */; };
3568A7E3201A8A6300F3B860 /* MSChannelDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3542741B2012B02600BE766F /* MSChannelDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
3568A7E4201A8A6300F3B860 /* MSChannelUnitProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 354274192012AEFC00BE766F /* MSChannelUnitProtocol.h */; };
Expand Down Expand Up @@ -631,8 +628,6 @@
3542741B2012B02600BE766F /* MSChannelDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSChannelDelegate.h; sourceTree = "<group>"; };
3542741C2012B53B00BE766F /* MSChannelUnitDefault.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSChannelUnitDefault.h; sourceTree = "<group>"; };
3542742220167DA400BE766F /* MSEnable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSEnable.h; sourceTree = "<group>"; };
354274242017A4BD00BE766F /* MSExpectantChannelDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSExpectantChannelDelegate.h; sourceTree = "<group>"; };
354274252017A50D00BE766F /* MSExpectantChannelDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSExpectantChannelDelegate.m; sourceTree = "<group>"; };
358F9BC22019531F00B9E22C /* MSLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSLogger.h; sourceTree = "<group>"; };
3592ABA51DC90E3600EF4592 /* MSLoggerInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSLoggerInternal.h; sourceTree = "<group>"; };
3592ABA61DC90E3600EF4592 /* MSLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSLogger.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1176,8 +1171,6 @@
isa = PBXGroup;
children = (
386E8D921E25932100EECF0F /* MSHttpTestUtil.h */,
354274242017A4BD00BE766F /* MSExpectantChannelDelegate.h */,
354274252017A50D00BE766F /* MSExpectantChannelDelegate.m */,
386E8D911E25932100EECF0F /* MSHttpTestUtil.m */,
E88D17041D35B6B500A5EA57 /* MSMockLog.h */,
E88D17051D35B6B500A5EA57 /* MSMockLog.m */,
Expand Down Expand Up @@ -1250,8 +1243,8 @@
E84B8E2D1D2351DB006FD231 /* MSChannelGroupDefault.m */,
6EF628F21D371B1600CAFF64 /* MSChannelUnitConfiguration.h */,
6EF628F31D371B1600CAFF64 /* MSChannelUnitConfiguration.m */,
6E0684621D36BC8D00A8CC6C /* MSChannelUnitDefault.m */,
3542741C2012B53B00BE766F /* MSChannelUnitDefault.h */,
6E0684621D36BC8D00A8CC6C /* MSChannelUnitDefault.m */,
3542741B2012B02600BE766F /* MSChannelDelegate.h */,
354274192012AEFC00BE766F /* MSChannelUnitProtocol.h */,
3542741A2012AF0500BE766F /* MSChannelGroupProtocol.h */,
Expand Down Expand Up @@ -1837,7 +1830,6 @@
0446DF181F3B864600C8E338 /* MSChannelUnitConfigurationTests.m in Sources */,
0446DF191F3B864600C8E338 /* MSLoggerTests.m in Sources */,
35C0E3CB1FD6146A004E841E /* MSMockSecondService.m in Sources */,
354274282017A50D00BE766F /* MSExpectantChannelDelegate.m in Sources */,
0446DF1B1F3B864600C8E338 /* MSSenderUtilTests.m in Sources */,
0446DF1C1F3B864600C8E338 /* MSMockLog.m in Sources */,
0446DF1D1F3B864600C8E338 /* MSChannelGroupDefaultTests.m in Sources */,
Expand Down Expand Up @@ -1867,7 +1859,6 @@
0446DF331F3B870A00C8E338 /* MSLogDBStorageTests.m in Sources */,
046AEAE61ECA562A00CBE511 /* MSChannelUnitConfigurationTests.m in Sources */,
046AEAE81ECA562A00CBE511 /* MSCustomPropertiesTests.m in Sources */,
354274262017A50D00BE766F /* MSExpectantChannelDelegate.m in Sources */,
04A140861ECE60C6001CEE94 /* MSUtilityTests.m in Sources */,
046AEAE91ECA562A00CBE511 /* MSSenderUtilTests.m in Sources */,
04A1408A1ECE63C7001CEE94 /* MSLogContainerTests.m in Sources */,
Expand Down Expand Up @@ -1992,7 +1983,6 @@
805F3F6B1F209C9D00B489E4 /* MSMockService.m in Sources */,
E88EBBFB1D2C8CC7007E7785 /* MSLogContainerTests.m in Sources */,
04FD126B1E4103CC007ABFE7 /* MSKeychainUtilTests.m in Sources */,
354274272017A50D00BE766F /* MSExpectantChannelDelegate.m in Sources */,
D38024121E7130C700466558 /* MSStartServiceLogTests.m in Sources */,
387C75961D64EE1900D68CC1 /* MSServiceAbstractTests.m in Sources */,
6E48A5A41D3831FE006E8B5F /* MSChannelUnitConfigurationTests.m in Sources */,
Expand Down
52 changes: 26 additions & 26 deletions AppCenter/AppCenter/Internals/Channel/MSChannelDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,49 @@

@optional

/**
* A callback that is called when a log is just enqueued. Delegates may want to prepare the log a little more before further processing.
*
* @param log The log to prepare.
*/
- (void)channel:(id<MSChannelProtocol>)channel prepareLog:(id<MSLog>)log;

/**
* A callback that is called after a log is definitely prepared.
*
* @param log The log.
* @param internalId An internal Id to keep track of logs.
*/
- (void)channel:(id<MSChannelProtocol>)channel didPrepareLog:(id<MSLog>)log withInternalId:(NSString *)internalId;

/**
* A callback that is called after a log completed the enqueueing process weither it was successfull or not.
*
* @param log The log.
* @param internalId An internal Id to keep track of logs.
*/
- (void)channel:(id<MSChannelProtocol>)channel didCompleteEnqueueingLog:(id<MSLog>)log withInternalId:(NSString *)internalId;

/**
* Callback method that will be called before each log will be send to the server.
*
* @param channel The channel object.
* @param log The log to be sent.
*/
- (void)channel:(id<MSChannelProtocol>)channel willSendLog:(id<MSLog>)log;

/**
* Callback method that will be called in case the SDK was able to send a log.
*
* @param channel The channel object.
* @param log The log to be sent.
*/
- (void)channel:(id<MSChannelProtocol>)channel didSucceedSendingLog:(id<MSLog>)log;

/**
* Callback method that will be called in case the SDK was unable to send a log.
*
* @param channel The channel object.
* @param log The log to be sent.
* @param error The error that occured.
*/
Expand All @@ -39,30 +65,4 @@
*/
- (BOOL)shouldFilterLog:(id<MSLog>)log;

/**
* A callback that is called when a log has been enqueued, before a log has been forwarded to persistence, etc.
*
* @param log The log.
* @param internalId An internal Id that can be used to keep track of logs.
*/
- (void)onEnqueuingLog:(id<MSLog>)log withInternalId:(NSString *)internalId;

/**
* Callback that is called when a log has been persisted successfully. This was introduced to implement the
* log buffer for Crashes.
*
* @param log The log.
* @param internalId An internal Id that can be used to keep track of logs.
*/
- (void)onFinishedPersistingLog:(id<MSLog>)log withInternalId:(NSString *)internalId;

/**
* Callback that is called when persisting a log has failed, meaning it has not been saved to disk because the log was
* empty. This was introduced to implement the log buffer for Crashes.
*
* @param log The log.
* @param internalId An internal Id that can be used to keep track of logs.
*/
- (void)onFailedPersistingLog:(id<MSLog>)log withInternalId:(NSString *)internalId;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

#import "MSChannelGroupProtocol.h"
#import "MSDeviceTracker.h"
#import "MSSenderDelegate.h"

NS_ASSUME_NONNULL_BEGIN

@class MSHttpSender;
@protocol MSStorage;
@protocol MSChannelDelegate;

static short const kMSStorageMaxCapacity = 300;

/**
* A channel group which triggers and manages the processing of log items on
Expand All @@ -21,7 +17,7 @@ static short const kMSStorageMaxCapacity = 300;
* persistence layer what to do with a pending batch based on the status code
* returned by the sender
*/
@interface MSChannelGroupDefault : NSObject <MSChannelGroupProtocol, MSSenderDelegate>
@interface MSChannelGroupDefault : NSObject <MSChannelGroupProtocol>

/**
* Initializes a new `MSChannelGroupDefault` instance.
Expand Down
71 changes: 30 additions & 41 deletions AppCenter/AppCenter/Internals/Channel/MSChannelGroupDefault.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
#import "MSLogDBStorage.h"
#import "MSStorage.h"

static short const kMSStorageMaxCapacity = 300;
static char *const kMSlogsDispatchQueue = "com.microsoft.appcenter.ChannelGroupQueue";

@interface MSChannelGroupDefault () <MSChannelDelegate>

@end

@implementation MSChannelGroupDefault

#pragma mark - Initialization
Expand Down Expand Up @@ -42,7 +47,10 @@ - (instancetype)initWithSender:(nullable MSHttpSender *)sender storage:(nullable
storage:self.storage
configuration:configuration
logsDispatchQueue:self.logsDispatchQueue];
[channel addDelegate:(id<MSChannelDelegate>)self];
[channel addDelegate:self];
dispatch_async(self.logsDispatchQueue, ^{
[channel flushQueue];
});
[self.channels addObject:channel];
}
return channel;
Expand Down Expand Up @@ -74,6 +82,27 @@ - (void)enumerateDelegatesForSelector:(SEL)selector withBlock:(void (^)(id<MSCha

#pragma mark - Channel Delegate

- (void)channel:(id<MSChannelProtocol>)channel prepareLog:(id<MSLog>)log {
[self enumerateDelegatesForSelector:@selector(channel:prepareLog:)
withBlock:^(id<MSChannelDelegate> delegate) {
[delegate channel:channel prepareLog:log];
}];
}

- (void)channel:(id<MSChannelProtocol>)channel didPrepareLog:(id<MSLog>)log withInternalId:(NSString *)internalId {
[self enumerateDelegatesForSelector:@selector(channel:didPrepareLog:withInternalId:)
withBlock:^(id<MSChannelDelegate> delegate) {
[delegate channel:channel didPrepareLog:log withInternalId:internalId];
}];
}

- (void)channel:(id<MSChannelProtocol>)channel didCompleteEnqueueingLog:(id<MSLog>)log withInternalId:(NSString *)internalId {
[self enumerateDelegatesForSelector:@selector(channel:didCompleteEnqueueingLog:withInternalId:)
withBlock:^(id<MSChannelDelegate> delegate) {
[delegate channel:channel didCompleteEnqueueingLog:log withInternalId:internalId];
}];
}

- (void)channel:(id<MSChannelProtocol>)channel willSendLog:(id<MSLog>)log {
[self enumerateDelegatesForSelector:@selector(channel:willSendLog:)
withBlock:^(id<MSChannelDelegate> delegate) {
Expand Down Expand Up @@ -104,27 +133,6 @@ -(BOOL)shouldFilterLog:(id<MSLog>)log {
return shouldFilter;
}

- (void)onEnqueuingLog:(id<MSLog>)log withInternalId:(NSString *)internalId {
[self enumerateDelegatesForSelector:@selector(onEnqueuingLog:withInternalId:)
withBlock:^(id<MSChannelDelegate> delegate) {
[delegate onEnqueuingLog:log withInternalId:internalId];
}];
}

- (void)onFinishedPersistingLog:(id<MSLog>)log withInternalId:(NSString *)internalId {
[self enumerateDelegatesForSelector:@selector(onFinishedPersistingLog:withInternalId:)
withBlock:^(id<MSChannelDelegate> delegate) {
[delegate onFinishedPersistingLog:log withInternalId:internalId];
}];
}

- (void)onFailedPersistingLog:(id<MSLog>)log withInternalId:(NSString *)internalId {
[self enumerateDelegatesForSelector:@selector(onFailedPersistingLog:withInternalId:)
withBlock:^(id<MSChannelDelegate> delegate) {
[delegate onFailedPersistingLog:log withInternalId:internalId];
}];
}

#pragma mark - Enable / Disable

- (void)setEnabled:(BOOL)isEnabled andDeleteDataOnDisabled:(BOOL)deleteData {
Expand Down Expand Up @@ -174,25 +182,6 @@ - (void)resume {
}
}

#pragma mark - MSSenderDelegate

- (void)senderDidSuspend:(id<MSSender>)sender {
(void)sender;
[self suspend];
}

- (void)senderDidResume:(id<MSSender>)sender {
(void)sender;
[self resume];
}

- (void)senderDidReceiveFatalError:(id<MSSender>)sender {
(void)sender;

// Disable and delete data on fatal errors.
[self setEnabled:NO andDeleteDataOnDisabled:YES];
}

#pragma mark - Other public methods

- (void)setLogUrl:(NSString *)logUrl {
Expand Down
12 changes: 8 additions & 4 deletions AppCenter/AppCenter/Internals/Channel/MSChannelUnitDefault.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#import <Foundation/Foundation.h>

#import "MSChannelUnitProtocol.h"
#import "MSSenderDelegate.h"

NS_ASSUME_NONNULL_BEGIN

@class MSChannelUnitConfiguration;
@protocol MSChannelDelegate;
@protocol MSSender;
@protocol MSStorage;

@interface MSChannelUnitDefault : NSObject <MSChannelUnitProtocol>
@interface MSChannelUnitDefault : NSObject <MSChannelUnitProtocol, MSSenderDelegate>

/**
* Initializes a new `MSChannelUnitDefault` instance.
*
* @param sender A sender instance that is used to send batches of log items to
* the backend.
* @param sender A sender instance that is used to send batches of log items to the backend.
* @param storage A storage instance to store and read enqueued log items.
* @param configuration The configuration used by this channel.
* @param logsDispatchQueue Queue used to process logs.
Expand All @@ -27,6 +26,11 @@ NS_ASSUME_NONNULL_BEGIN
configuration:(MSChannelUnitConfiguration *)configuration
logsDispatchQueue:(dispatch_queue_t)logsDispatchQueue;

/**
* Flush pending logs.
*/
- (void)flushQueue;

/**
* Queue used to process logs.
*/
Expand Down
Loading

0 comments on commit 405757b

Please sign in to comment.