FPRNetworkInstrumentHelpers.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. @class FPRSelectorInstrumentor;
  16. @class FPRClassInstrumentor;
  17. /** Throws an exception declaring that the selector was not found on the class. This is a
  18. * convenience function.
  19. *
  20. * This should only be invoked when one of two things has happened:
  21. * - The underlying iOS implementation removes a method on a class and we haven't detected it yet.
  22. * - We instrument a new method using the wrong selector/class combo and don't discover that
  23. * through unit tests or other kinds of testing or development.
  24. *
  25. * @param selector The selector being invoked.
  26. * @param aClass The class the selector belongs to.
  27. * @throws An exception if invoked.
  28. */
  29. FOUNDATION_EXTERN
  30. void ThrowExceptionBecauseSelectorNotFoundOnClass(SEL selector, Class aClass);
  31. /** Throws an exception declaring that the selector instrumentor has been deallocated. This is a
  32. * convenience function.
  33. *
  34. * This should only be invoked when the selector instrumentor has been deallocated, but for some
  35. * reason -unswizzle was not called.
  36. *
  37. * @param selector The selector being invoked.
  38. * @param aClass The class the selector belongs to.
  39. * @throws An exception if invoked.
  40. */
  41. FOUNDATION_EXTERN
  42. void ThrowExceptionBecauseSelectorInstrumentorHasBeenDeallocated(SEL selector, Class aClass);
  43. /** Throws an exception declaring that the instrument attempting to register a class has been
  44. * deallocated.
  45. *
  46. * This should only be invoked when the instrument of an iOS class cluster has been deallocated,
  47. * but not unswizzled.
  48. *
  49. * @param selector The selector being invoked.
  50. * @param aClass The class the selector belongs to.
  51. * @throws An exception if invoked.
  52. */
  53. FOUNDATION_EXTERN
  54. void ThrowExceptionBecauseInstrumentHasBeenDeallocated(SEL selector, Class aClass);
  55. /** Returns an FPRSelectorInstrumentor given a SEL and FPRClassInstrumentor. This is a convenience
  56. * function.
  57. *
  58. * @param selector The selector to instrument.
  59. * @param instrumentor The class instrumentor to generate the selector instrumentor from.
  60. * @param isClassSelector YES if the selector is a class selector, NO otherwise.
  61. * @return An FPRSelectorInstrumentor instance if the selector is on the class.
  62. * @throws An exception if the selector is NOT found on the class.
  63. */
  64. FOUNDATION_EXTERN
  65. FPRSelectorInstrumentor *SelectorInstrumentor(SEL selector,
  66. FPRClassInstrumentor *instrumentor,
  67. BOOL isClassSelector);