2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
750 B

  1. //
  2. // Created by Aaron Levine on 10/16/17.
  3. //
  4. #import "SCCapturerTokenProvider.h"
  5. #import "SCCapturerToken.h"
  6. #import <SCBase/SCAssignment.h>
  7. #import <SCFoundation/SCAssertWrapper.h>
  8. @implementation SCCapturerTokenProvider {
  9. SCCapturerToken *_Nullable _token;
  10. }
  11. + (instancetype)providerWithToken:(SCCapturerToken *)token
  12. {
  13. return [[self alloc] initWithToken:token];
  14. }
  15. - (instancetype)initWithToken:(SCCapturerToken *)token
  16. {
  17. self = [super init];
  18. if (self) {
  19. _token = token;
  20. }
  21. return self;
  22. }
  23. - (nullable SCCapturerToken *)getTokenAndInvalidate
  24. {
  25. // ensure serial access by requiring calls be on the main thread
  26. SCAssertMainThread();
  27. let token = _token;
  28. _token = nil;
  29. return token;
  30. }
  31. @end