aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient
diff options
context:
space:
mode:
Diffstat (limited to 'src/objective-c/GRPCClient')
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.h2
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m19
-rw-r--r--src/objective-c/GRPCClient/GRPCCallOptions.m8
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m6
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.m26
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m35
9 files changed, 54 insertions, 50 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h
index be63de1af9..b549f5d2bf 100644
--- a/src/objective-c/GRPCClient/GRPCCall.h
+++ b/src/objective-c/GRPCClient/GRPCCall.h
@@ -181,7 +181,7 @@ extern NSString *const kGRPCTrailersKey;
* error descriptions.
*/
- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
- error:(nullable NSError *)error;
+ error:(nullable NSError *)error;
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index e56cc72149..589b52031a 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -28,6 +28,8 @@
#include <grpc/support/time.h>
#import "GRPCCallOptions.h"
+#import "private/GRPCChannelPool.h"
+#import "private/GRPCCompletionQueue.h"
#import "private/GRPCConnectivityMonitor.h"
#import "private/GRPCHost.h"
#import "private/GRPCRequestHeaders.h"
@@ -35,8 +37,6 @@
#import "private/NSData+GRPC.h"
#import "private/NSDictionary+GRPC.h"
#import "private/NSError+GRPC.h"
-#import "private/GRPCChannelPool.h"
-#import "private/GRPCCompletionQueue.h"
// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA,
// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE,
@@ -259,12 +259,12 @@ const char *kCFStreamVarName = "grpc_cfstream";
}
[copiedHandler didCloseWithTrailingMetadata:nil
- error:[NSError errorWithDomain:kGRPCErrorDomain
- code:GRPCErrorCodeCancelled
- userInfo:@{
- NSLocalizedDescriptionKey :
- @"Canceled by app"
- }]];
+ error:[NSError errorWithDomain:kGRPCErrorDomain
+ code:GRPCErrorCodeCancelled
+ userInfo:@{
+ NSLocalizedDescriptionKey :
+ @"Canceled by app"
+ }]];
});
} else {
_handler = nil;
@@ -819,7 +819,8 @@ const char *kCFStreamVarName = "grpc_cfstream";
_responseWriteable =
[[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue];
- GRPCPooledChannel *channel = [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions];
+ GRPCPooledChannel *channel =
+ [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions];
GRPCWrappedCall *wrappedCall = [channel wrappedCallWithPath:_path
completionQueue:[GRPCCompletionQueue completionQueue]
callOptions:_callOptions];
diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m
index 1962ad8956..d3440ee6c0 100644
--- a/src/objective-c/GRPCClient/GRPCCallOptions.m
+++ b/src/objective-c/GRPCClient/GRPCCallOptions.m
@@ -233,7 +233,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
copyItems:YES]
PEMRootCertificates:[_PEMRootCertificates copy]
PEMPrivateKey:[_PEMPrivateKey copy]
- PEMCertificateChain:[_PEMCertificateChain copy]
+ PEMCertificateChain:[_PEMCertificateChain copy]
transportType:_transportType
hostNameOverride:[_hostNameOverride copy]
logContext:_logContext
@@ -336,7 +336,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
additionalChannelArgs:kDefaultAdditionalChannelArgs
PEMRootCertificates:kDefaultPEMRootCertificates
PEMPrivateKey:kDefaultPEMPrivateKey
- PEMCertificateChain:kDefaultPEMCertificateChain
+ PEMCertificateChain:kDefaultPEMCertificateChain
transportType:kDefaultTransportType
hostNameOverride:kDefaultHostNameOverride
logContext:kDefaultLogContext
@@ -363,7 +363,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
additionalChannelArgs:_additionalChannelArgs
PEMRootCertificates:_PEMRootCertificates
PEMPrivateKey:_PEMPrivateKey
- PEMCertificateChain:_PEMCertificateChain
+ PEMCertificateChain:_PEMCertificateChain
transportType:_transportType
hostNameOverride:_hostNameOverride
logContext:_logContext
@@ -391,7 +391,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
additionalChannelArgs:[_additionalChannelArgs copy]
PEMRootCertificates:_PEMRootCertificates
PEMPrivateKey:_PEMPrivateKey
- PEMCertificateChain:_PEMCertificateChain
+ PEMCertificateChain:_PEMCertificateChain
transportType:_transportType
hostNameOverride:_hostNameOverride
logContext:_logContext
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index 12acfa1429..1a79fb04a0 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -57,7 +57,7 @@
#ifdef GRPC_COMPILE_WITH_CRONET
if (![GRPCCall isUsingCronet]) {
#else
- {
+ {
#endif
NSError *error;
id<GRPCChannelFactory> factory = [GRPCSecureChannelFactory
@@ -229,7 +229,9 @@
NSTimeInterval timeout = callOptions.timeout;
NSAssert(timeout >= 0, @"Invalid timeout");
if (timeout < 0) return NULL;
- grpc_slice host_slice = serverAuthority ? grpc_slice_from_copied_string(serverAuthority.UTF8String) : grpc_empty_slice();
+ grpc_slice host_slice = serverAuthority
+ ? grpc_slice_from_copied_string(serverAuthority.UTF8String)
+ : grpc_empty_slice();
grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String);
gpr_timespec deadline_ms =
timeout == 0 ? gpr_inf_future(GPR_CLOCK_REALTIME)
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
index 4e7c988585..ca0cc51a52 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
@@ -25,7 +25,7 @@
* Initialize a pooled channel with non-default destroy delay for testing purpose.
*/
- (nullable instancetype)initWithChannelConfiguration:
-(GRPCChannelConfiguration *)channelConfiguration
+ (GRPCChannelConfiguration *)channelConfiguration
destroyDelay:(NSTimeInterval)destroyDelay;
/**
@@ -45,5 +45,3 @@
- (nullable instancetype)initTestPool;
@end
-
-
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
index 19ef4c93ac..d3a99ca826 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
@@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
* Initialize with an actual channel object \a channel and a reference to the channel pool.
*/
- (nullable instancetype)initWithChannelConfiguration:
- (GRPCChannelConfiguration *)channelConfiguration;
+ (GRPCChannelConfiguration *)channelConfiguration;
/**
* Create a GRPCWrappedCall object (grpc_call) from this channel. If channel is disconnected, get a
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
index 17c74e558b..a323f0490c 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
@@ -21,15 +21,15 @@
#import "../internal/GRPCCallOptions+Internal.h"
#import "GRPCChannel.h"
#import "GRPCChannelFactory.h"
-#import "GRPCChannelPool.h"
#import "GRPCChannelPool+Test.h"
+#import "GRPCChannelPool.h"
+#import "GRPCCompletionQueue.h"
#import "GRPCConnectivityMonitor.h"
#import "GRPCCronetChannelFactory.h"
#import "GRPCInsecureChannelFactory.h"
#import "GRPCSecureChannelFactory.h"
-#import "version.h"
#import "GRPCWrappedCall.h"
-#import "GRPCCompletionQueue.h"
+#import "version.h"
#import <GRPCClient/GRPCCall+Cronet.h>
#include <grpc/support/log.h>
@@ -53,10 +53,12 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30;
}
- (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration {
- return [self initWithChannelConfiguration:channelConfiguration destroyDelay:kDefaultChannelDestroyDelay];
+ return [self initWithChannelConfiguration:channelConfiguration
+ destroyDelay:kDefaultChannelDestroyDelay];
}
-- (nullable instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration
+- (nullable instancetype)initWithChannelConfiguration:
+ (GRPCChannelConfiguration *)channelConfiguration
destroyDelay:(NSTimeInterval)destroyDelay {
NSAssert(channelConfiguration != nil, @"channelConfiguration cannot be empty.");
if (channelConfiguration == nil) {
@@ -71,8 +73,8 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30;
_lastTimedDestroy = nil;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
if (@available(iOS 8.0, macOS 10.10, *)) {
- _timerQueue = dispatch_queue_create(NULL,
- dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0));
+ _timerQueue = dispatch_queue_create(NULL, dispatch_queue_attr_make_with_qos_class(
+ DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0));
} else {
#else
{
@@ -115,9 +117,10 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30;
}
_lastTimedDestroy = nil;
- grpc_call *unmanagedCall = [_wrappedChannel unmanagedCallWithPath:path
- completionQueue:[GRPCCompletionQueue completionQueue]
- callOptions:callOptions];
+ grpc_call *unmanagedCall =
+ [_wrappedChannel unmanagedCallWithPath:path
+ completionQueue:[GRPCCompletionQueue completionQueue]
+ callOptions:callOptions];
if (unmanagedCall == NULL) {
NSAssert(unmanagedCall != NULL, @"Unable to create grpc_call object");
return nil;
@@ -203,8 +206,7 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30;
+ (instancetype)sharedInstance {
dispatch_once(&gInitChannelPool, ^{
- gChannelPool =
- [[GRPCChannelPool alloc] initPrivate];
+ gChannelPool = [[GRPCChannelPool alloc] initPrivate];
NSAssert(gChannelPool != nil, @"Cannot initialize global channel pool.");
});
return gChannelPool;
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index 0432190528..92bd1be257 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -77,7 +77,7 @@
- (instancetype)init NS_UNAVAILABLE;
-+ (instancetype)new NS_UNAVAILABLE;
++ (instancetype) new NS_UNAVAILABLE;
- (instancetype)initWithUnmanagedCall:(grpc_call *)unmanagedCall
pooledChannel:(GRPCPooledChannel *)pooledChannel NS_DESIGNATED_INITIALIZER;
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 82149e3dba..9066cb950f 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -267,7 +267,7 @@
[GRPCOpBatchLog addOpBatchToLog:operations];
#endif
- @synchronized (self) {
+ @synchronized(self) {
if (_call != NULL) {
size_t nops = operations.count;
grpc_op *ops_array = gpr_malloc(nops * sizeof(grpc_op));
@@ -275,19 +275,20 @@
for (GRPCOperation *operation in operations) {
ops_array[i++] = operation.op;
}
- grpc_call_error error = grpc_call_start_batch(_call, ops_array, nops, (__bridge_retained void *)(^(bool success) {
- if (!success) {
- if (errorHandler) {
- errorHandler();
- } else {
- return;
- }
- }
- for (GRPCOperation *operation in operations) {
- [operation finish];
- }
- }),
- NULL);
+ grpc_call_error error =
+ grpc_call_start_batch(_call, ops_array, nops, (__bridge_retained void *)(^(bool success) {
+ if (!success) {
+ if (errorHandler) {
+ errorHandler();
+ } else {
+ return;
+ }
+ }
+ for (GRPCOperation *operation in operations) {
+ [operation finish];
+ }
+ }),
+ NULL);
gpr_free(ops_array);
NSAssert(error == GRPC_CALL_OK, @"Error starting a batch of operations: %i", error);
@@ -296,7 +297,7 @@
}
- (void)cancel {
- @synchronized (self) {
+ @synchronized(self) {
if (_call != NULL) {
grpc_call_cancel(_call, NULL);
}
@@ -304,7 +305,7 @@
}
- (void)channelDisconnected {
- @synchronized (self) {
+ @synchronized(self) {
if (_call != NULL) {
grpc_call_unref(_call);
_call = NULL;
@@ -313,7 +314,7 @@
}
- (void)dealloc {
- @synchronized (self) {
+ @synchronized(self) {
if (_call != NULL) {
grpc_call_unref(_call);
_call = NULL;