FPRInstrument.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 FPRClassInstrumentor;
  16. NS_ASSUME_NONNULL_BEGIN
  17. /** FPRInstrument instances can instrument many different classes, but should try to instrument
  18. * only a single class in the general case. Due to class clusters, FPRInstruments need to be able
  19. * to support logical groups of classes, even if the public API is a single class (e.g.
  20. * NSDictionary or NSURLSession. FPRInstrument is expected to be subclassed by other classes that
  21. * actually implement the instrument. Subclasses should provide their own implementations of
  22. * registerInstrumentor
  23. */
  24. NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
  25. @interface FPRInstrument : NSObject
  26. /** The list of class instrumentors. count should == 1 in most cases, and be > 1 for class clusters.
  27. */
  28. @property(nonatomic, readonly) NSArray<FPRClassInstrumentor *> *classInstrumentors;
  29. /** A set of the instrumented classes. */
  30. @property(nonatomic, readonly) NSSet<Class> *instrumentedClasses;
  31. /**
  32. * Checks if the given object is instrumentable and returns YES if instrumentable. NO, otherwise.
  33. *
  34. * @param object Object that needs to be validated.
  35. * @return Yes if instrumentable, NO otherwise.
  36. */
  37. - (BOOL)isObjectInstrumentable:(id)object;
  38. /** Registers all instrumentors this instrument will utilize. Should be instrumented in a subclass.
  39. *
  40. * @note This method is thread-safe.
  41. */
  42. - (void)registerInstrumentors;
  43. /** Deregisters the instrumentors by using API provided by FPRClassInstrumentor. Called by dealloc.
  44. *
  45. * @note This method is thread-safe.
  46. */
  47. - (void)deregisterInstrumentors;
  48. @end
  49. NS_ASSUME_NONNULL_END