Skip to content

Commit

Permalink
[ios-sdk] Removed string parameter from [FBSessionTokenCachingStrateg…
Browse files Browse the repository at this point in the history
…y clearToken]

Summary:
The string parameter to this method was intended as an optimization to help implementations find
the token to be deleted. However, since the intention is that only the current token would ever be
deleted, they can store this data internally if they need to optimize for it, without requiring
that all callers pay the tax of passing it in.

Test Plan:
- Ran unit tests
- Ran SwitchUserSample (the only sample that used this method explicitly)

Revert Plan:

Reviewers: jacl, mmarucheck, gregschechte, ayden

Reviewed By: jacl

CC: msdkexp@

Differential Revision: https://phabricator.fb.com/D520450

Task ID: 1188716
  • Loading branch information
Chris Lang committed Jul 17, 2012
1 parent 8891302 commit 842693c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion samples/SwitchUserSample/SwitchUserSample/SUUserManager.m
Expand Up @@ -141,7 +141,7 @@ - (void)updateUser:(NSDictionary<FBGraphUser> *)user inSlot:(int)slot {
// FBSample logic
// Also need to tell the token cache to forget the tokens for this user
FBSessionTokenCachingStrategy *tokenCachingStrategy = [self createCachingStrategyForSlot:slot];
[tokenCachingStrategy clearToken:nil];
[tokenCachingStrategy clearToken];

[defaults removeObjectForKey:idKey];
[defaults removeObjectForKey:nameKey];
Expand Down
4 changes: 2 additions & 2 deletions src/FBSession.m
Expand Up @@ -262,7 +262,7 @@ - (id)initWithAppID:(NSString*)appID
shouldCache:NO];
} else {
// else this token is expired and should be cleared from cache
[tokenCachingStrategy clearToken:cachedToken];
[tokenCachingStrategy clearToken];
}
}
}
Expand Down Expand Up @@ -381,7 +381,7 @@ - (void)close {
- (void)closeAndClearTokenInformation {
NSAssert(self.affinitizedThread == [NSThread currentThread], @"FBSession: should only be used from a single thread");

[self.tokenCachingStrategy clearToken:self.accessToken];
[self.tokenCachingStrategy clearToken];
[self transitionAndCallHandlerWithState:FBSessionStateClosed
error:nil
token:nil
Expand Down
2 changes: 1 addition & 1 deletion src/FBSessionManualTokenCachingStrategy.m
Expand Up @@ -41,7 +41,7 @@ - (NSDictionary*)fetchTokenInformation;
nil];
}

- (void)clearToken:(NSString*)token
- (void)clearToken
{
self.accessToken = nil;
self.expirationDate = nil;
Expand Down
11 changes: 2 additions & 9 deletions src/FBSessionTokenCachingStrategy.h
Expand Up @@ -78,16 +78,9 @@

/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order delete any cached information for a given token
@discussion
Not all implementations will make use of the token value passedas an argument; however advanced implementations
may need the token value in order to locate and delete the cache. An overriding implementation must be able to
tolerate a nil token, as well as a token value for which no cached information exists
@param token the access token to clear
Called by <FBSession> (and overridden by inheritors), in order delete any cached information for the current token
*/
- (void)clearToken:(NSString*)token;
- (void)clearToken;

/*!
@abstract
Expand Down
2 changes: 1 addition & 1 deletion src/FBSessionTokenCachingStrategy.m
Expand Up @@ -70,7 +70,7 @@ - (NSDictionary*)fetchTokenInformation {
return [defaults objectForKey:_accessTokenInformationKeyName];
}

- (void)clearToken:(NSString*)token {
- (void)clearToken {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:_accessTokenInformationKeyName];
[defaults synchronize];
Expand Down
4 changes: 2 additions & 2 deletions src/Facebook.m
Expand Up @@ -154,7 +154,7 @@ - (void)dealloc {
- (void)invalidateSession {

[self.session close];
[self.tokenCaching clearToken:nil];
[self.tokenCaching clearToken];

[FBSession deleteFacebookCookies];

Expand Down Expand Up @@ -291,7 +291,7 @@ - (void)authorize:(NSArray *)permissions {
// if we already have a session, git rid of it
[self.session close];
self.session = nil;
[self.tokenCaching clearToken:nil];
[self.tokenCaching clearToken];

self.session = [[[FBSession alloc] initWithAppID:_appId
permissions:permissions
Expand Down

0 comments on commit 842693c

Please sign in to comment.