aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCHost.m
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-04-11 18:10:02 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-04-11 18:10:02 -0700
commitc92d90aba2bd1bd710830c781d1e1e4c8adea0ba (patch)
treedb1825d2676e0be8809918378ab2826c24d42f17 /src/objective-c/GRPCClient/private/GRPCHost.m
parente433b56defb450f5815e973da8798512b99c9e51 (diff)
clang-format objective-c files
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCHost.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index 152c3d3ed6..283306262a 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -18,10 +18,10 @@
#import "GRPCHost.h"
+#import <GRPCClient/GRPCCall+MobileLog.h>
+#import <GRPCClient/GRPCCall.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
-#import <GRPCClient/GRPCCall.h>
-#import <GRPCClient/GRPCCall+MobileLog.h>
#ifdef GRPC_COMPILE_WITH_CRONET
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Cronet.h>
@@ -91,16 +91,15 @@ static NSMutableDictionary *kHostCache;
+ (void)flushChannelCache {
@synchronized(kHostCache) {
- [kHostCache enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key,
- GRPCHost * _Nonnull host,
- BOOL * _Nonnull stop) {
+ [kHostCache enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, GRPCHost *_Nonnull host,
+ BOOL *_Nonnull stop) {
[host disconnect];
}];
}
}
+ (void)resetAllHostSettings {
- @synchronized (kHostCache) {
+ @synchronized(kHostCache) {
kHostCache = [NSMutableDictionary dictionary];
}
}
@@ -131,38 +130,38 @@ static NSMutableDictionary *kHostCache;
static NSError *kDefaultRootsError;
static dispatch_once_t loading;
dispatch_once(&loading, ^{
- NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
+ NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
// Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"];
NSError *error;
// Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the
// issuer). Load them as UTF8 and produce an ASCII equivalent.
- NSString *contentInUTF8 = [NSString stringWithContentsOfFile:path
- encoding:NSUTF8StringEncoding
- error:&error];
+ NSString *contentInUTF8 =
+ [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if (contentInUTF8 == nil) {
kDefaultRootsError = error;
return;
}
- kDefaultRootsASCII = [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
+ kDefaultRootsASCII =
+ [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
});
NSData *rootsASCII;
if (pemRootCerts != nil) {
- rootsASCII = [pemRootCerts dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
+ rootsASCII = [pemRootCerts dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
} else {
if (kDefaultRootsASCII == nil) {
if (errorPtr) {
*errorPtr = kDefaultRootsError;
}
- NSAssert(kDefaultRootsASCII, @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
- "with the root certificates, is needed to establish secure (TLS) connections. "
- "Because the file is distributed with the gRPC library, this error is usually a sign "
- "that the library wasn't configured correctly for your project. Error: %@",
- kDefaultRootsError);
+ NSAssert(
+ kDefaultRootsASCII,
+ @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
+ "with the root certificates, is needed to establish secure (TLS) connections. "
+ "Because the file is distributed with the gRPC library, this error is usually a sign "
+ "that the library wasn't configured correctly for your project. Error: %@",
+ kDefaultRootsError);
return NO;
}
rootsASCII = kDefaultRootsASCII;
@@ -173,10 +172,10 @@ static NSMutableDictionary *kHostCache;
creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL);
} else {
grpc_ssl_pem_key_cert_pair key_cert_pair;
- NSData *privateKeyASCII = [pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
- NSData *certChainASCII = [pemCertChain dataUsingEncoding:NSASCIIStringEncoding
- allowLossyConversion:YES];
+ NSData *privateKeyASCII =
+ [pemPrivateKey dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
+ NSData *certChainASCII =
+ [pemCertChain dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
key_cert_pair.private_key = privateKeyASCII.bytes;
key_cert_pair.cert_chain = certChainASCII.bytes;
creds = grpc_ssl_credentials_create(rootsASCII.bytes, &key_cert_pair, NULL);
@@ -212,8 +211,7 @@ static NSMutableDictionary *kHostCache;
}
if (_compressAlgorithm != GRPC_COMPRESS_NONE) {
- args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] =
- [NSNumber numberWithInt:_compressAlgorithm];
+ args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] = [NSNumber numberWithInt:_compressAlgorithm];
}
if (_keepaliveInterval != 0) {
@@ -247,14 +245,12 @@ static NSMutableDictionary *kHostCache;
}
#ifdef GRPC_COMPILE_WITH_CRONET
if (useCronet) {
- channel = [GRPCChannel secureCronetChannelWithHost:_address
- channelArgs:args];
+ channel = [GRPCChannel secureCronetChannelWithHost:_address channelArgs:args];
} else
#endif
{
- channel = [GRPCChannel secureChannelWithHost:_address
- credentials:_channelCreds
- channelArgs:args];
+ channel =
+ [GRPCChannel secureChannelWithHost:_address credentials:_channelCreds channelArgs:args];
}
}
return channel;