aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-12-19 09:16:26 -0800
committerGravatar Muxi Yan <mxyan@google.com>2018-12-19 09:16:26 -0800
commit25e73664136ea01e2b8a64149a97e782c57d9f7d (patch)
tree17890f21ecbc91416390c33e50d29a39e4d84148 /src
parent3f57e3451bf4a3687e70e92fc218ea25ff7a17c9 (diff)
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 92db5fc72488f9d62b81ee311a79832df787f3ef.
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m14
-rw-r--r--src/objective-c/GRPCClient/GRPCCallOptions.h12
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m2
-rw-r--r--src/objective-c/tests/APIv2Tests/APIv2Tests.m2
4 files changed, 5 insertions, 25 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 39e4967ec9..9bcacac0df 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -885,7 +885,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
@synchronized(self) {
self.isWaitingForToken = YES;
}
- void (^tokenHandler)(NSString *token) = ^(NSString *token) {
+ [_callOptions.authTokenProvider getTokenWithHandler:^(NSString *token) {
@synchronized(self) {
if (self.isWaitingForToken) {
if (token) {
@@ -895,17 +895,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
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 {
[self startCallWithWriteable:writeable];
}
diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h
index b866f268ee..b5bf4c9eb6 100644
--- a/src/objective-c/GRPCClient/GRPCCallOptions.h
+++ b/src/objective-c/GRPCClient/GRPCCallOptions.h
@@ -60,22 +60,12 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) {
/**
* Implement this protocol to provide a token to gRPC when a call is initiated.
*/
-@protocol GRPCAuthorizationProtocol<NSObject>
-
-@optional
+@protocol GRPCAuthorizationProtocol
/**
* 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)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;
@end
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index abf224c3cf..48a38bd35a 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -175,7 +175,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
}
- (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]]) {
NSLog(@"Failed to send a message that is non-proto.");
return;
diff --git a/src/objective-c/tests/APIv2Tests/APIv2Tests.m b/src/objective-c/tests/APIv2Tests/APIv2Tests.m
index fd472aafeb..ca7bf47283 100644
--- a/src/objective-c/tests/APIv2Tests/APIv2Tests.m
+++ b/src/objective-c/tests/APIv2Tests/APIv2Tests.m
@@ -241,7 +241,7 @@ static const NSTimeInterval kTestTimeout = 16;
[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_sync(queue, ^{
handler(@"test-access-token");