FPRProxyObjectHelper.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. /** This class helps the instrumentation deal with objects that have been wrapped with NSProxy
  16. * objects after being swizzled by other SDKs. In particular, Crittercism swizzles NSURLSessions
  17. * and makes every NSURLSession initialization method return an NSProxy subclass.
  18. */
  19. @interface FPRProxyObjectHelper : NSObject
  20. /** Registers a proxy object for a given class and runs the onSuccess block whenever an ivar of the
  21. * given class is discovered on the proxy object.
  22. *
  23. * @param proxy The proxy object whose ivars will be iterated.
  24. * @param superclass The superclass all ivars will be compared against. See varFoundHandler.
  25. * @param varFoundHandler The block to run when an ivar isKindOfClass:aClass.
  26. */
  27. + (void)registerProxyObject:(id)proxy
  28. forSuperclass:(Class)superclass
  29. varFoundHandler:(void (^)(id ivar))varFoundHandler;
  30. /** Registers a proxy object for a given class and runs the onSuccess block whenever an ivar of the
  31. * given class is discovered on the proxy object.
  32. *
  33. * @param proxy The proxy object whose ivars will be iterated.
  34. * @param protocol The protocol all ivars will be compared against. See varFoundHandler.
  35. * @param varFoundHandler The block to run when an ivar conformsToProtocol:protocol.
  36. */
  37. + (void)registerProxyObject:(id)proxy
  38. forProtocol:(Protocol *)protocol
  39. varFoundHandler:(void (^)(id ivar))varFoundHandler;
  40. @end