Skip to content

Commit

Permalink
[v8] Remove extraneous parameter from removeObject API (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncooke3 authored Jun 11, 2024
1 parent 376e409 commit b5c37c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param accessGroup The Keychain Access Group.
/// @param completionHandler The completion handler to call when the
/// synchronized keychain removal is complete. An error is passed to the
/// completion handler if the keychain removal fails. Else, `YES` if the item
/// was removed successfully or doesn’t exist, `NO` otherwise.
/// @note In the event an error occurs, the completion handler will return an
/// error and a boolean to indicate the removal failed (`NO`).
/// completion handler if the keychain removal fails.
- (void)removeObjectForKey:(NSString *)key
accessGroup:(nullable NSString *)accessGroup
completionHandler:(void (^)(BOOL success, NSError *_Nullable error))completionHandler;
completionHandler:(void (^)(NSError *_Nullable error))completionHandler;

#if TARGET_OS_OSX
/// If not `nil`, then only this keychain will be used to save and read data (see
Expand Down
11 changes: 5 additions & 6 deletions GoogleUtilities/Environment/SecureStorage/GULKeychainStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,18 @@ - (void)setObject:(id<NSSecureCoding>)object

- (void)removeObjectForKey:(NSString *)key
accessGroup:(nullable NSString *)accessGroup
completionHandler:(void (^)(BOOL success, NSError *_Nullable error))completionHandler {
completionHandler:(void (^)(NSError *_Nullable error))completionHandler {
dispatch_async(self.inMemoryCacheQueue, ^{
[self.inMemoryCache removeObjectForKey:key];
dispatch_async(self.keychainQueue, ^{
NSDictionary *query = [self keychainQueryWithKey:key accessGroup:accessGroup];

NSError *error;
BOOL success = [GULKeychainUtils removeItemWithQuery:query error:&error];
if (!success) {
completionHandler(NO, error);
return;
if (![GULKeychainUtils removeItemWithQuery:query error:&error]) {
completionHandler(error);
} else {
completionHandler(nil);
}
completionHandler(success, nil);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ - (void)assertRemoveObjectForKey:(NSString *)key {
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.storage removeObjectForKey:key
accessGroup:nil
completionHandler:^(BOOL success, NSError *_Nullable error) {
completionHandler:^(NSError *_Nullable error) {
XCTAssertNil(error);
[expectation fulfill];
}];
Expand Down

0 comments on commit b5c37c5

Please sign in to comment.