diff options
Diffstat (limited to 'src/objective-c')
-rw-r--r-- | src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall+MobileLog.h | 30 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall+MobileLog.m | 33 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCChannel.m | 22 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCHost.m | 6 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/version.h | 2 | ||||
-rw-r--r-- | src/objective-c/tests/version.h | 2 |
7 files changed, 94 insertions, 3 deletions
diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 037ad4d9b0..954beed8e1 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.10.0-dev' + v = '1.11.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/GRPCCall+MobileLog.h b/src/objective-c/GRPCClient/GRPCCall+MobileLog.h new file mode 100644 index 0000000000..53b347d9ca --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCall+MobileLog.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCall.h" + +@interface GRPCCall (MobileLog) +// Set the object to be passed down along channel stack with channel arg +// GRPC_ARG_MOBILE_LOG_CONFIG. The setting may be used by custom channel +// filters for metrics logging. ++ (void)setLogConfig:(id)logConfig; + +// Obtain the object to be passed down along channel stack with channel arg +// GRPC_ARG_MOBILE_LOG_CONFIG. ++ (id)logConfig; +@end diff --git a/src/objective-c/GRPCClient/GRPCCall+MobileLog.m b/src/objective-c/GRPCClient/GRPCCall+MobileLog.m new file mode 100644 index 0000000000..4dedb7de8b --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCall+MobileLog.m @@ -0,0 +1,33 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCall+MobileLog.h" + +static id globalLogConfig = nil; + +@implementation GRPCCall (MobileLog) + ++ (void)setLogConfig:(id)logConfig { + globalLogConfig = logConfig; +} + ++ (id)logConfig { + return globalLogConfig; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 87646f7895..b53d84159d 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -32,6 +32,24 @@ #endif #import "GRPCCompletionQueue.h" +static void* copy_pointer_arg(void *p) { + // Add ref count to the object when making copy + id obj = (__bridge id)p; + return (__bridge_retained void *)obj; +} + +static void destroy_pointer_arg(void *p) { + // Decrease ref count to the object when destroying + CFRelease((CFTreeRef)p); +} + +static int cmp_pointer_arg(void *p, void *q) { + return p == q; +} + +static const grpc_arg_pointer_vtable objc_arg_vtable = { + copy_pointer_arg, destroy_pointer_arg, cmp_pointer_arg}; + static void FreeChannelArgs(grpc_channel_args *channel_args) { for (size_t i = 0; i < channel_args->num_args; ++i) { grpc_arg *arg = &channel_args->args[i]; @@ -75,6 +93,10 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) { } else if ([value respondsToSelector:@selector(intValue)]) { arg->type = GRPC_ARG_INTEGER; arg->value.integer = [value intValue]; + } else if (value != nil) { + arg->type = GRPC_ARG_POINTER; + arg->value.pointer.p = (__bridge_retained void *)value; + arg->value.pointer.vtable = &objc_arg_vtable; } else { [NSException raise:NSInvalidArgumentException format:@"Invalid value type: %@", [value class]]; diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index ceae9607d7..71b57cf1f6 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -21,6 +21,7 @@ #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> @@ -231,6 +232,11 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; [NSNumber numberWithInt:_compressAlgorithm]; } + id logConfig = [GRPCCall logConfig]; + if (logConfig != nil) { + args[@GRPC_ARG_MOBILE_LOG_CONFIG] = logConfig; + } + return args; } diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 5c134e3642..405c2fff9f 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -23,4 +23,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.10.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.11.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 5140aa23a6..6f6cd25007 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -23,5 +23,5 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.10.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.11.0-dev" #define GRPC_C_VERSION_STRING @"6.0.0-dev" |