diff options
author | 2015-07-01 14:52:44 -0700 | |
---|---|---|
committer | 2015-07-01 14:52:44 -0700 | |
commit | 8a187099ec8accf4f4b9c1bcea0a71d023f6389b (patch) | |
tree | ae197d56afaf80aff6a1cb6dba715dba665572bf /src/objective-c | |
parent | d7d9ce27c523798384051246e18e3f00b29dd8c9 (diff) | |
parent | f8c63562c1388262c5588e381c05cb0c02e5b406 (diff) |
Merge branch 'master' of github.com:grpc/grpc into decompression
# Conflicts:
# Makefile
# gRPC.podspec
# src/core/surface/call.c
# src/core/transport/chttp2/frame_data.c
# tools/doxygen/Doxyfile.core.internal
# vsprojects/Grpc.mak
Diffstat (limited to 'src/objective-c')
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.h | 2 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 2 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m | 2 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h | 2 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCSecureChannel.m | 8 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 20 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/NSError+GRPC.m | 2 | ||||
-rw-r--r-- | src/objective-c/ProtoRPC/ProtoRPC.h | 2 | ||||
-rw-r--r-- | src/objective-c/ProtoRPC/ProtoRPC.m | 10 | ||||
-rw-r--r-- | src/objective-c/ProtoRPC/ProtoService.m | 6 | ||||
-rw-r--r-- | src/objective-c/RxLibrary/transformations/GRXMappingWriter.h | 2 | ||||
-rw-r--r-- | src/objective-c/examples/Sample/Sample/ViewController.m | 8 | ||||
-rw-r--r-- | src/objective-c/tests/GRPCClientTests.m | 8 | ||||
-rw-r--r-- | src/objective-c/tests/InteropTests.m | 14 | ||||
-rw-r--r-- | src/objective-c/tests/LocalClearTextTests.m | 8 | ||||
-rw-r--r-- | src/objective-c/tests/RxLibraryUnitTests.m | 6 |
16 files changed, 60 insertions, 42 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 7b42498d42..33aae10747 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -46,7 +46,7 @@ // transparently on the same TCP connection. #import <Foundation/Foundation.h> -#import <gRPC/GRXWriter.h> +#import <RxLibrary/GRXWriter.h> @class GRPCMethodName; diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index a9625a1799..77eebeff76 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -34,7 +34,7 @@ #import "GRPCCall.h" #include <grpc/grpc.h> -#include <grpc/support/grpc_time.h> +#include <grpc/support/time.h> #import "GRPCMethodName.h" #import "private/GRPCChannel.h" diff --git a/src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m b/src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m index 7d5ecb56d9..59c0565494 100644 --- a/src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m +++ b/src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m @@ -33,7 +33,7 @@ #import "GRPCDelegateWrapper.h" -#import <gRPC/GRXWriteable.h> +#import <RxLibrary/GRXWriteable.h> @interface GRPCDelegateWrapper () // These are atomic so that cancellation can nillify them from any thread. diff --git a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h index 28c7374517..81c80f2a49 100644 --- a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h +++ b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h @@ -33,7 +33,7 @@ #import <Foundation/Foundation.h> -#import "GRPCMethodName.h" +#import "GRPCClient/GRPCMethodName.h" @interface GRPCMethodName (HTTP2Encoding) - (NSString *)HTTP2Path; diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m index 2cbc6e0f83..43a8bd539e 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m @@ -38,13 +38,17 @@ @implementation GRPCSecureChannel - (instancetype)initWithHost:(NSString *)host { - static const grpc_credentials *kCredentials; + static grpc_credentials *kCredentials; static dispatch_once_t loading; dispatch_once(&loading, ^{ // Do not use NSBundle.mainBundle, as it's nil for tests of library projects. NSBundle *bundle = [NSBundle bundleForClass:self.class]; - NSString *certsPath = [bundle pathForResource:@"gRPC.bundle/roots" ofType:@"pem"]; + NSString *certsPath = [bundle pathForResource:@"gRPCCertificates.bundle/roots" ofType:@"pem"]; + NSAssert(certsPath.length, + @"gRPCCertificates.bundle/roots.pem not found under %@. This file, with the root " + "certificates, is needed to establish TLS (HTTPS) connections.", bundle.bundlePath); NSData *certsData = [NSData dataWithContentsOfFile:certsPath]; + NSAssert(certsData.length, @"No data read from %@", certsPath); NSString *certsString = [[NSString alloc] initWithData:certsData encoding:NSUTF8StringEncoding]; kCredentials = grpc_ssl_credentials_create(certsString.UTF8String, NULL); }); diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 4ccd5723c6..d94b25091e 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -132,8 +132,12 @@ grpc_metadata_array_init(&_headers); _op.data.recv_initial_metadata = &_headers; if (handler) { + // Prevent reference cycle with _handler + __weak typeof(self) weakSelf = self; _handler = ^{ - NSDictionary *metadata = [NSDictionary grpc_dictionaryFromMetadataArray:_headers]; + __strong typeof(self) strongSelf = weakSelf; + NSDictionary *metadata = [NSDictionary + grpc_dictionaryFromMetadataArray:strongSelf->_headers]; handler(metadata); }; } @@ -160,8 +164,11 @@ _op.op = GRPC_OP_RECV_MESSAGE; _op.data.recv_message = &_receivedMessage; if (handler) { + // Prevent reference cycle with _handler + __weak typeof(self) weakSelf = self; _handler = ^{ - handler(_receivedMessage); + __strong typeof(self) strongSelf = weakSelf; + handler(strongSelf->_receivedMessage); }; } } @@ -190,9 +197,14 @@ grpc_metadata_array_init(&_trailers); _op.data.recv_status_on_client.trailing_metadata = &_trailers; if (handler) { + // Prevent reference cycle with _handler + __weak typeof(self) weakSelf = self; _handler = ^{ - NSError *error = [NSError grpc_errorFromStatusCode:_statusCode details:_details]; - NSDictionary *trailers = [NSDictionary grpc_dictionaryFromMetadataArray:_trailers]; + __strong typeof(self) strongSelf = weakSelf; + NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode + details:strongSelf->_details]; + NSDictionary *trailers = [NSDictionary + grpc_dictionaryFromMetadataArray:strongSelf->_trailers]; handler(error, trailers); }; } diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.m b/src/objective-c/GRPCClient/private/NSError+GRPC.m index f7390476d9..638f41cb11 100644 --- a/src/objective-c/GRPCClient/private/NSError+GRPC.m +++ b/src/objective-c/GRPCClient/private/NSError+GRPC.m @@ -33,7 +33,7 @@ #import "NSError+GRPC.h" -#include <grpc.h> +#include <grpc/grpc.h> NSString * const kGRPCErrorDomain = @"io.grpc"; diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index b6375f52d6..a383310619 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -32,7 +32,7 @@ */ #import <Foundation/Foundation.h> -#import <gRPC/GRPCCall.h> +#import <GRPCClient/GRPCCall.h> @interface ProtoRPC : GRPCCall diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index b8f8008422..4da646d7b4 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -33,10 +33,10 @@ #import "ProtoRPC.h" -#import <gRPC/GRXWriteable.h> -#import <gRPC/GRXWriter.h> -#import <gRPC/GRXWriter+Transformations.h> -#import <Protobuf/GPBProtocolBuffers.h> +#import <GPBProtocolBuffers.h> +#import <RxLibrary/GRXWriteable.h> +#import <RxLibrary/GRXWriter.h> +#import <RxLibrary/GRXWriter+Transformations.h> @implementation ProtoRPC { id<GRXWriteable> _responseWriteable; @@ -66,6 +66,8 @@ // A writer that serializes the proto messages to send. id<GRXWriter> bytesWriter = [[[GRXWriter alloc] initWithWriter:requestsWriter] map:^id(GPBMessage *proto) { + // TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't + // sending GPBMessages. return [proto data]; }]; if ((self = [super initWithHost:host method:method requestsWriter:bytesWriter])) { diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 453d7b3f1a..47bdb5dc6e 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -33,9 +33,9 @@ #import "ProtoService.h" -#import <gRPC/GRPCMethodName.h> -#import <gRPC/GRXWriteable.h> -#import <gRPC/GRXWriter.h> +#import <GRPCClient/GRPCMethodName.h> +#import <RxLibrary/GRXWriteable.h> +#import <RxLibrary/GRXWriter.h> #import "ProtoRPC.h" diff --git a/src/objective-c/RxLibrary/transformations/GRXMappingWriter.h b/src/objective-c/RxLibrary/transformations/GRXMappingWriter.h index dcebb6132a..55f6f82f20 100644 --- a/src/objective-c/RxLibrary/transformations/GRXMappingWriter.h +++ b/src/objective-c/RxLibrary/transformations/GRXMappingWriter.h @@ -31,7 +31,7 @@ * */ -#import "GRXWriter.h" +#import "RxLibrary/GRXWriter.h" // A "proxy" writer that transforms all the values of its input writer by using a mapping function. @interface GRXMappingWriter : GRXWriter diff --git a/src/objective-c/examples/Sample/Sample/ViewController.m b/src/objective-c/examples/Sample/Sample/ViewController.m index 0011a4508d..05bd6fa2db 100644 --- a/src/objective-c/examples/Sample/Sample/ViewController.m +++ b/src/objective-c/examples/Sample/Sample/ViewController.m @@ -33,12 +33,12 @@ #import "ViewController.h" -#import <gRPC/GRPCCall.h> -#import <gRPC/GRPCMethodName.h> -#import <gRPC/GRXWriter+Immediate.h> -#import <gRPC/GRXWriteable.h> +#import <GRPCClient/GRPCCall.h> +#import <GRPCClient/GRPCMethodName.h> #import <RemoteTest/Messages.pbobjc.h> #import <RemoteTest/Test.pbrpc.h> +#import <RxLibrary/GRXWriter+Immediate.h> +#import <RxLibrary/GRXWriteable.h> @implementation ViewController diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 268e67af2f..e421127ea1 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -34,11 +34,11 @@ #import <UIKit/UIKit.h> #import <XCTest/XCTest.h> -#import <gRPC/GRPCCall.h> -#import <gRPC/GRPCMethodName.h> -#import <gRPC/GRXWriter+Immediate.h> -#import <gRPC/GRXWriteable.h> +#import <GRPCClient/GRPCCall.h> +#import <GRPCClient/GRPCMethodName.h> #import <RemoteTest/Messages.pbobjc.h> +#import <RxLibrary/GRXWriteable.h> +#import <RxLibrary/GRXWriter+Immediate.h> // These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall) // rather than a generated proto library on top of it. diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 0a512c17dc..74f6b231cf 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -36,13 +36,13 @@ #import <UIKit/UIKit.h> #import <XCTest/XCTest.h> -#import <gRPC/GRXWriter+Immediate.h> -#import <gRPC/GRXBufferedPipe.h> -#import <gRPC/ProtoRPC.h> +#import <ProtoRPC/ProtoRPC.h> #import <RemoteTest/Empty.pbobjc.h> #import <RemoteTest/Messages.pbobjc.h> #import <RemoteTest/Test.pbobjc.h> #import <RemoteTest/Test.pbrpc.h> +#import <RxLibrary/GRXBufferedPipe.h> +#import <RxLibrary/GRXWriter+Immediate.h> // Convenience constructors for the generated proto messages: @@ -174,7 +174,7 @@ __block int index = 0; [_service streamingOutputCallWithRequest:request - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error){ XCTAssertNil(error, @"Finished with unexpected error: %@", error); @@ -211,7 +211,7 @@ [requestsBuffer writeValue:request]; [_service fullDuplexCallWithRequestsWriter:requestsBuffer - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { XCTAssertNil(error, @"Finished with unexpected error: %@", error); @@ -242,7 +242,7 @@ - (void)testEmptyStreamRPC { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"]; [_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter] - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { XCTAssertNil(error, @"Finished with unexpected error: %@", error); @@ -283,7 +283,7 @@ [requestsBuffer writeValue:request]; __block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { if (receivedResponse) { diff --git a/src/objective-c/tests/LocalClearTextTests.m b/src/objective-c/tests/LocalClearTextTests.m index 68ffd23200..05cc10410a 100644 --- a/src/objective-c/tests/LocalClearTextTests.m +++ b/src/objective-c/tests/LocalClearTextTests.m @@ -34,12 +34,12 @@ #import <UIKit/UIKit.h> #import <XCTest/XCTest.h> -#import <gRPC/GRPCCall.h> -#import <gRPC/GRPCMethodName.h> -#import <gRPC/GRXWriter+Immediate.h> -#import <gRPC/GRXWriteable.h> +#import <GRPCClient/GRPCCall.h> +#import <GRPCClient/GRPCMethodName.h> #import <RouteGuide/RouteGuide.pbobjc.h> #import <RouteGuide/RouteGuide.pbrpc.h> +#import <RxLibrary/GRXWriteable.h> +#import <RxLibrary/GRXWriter+Immediate.h> // These tests require a gRPC "RouteGuide" sample server to be running locally. You can compile and // run one by following the instructions here: https://github.com/grpc/grpc-common/blob/master/cpp/cpptutorial.md#try-it-out diff --git a/src/objective-c/tests/RxLibraryUnitTests.m b/src/objective-c/tests/RxLibraryUnitTests.m index 89984d9481..5e3162875a 100644 --- a/src/objective-c/tests/RxLibraryUnitTests.m +++ b/src/objective-c/tests/RxLibraryUnitTests.m @@ -34,9 +34,9 @@ #import <UIKit/UIKit.h> #import <XCTest/XCTest.h> -#import <gRPC/GRXBufferedPipe.h> -#import <gRPC/GRXWriter.h> -#import <gRPC/GRXWriteable.h> +#import <RxLibrary/GRXBufferedPipe.h> +#import <RxLibrary/GRXWriteable.h> +#import <RxLibrary/GRXWriter.h> // A mock of a GRXSingleValueHandler block that can be queried for how many times it was called and // what were the last values passed to it. |