PerfTraceView.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #import <UIKit/UIKit.h>
  16. #import "FirebasePerformance/Sources/Public/FIRTrace.h"
  17. @class PerfTraceView;
  18. @protocol PerfTraceViewDelegate <NSObject>
  19. /**
  20. * Delegate method that is called whenever the trace is stopped.
  21. *
  22. * @param traceView Instance of the traceView generating the request to stop.
  23. */
  24. - (void)perfTraceViewTraceStopped:(nonnull PerfTraceView *)traceView;
  25. @end
  26. /**
  27. * PerfTraceView represents an FPRTrace in the PerfSDK. This class will enable the user to create
  28. * a view, add stages, initialize/increment metrics and stop the trace. This object also
  29. * abstracts the use of the PerfSDK's FPRTrace object.
  30. */
  31. @interface PerfTraceView : UIView
  32. @property(nonatomic, nonnull, readonly) FIRTrace *trace;
  33. @property(nonatomic, nullable, weak) id<PerfTraceViewDelegate> delegate;
  34. /** @brief Not a valid initializer. */
  35. - (nonnull instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
  36. /** @brief Not a valid initializer. */
  37. - (nonnull instancetype)initWithCoder:(nullable NSCoder *)coder NS_UNAVAILABLE;
  38. /** @brief Not a valid initializer. */
  39. - (nonnull instancetype)init NS_UNAVAILABLE;
  40. /**
  41. * Creates a new trace view using the FPRTrace object provided.
  42. *
  43. * @param trace The trace object for which the view is created.
  44. * @param frame Frame size of the view.
  45. * @return An instance of PerfTraceView.
  46. */
  47. - (nullable instancetype)initWithTrace:(nonnull FIRTrace *)trace
  48. frame:(CGRect)frame NS_DESIGNATED_INITIALIZER;
  49. @end