From eeced98fc556c6a5bc3a5dedc171c98747217078 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 6 Dec 2018 13:08:34 -0800 Subject: Rename handlers to didXxx --- src/objective-c/GRPCClient/GRPCCall.h | 8 ++++---- src/objective-c/GRPCClient/GRPCCall.m | 16 ++++++++-------- src/objective-c/ProtoRPC/ProtoRPC.h | 12 ++++++------ src/objective-c/ProtoRPC/ProtoRPC.m | 24 ++++++++++++------------ src/objective-c/tests/APIv2Tests/APIv2Tests.m | 6 +++--- src/objective-c/tests/InteropTests.m | 6 +++--- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 51a82263bf..985743433c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -158,13 +158,13 @@ extern NSString *const kGRPCTrailersKey; /** * Issued when initial metadata is received from the server. */ -- (void)receivedInitialMetadata:(nullable NSDictionary *)initialMetadata; +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata; /** * Issued when a message is received from the server. The message is the raw data received from the * server, with decompression and without proto deserialization. */ -- (void)receivedRawMessage:(nullable NSData *)message; +- (void)didReceiveRawMessage:(nullable NSData *)message; /** * Issued when a call finished. If the call finished successfully, \a error is nil and \a @@ -172,7 +172,7 @@ extern NSString *const kGRPCTrailersKey; * is non-nil and contains the corresponding error information, including gRPC error codes and * error descriptions. */ -- (void)closedWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata error:(nullable NSError *)error; @required @@ -247,7 +247,7 @@ extern NSString *const kGRPCTrailersKey; /** * Cancel the request of this call at best effort. It attempts to notify the server that the RPC - * should be cancelled, and issue closedWithTrailingMetadata:error: callback with error code + * should be cancelled, and issue didCloseWithTrailingMetadata:error: callback with error code * CANCELED if no other error code has already been issued. */ - (void)cancel; diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 9b3bcd385e..48253677bd 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -250,7 +250,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; _call = nil; _pipe = nil; - if ([_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { + if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { dispatch_async(_dispatchQueue, ^{ // Copy to local so that block is freed after cancellation completes. id copiedHandler = nil; @@ -259,7 +259,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; self->_handler = nil; } - [copiedHandler closedWithTrailingMetadata:nil + [copiedHandler didCloseWithTrailingMetadata:nil error:[NSError errorWithDomain:kGRPCErrorDomain code:GRPCErrorCodeCancelled userInfo:@{ @@ -321,13 +321,13 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { @synchronized(self) { if (initialMetadata != nil && - [_handler respondsToSelector:@selector(receivedInitialMetadata:)]) { + [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { dispatch_async(_dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { copiedHandler = self->_handler; } - [copiedHandler receivedInitialMetadata:initialMetadata]; + [copiedHandler didReceiveInitialMetadata:initialMetadata]; }); } } @@ -335,13 +335,13 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)issueMessage:(id)message { @synchronized(self) { - if (message != nil && [_handler respondsToSelector:@selector(receivedRawMessage:)]) { + if (message != nil && [_handler respondsToSelector:@selector(didReceiveRawMessage:)]) { dispatch_async(_dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { copiedHandler = self->_handler; } - [copiedHandler receivedRawMessage:message]; + [copiedHandler didReceiveRawMessage:message]; }); } } @@ -349,7 +349,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { @synchronized(self) { - if ([_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { + if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { dispatch_async(_dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { @@ -357,7 +357,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; // Clean up _handler so that no more responses are reported to the handler. self->_handler = nil; } - [copiedHandler closedWithTrailingMetadata:trailingMetadata error:error]; + [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; }); } else { _handler = nil; diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index 1819fa9379..287aa0369b 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -33,12 +33,12 @@ NS_ASSUME_NONNULL_BEGIN /** * Issued when initial metadata is received from the server. */ -- (void)receivedInitialMetadata:(nullable NSDictionary *)initialMetadata; +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata; /** * Issued when a message is received from the server. The message is the deserialized proto object. */ -- (void)receivedProtoMessage:(nullable GPBMessage *)message; +- (void)didReceiveProtoMessage:(nullable GPBMessage *)message; /** * Issued when a call finished. If the call finished successfully, \a error is nil and \a @@ -46,8 +46,8 @@ NS_ASSUME_NONNULL_BEGIN * is non-nil and contains the corresponding error information, including gRPC error codes and * error descriptions. */ -- (void)closedWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error; +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error; @required @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Cancel the request of this call at best effort. It attempts to notify the server that the RPC - * should be cancelled, and issue closedWithTrailingMetadata:error: callback with error code + * should be cancelled, and issue didCloseWithTrailingMetadata:error: callback with error code * CANCELED if no other error code has already been issued. */ - (void)cancel; @@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Cancel the request of this call at best effort. It attempts to notify the server that the RPC - * should be cancelled, and issue closedWithTrailingMetadata:error: callback with error code + * should be cancelled, and issue didCloseWithTrailingMetadata:error: callback with error code * CANCELED if no other error code has already been issued. */ - (void)cancel; diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 09f8d03af6..886e31ce58 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -144,14 +144,14 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing @synchronized(self) { copiedCall = _call; _call = nil; - if ([_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { + if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { dispatch_async(_handler.dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { copiedHandler = self->_handler; self->_handler = nil; } - [copiedHandler closedWithTrailingMetadata:nil + [copiedHandler didCloseWithTrailingMetadata:nil error:[NSError errorWithDomain:kGRPCErrorDomain code:GRPCErrorCodeCancelled userInfo:@{ @@ -187,7 +187,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing [call finish]; } -- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata { +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { @synchronized(self) { if (initialMetadata != nil && [_handler respondsToSelector:@selector(initialMetadata:)]) { dispatch_async(_dispatchQueue, ^{ @@ -195,35 +195,35 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing @synchronized(self) { copiedHandler = self->_handler; } - [copiedHandler receivedInitialMetadata:initialMetadata]; + [copiedHandler didReceiveInitialMetadata:initialMetadata]; }); } } } -- (void)receivedRawMessage:(NSData *)message { +- (void)didReceiveRawMessage:(NSData *)message { if (message == nil) return; NSError *error = nil; GPBMessage *parsed = [_responseClass parseFromData:message error:&error]; @synchronized(self) { - if (parsed && [_handler respondsToSelector:@selector(receivedProtoMessage:)]) { + if (parsed && [_handler respondsToSelector:@selector(didReceiveProtoMessage:)]) { dispatch_async(_dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { copiedHandler = self->_handler; } - [copiedHandler receivedProtoMessage:parsed]; + [copiedHandler didReceiveProtoMessage:parsed]; }); } else if (!parsed && - [_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { + [_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { dispatch_async(_dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { copiedHandler = self->_handler; self->_handler = nil; } - [copiedHandler closedWithTrailingMetadata:nil + [copiedHandler didCloseWithTrailingMetadata:nil error:ErrorForBadProto(message, _responseClass, error)]; }); [_call cancel]; @@ -232,16 +232,16 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing } } -- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { @synchronized(self) { - if ([_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { + if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { dispatch_async(_dispatchQueue, ^{ id copiedHandler = nil; @synchronized(self) { copiedHandler = self->_handler; self->_handler = nil; } - [copiedHandler closedWithTrailingMetadata:trailingMetadata error:error]; + [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; }); } _call = nil; diff --git a/src/objective-c/tests/APIv2Tests/APIv2Tests.m b/src/objective-c/tests/APIv2Tests/APIv2Tests.m index 32f2122f79..ca7bf47283 100644 --- a/src/objective-c/tests/APIv2Tests/APIv2Tests.m +++ b/src/objective-c/tests/APIv2Tests/APIv2Tests.m @@ -81,19 +81,19 @@ static const NSTimeInterval kTestTimeout = 16; return self; } -- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata { +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { if (self->_initialMetadataCallback) { self->_initialMetadataCallback(initialMetadata); } } -- (void)receivedRawMessage:(GPBMessage *)message { +- (void)didReceiveRawMessage:(GPBMessage *)message { if (self->_messageCallback) { self->_messageCallback(message); } } -- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { if (self->_closeCallback) { self->_closeCallback(trailingMetadata, error); } diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index e94fd1493a..d17a07f929 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -102,19 +102,19 @@ BOOL isRemoteInteropTest(NSString *host) { return self; } -- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata { +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { if (_initialMetadataCallback) { _initialMetadataCallback(initialMetadata); } } -- (void)receivedProtoMessage:(GPBMessage *)message { +- (void)didReceiveProtoMessage:(GPBMessage *)message { if (_messageCallback) { _messageCallback(message); } } -- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { if (_closeCallback) { _closeCallback(trailingMetadata, error); } -- cgit v1.2.3