Revert "Rename getTokenWithHandler"

Since the renamed protocol is breaking people and is not general enough, we revert the rename and leave the work to interceptor

This reverts commit 92db5fc724.
pull/16190/head
Muxi Yan 6 years ago
parent 3f57e3451b
commit 25e7366413
  1. 14
      src/objective-c/GRPCClient/GRPCCall.m
  2. 12
      src/objective-c/GRPCClient/GRPCCallOptions.h
  3. 2
      src/objective-c/ProtoRPC/ProtoRPC.m
  4. 2
      src/objective-c/tests/APIv2Tests/APIv2Tests.m

@ -885,7 +885,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
@synchronized(self) { @synchronized(self) {
self.isWaitingForToken = YES; self.isWaitingForToken = YES;
} }
void (^tokenHandler)(NSString *token) = ^(NSString *token) { [_callOptions.authTokenProvider getTokenWithHandler:^(NSString *token) {
@synchronized(self) { @synchronized(self) {
if (self.isWaitingForToken) { if (self.isWaitingForToken) {
if (token) { if (token) {
@ -895,17 +895,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
self.isWaitingForToken = NO; self.isWaitingForToken = NO;
} }
} }
}; }];
id<GRPCAuthorizationProtocol> authTokenProvider = _callOptions.authTokenProvider;
if ([authTokenProvider respondsToSelector:@selector(provideTokenToHandler:)]) {
[_callOptions.authTokenProvider provideTokenToHandler:tokenHandler];
} else {
NSAssert([authTokenProvider respondsToSelector:@selector(getTokenWithHandler:)],
@"authTokenProvider has no usable method");
if ([authTokenProvider respondsToSelector:@selector(getTokenWithHandler:)]) {
[_callOptions.authTokenProvider getTokenWithHandler:tokenHandler];
}
}
} else { } else {
[self startCallWithWriteable:writeable]; [self startCallWithWriteable:writeable];
} }

@ -60,22 +60,12 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) {
/** /**
* Implement this protocol to provide a token to gRPC when a call is initiated. * Implement this protocol to provide a token to gRPC when a call is initiated.
*/ */
@protocol GRPCAuthorizationProtocol<NSObject> @protocol GRPCAuthorizationProtocol
@optional
/** /**
* This method is called when gRPC is about to start the call. When OAuth token is acquired, * This method is called when gRPC is about to start the call. When OAuth token is acquired,
* \a handler is expected to be called with \a token being the new token to be used for this call. * \a handler is expected to be called with \a token being the new token to be used for this call.
*/ */
- (void)provideTokenToHandler:(void (^)(NSString *_Nullable token))handler;
/**
* This method is deprecated. Please use \a provideTokenToHandler.
*
* This method is called when gRPC is about to start the call. When OAuth token is acquired,
* \a handler is expected to be called with \a token being the new token to be used for this call.
*/
- (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler; - (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler;
@end @end

@ -175,7 +175,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
} }
- (void)writeMessage:(GPBMessage *)message { - (void)writeMessage:(GPBMessage *)message {
NSAssert([message isKindOfClass:[GPBMessage class]], @"Parameter message must be a GPBMessage"); NSAssert([message isKindOfClass:[GPBMessage class]]);
if (![message isKindOfClass:[GPBMessage class]]) { if (![message isKindOfClass:[GPBMessage class]]) {
NSLog(@"Failed to send a message that is non-proto."); NSLog(@"Failed to send a message that is non-proto.");
return; return;

@ -241,7 +241,7 @@ static const NSTimeInterval kTestTimeout = 16;
[self waitForExpectationsWithTimeout:kTestTimeout handler:nil]; [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
} }
- (void)provideTokenToHandler:(void (^)(NSString *token))handler { - (void)getTokenWithHandler:(void (^)(NSString *token))handler {
dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
dispatch_sync(queue, ^{ dispatch_sync(queue, ^{
handler(@"test-access-token"); handler(@"test-access-token");

Loading…
Cancel
Save