Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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/AppActivity/FPRScreenTraceTracker.h"
16
 
17
#import <Foundation/Foundation.h>
18
#import <QuartzCore/QuartzCore.h>
19
#import <stdatomic.h>
20
 
21
#import "FirebasePerformance/Sources/Common/FPRConstants.h"
22
#import "FirebasePerformance/Sources/Timer/FIRTrace+Internal.h"
23
 
24
@class UIViewController;
25
 
26
NS_ASSUME_NONNULL_BEGIN
27
 
28
/** Prefix string for screen traces. */
29
FOUNDATION_EXTERN NSString *const kFPRPrefixForScreenTraceName;
30
 
31
/** Counter name for frozen frames. */
32
FOUNDATION_EXTERN NSString *const kFPRFrozenFrameCounterName;
33
 
34
/** Counter name for slow frames. */
35
FOUNDATION_EXTERN NSString *const kFPRSlowFrameCounterName;
36
 
37
/** Counter name for total frames. */
38
FOUNDATION_EXTERN NSString *const kFPRTotalFramesCounterName;
39
 
40
/** Slow frame threshold (for time difference between current and previous frame render time)
41
 *  in sec.
42
 */
43
FOUNDATION_EXTERN CFTimeInterval const kFPRSlowFrameThreshold;
44
 
45
/** Frozen frame threshold (for time difference between current and previous frame render time)
46
 *  in sec.
47
 */
48
FOUNDATION_EXTERN CFTimeInterval const kFPRFrozenFrameThreshold;
49
 
50
@interface FPRScreenTraceTracker ()
51
 
52
/** A map table of that has the viewControllers as the keys and their associated trace as the value.
53
 *  The key is weakly retained and the value is strongly retained.
54
 */
55
@property(nonatomic) NSMapTable<UIViewController *, FIRTrace *> *activeScreenTraces;
56
 
57
/** A list of all UIViewController instances that were visible before app was backgrounded. The
58
 *  viewControllers are reatined weakly.
59
 */
60
@property(nonatomic, nullable) NSPointerArray *previouslyVisibleViewControllers;
61
 
62
/** Serial queue on which all operations that need to be thread safe in this class take place. */
63
@property(nonatomic) dispatch_queue_t screenTraceTrackerSerialQueue;
64
 
65
/** The display link that provides us with the frame rate data. */
66
@property(nonatomic) CADisplayLink *displayLink;
67
 
68
/** Dispatch group which allows us to make this class testable. Instead of waiting an arbitrary
69
 *  amount of time for an asynchronous task to finish before asserting its behavior, we can wait
70
 *  on this dispatch group to finish executing before testing the behavior of any asynchronous
71
 *  task. Consequently, all asynchronous tasks in this class should use this dispatch group.
72
 */
73
@property(nonatomic) dispatch_group_t screenTraceTrackerDispatchGroup;
74
 
75
/** The frozen frames counter. */
76
@property(atomic) int_fast64_t frozenFramesCount;
77
 
78
/** The total frames counter. */
79
@property(atomic) int_fast64_t totalFramesCount;
80
 
81
/** The slow frames counter. */
82
@property(atomic) int_fast64_t slowFramesCount;
83
 
84
/** Handles the appDidBecomeActive notification. Restores the screen traces that were active before
85
 *  the app was backgrounded.
86
 *
87
 *  @param notification The NSNotification object.
88
 */
89
- (void)appDidBecomeActiveNotification:(NSNotification *)notification;
90
 
91
/** Handles the appWillResignActive notification. Saves the names of the screen traces that are
92
 *  currently active and stops all of them.
93
 *
94
 *  @param notification The NSNotification object.
95
 */
96
- (void)appWillResignActiveNotification:(NSNotification *)notification;
97
 
98
/** The method that is invoked by the CADisplayLink when a new frame is rendered. */
99
- (void)displayLinkStep;
100
 
101
/** Tells the screen trace tracker that the given viewController appeared. This should be called
102
 *  from the main thread.
103
 *
104
 * @param viewController The UIViewController instance that appeared.
105
 */
106
- (void)viewControllerDidAppear:(UIViewController *)viewController;
107
 
108
/** Tells the screen trace tracker that the given viewController disappeared. This should be called
109
 *  from the main thread.
110
 *
111
 * @param viewController The UIViewController instance that disappeared.
112
 */
113
- (void)viewControllerDidDisappear:(id)viewController;
114
 
115
@end
116
 
117
NS_ASSUME_NONNULL_END