aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Remote/FSTStream.mm
diff options
context:
space:
mode:
authorGravatar rsgowman <rgowman@google.com>2018-03-21 11:04:40 -0400
committerGravatar GitHub <noreply@github.com>2018-03-21 11:04:40 -0400
commit308acc09bfaf6dabf4b6d5f5e39f33854df8ce34 (patch)
tree3706bbbe40d08569795634fd2f30a07fd348b399 /Firestore/Source/Remote/FSTStream.mm
parentd924771453d000e708bd5d239da3bae4feb489ac (diff)
Change CredentialsProvider::TokenListener to use StatusOr<Token> (#945)
* Change CredentialsProvider::TokenListener to use StatusOr Rather than a token plus error code/msg. * Eliminate the concept of an invalid Token Instead, we'll just use StatusOr<Token>. Note that unauthenticated tokens are handled as a special case; they're created via: Token::Unauthenticated() and are otherwise "valid", though attempting to retrieve the raw token on one of these tokens will cause an assertion failure.
Diffstat (limited to 'Firestore/Source/Remote/FSTStream.mm')
-rw-r--r--Firestore/Source/Remote/FSTStream.mm13
1 files changed, 6 insertions, 7 deletions
diff --git a/Firestore/Source/Remote/FSTStream.mm b/Firestore/Source/Remote/FSTStream.mm
index 019b0bc..a5c36c8 100644
--- a/Firestore/Source/Remote/FSTStream.mm
+++ b/Firestore/Source/Remote/FSTStream.mm
@@ -265,17 +265,15 @@ static const NSTimeInterval kIdleTimeout = 60.0;
_delegate = delegate;
_credentials->GetToken(
- /*force_refresh=*/false,
- [self](Token result, const int64_t error_code, const absl::string_view error_msg) {
- NSError *error = util::WrapNSError(error_code, error_msg);
+ /*force_refresh=*/false, [self](util::StatusOr<Token> result) {
[self.workerDispatchQueue dispatchAsyncAllowingSameQueue:^{
- [self resumeStartWithToken:result error:error];
+ [self resumeStartWithToken:result];
}];
});
}
/** Add an access token to our RPC, after obtaining one from the credentials provider. */
-- (void)resumeStartWithToken:(const Token &)token error:(NSError *)error {
+- (void)resumeStartWithToken:(const util::StatusOr<Token> &)result {
[self.workerDispatchQueue verifyIsCurrentQueue];
if (self.state == FSTStreamStateStopped) {
@@ -287,9 +285,9 @@ static const NSTimeInterval kIdleTimeout = 60.0;
// TODO(mikelehen): We should force a refresh if the previous RPC failed due to an expired token,
// but I'm not sure how to detect that right now. http://b/32762461
- if (error) {
+ if (!result.ok()) {
// RPC has not been started yet, so just invoke higher-level close handler.
- [self handleStreamClose:error];
+ [self handleStreamClose:util::MakeNSError(result.status())];
return;
}
@@ -297,6 +295,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
_rpc = [self createRPCWithRequestsWriter:self.requestsWriter];
[_rpc setResponseDispatchQueue:self.workerDispatchQueue.queue];
+ const Token &token = result.ValueOrDie();
[FSTDatastore
prepareHeadersForRPC:_rpc
databaseID:&self.databaseInfo->database_id()