1 |
efrain |
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 |
|
|
|
15 |
#import "FirebasePerformance/Sources/Instrumentation/FPRInstrument.h"
|
|
|
16 |
|
|
|
17 |
#import <GoogleUtilities/GULSwizzledObject.h>
|
|
|
18 |
|
|
|
19 |
@class FPRSelectorInstrumentor;
|
|
|
20 |
|
|
|
21 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
22 |
|
|
|
23 |
/** Defines the interface that an instrumentor should implement if they are going to instrument
|
|
|
24 |
* objects.
|
|
|
25 |
*/
|
|
|
26 |
@protocol FPRObjectInstrumentorProtocol <NSObject>
|
|
|
27 |
|
|
|
28 |
@required
|
|
|
29 |
|
|
|
30 |
/** Registers an instance of the delegate class to be instrumented.
|
|
|
31 |
*
|
|
|
32 |
* @param object The instance to instrument.
|
|
|
33 |
*/
|
|
|
34 |
- (void)registerObject:(id)object;
|
|
|
35 |
|
|
|
36 |
@end
|
|
|
37 |
|
|
|
38 |
/** This class allows the instrumentation of specific objects by isa swizzling specific instances
|
|
|
39 |
* with a dynamically generated subclass of the object's original class and installing methods
|
|
|
40 |
* onto this new class.
|
|
|
41 |
*/
|
|
|
42 |
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
|
|
|
43 |
@interface FPRObjectInstrumentor : FPRInstrument
|
|
|
44 |
|
|
|
45 |
/** The instrumented object. */
|
|
|
46 |
@property(nonatomic, weak) id instrumentedObject;
|
|
|
47 |
|
|
|
48 |
/** YES if there is reason to swizzle, NO if swizzling is not needed. */
|
|
|
49 |
@property(nonatomic) BOOL hasModifications;
|
|
|
50 |
|
|
|
51 |
/** Please use the designated initializer. */
|
|
|
52 |
- (instancetype)init NS_UNAVAILABLE;
|
|
|
53 |
|
|
|
54 |
/** Instantiates an instance of this class. The designated initializer.
|
|
|
55 |
*
|
|
|
56 |
* @param object The object to be instrumented.
|
|
|
57 |
* @return An instance of this class.
|
|
|
58 |
*/
|
|
|
59 |
- (instancetype)initWithObject:(id)object NS_DESIGNATED_INITIALIZER;
|
|
|
60 |
|
|
|
61 |
/** Attempts to copy a selector from a donor class onto the dynamically generated subclass that the
|
|
|
62 |
* object will adopt when -swizzle is called.
|
|
|
63 |
*
|
|
|
64 |
* @param selector The selector to use.
|
|
|
65 |
* @param aClass The class to copy the selector from.
|
|
|
66 |
* @param isClassSelector YES if the selector is a class selector, NO otherwise.
|
|
|
67 |
*/
|
|
|
68 |
- (void)copySelector:(SEL)selector fromClass:(Class)aClass isClassSelector:(BOOL)isClassSelector;
|
|
|
69 |
|
|
|
70 |
/** Swizzles the isa of the object and sets its class to the dynamically created subclass. */
|
|
|
71 |
- (void)swizzle;
|
|
|
72 |
|
|
|
73 |
@end
|
|
|
74 |
|
|
|
75 |
NS_ASSUME_NONNULL_END
|