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 <Foundation/Foundation.h>
|
|
|
16 |
|
|
|
17 |
#import "FIRPerformanceAttributable.h"
|
|
|
18 |
|
|
|
19 |
// clang-format off
|
|
|
20 |
// clang-format12 does a weird cascading indent of this enum.
|
|
|
21 |
/* Different HTTP methods. */
|
|
|
22 |
typedef NS_ENUM(NSInteger, FIRHTTPMethod) {
|
|
|
23 |
/** HTTP Method GET */
|
|
|
24 |
FIRHTTPMethodGET NS_SWIFT_NAME(get),
|
|
|
25 |
/** HTTP Method PUT */
|
|
|
26 |
FIRHTTPMethodPUT NS_SWIFT_NAME(put),
|
|
|
27 |
/** HTTP Method POST */
|
|
|
28 |
FIRHTTPMethodPOST NS_SWIFT_NAME(post),
|
|
|
29 |
/** HTTP Method DELETE */
|
|
|
30 |
FIRHTTPMethodDELETE NS_SWIFT_NAME(delete),
|
|
|
31 |
/** HTTP Method HEAD */
|
|
|
32 |
FIRHTTPMethodHEAD NS_SWIFT_NAME(head),
|
|
|
33 |
/** HTTP Method PATCH */
|
|
|
34 |
FIRHTTPMethodPATCH NS_SWIFT_NAME(patch),
|
|
|
35 |
/** HTTP Method OPTIONS */
|
|
|
36 |
FIRHTTPMethodOPTIONS NS_SWIFT_NAME(options),
|
|
|
37 |
/** HTTP Method TRACE */
|
|
|
38 |
FIRHTTPMethodTRACE NS_SWIFT_NAME(trace),
|
|
|
39 |
/** HTTP Method CONNECT */
|
|
|
40 |
FIRHTTPMethodCONNECT NS_SWIFT_NAME(connect)
|
|
|
41 |
} NS_SWIFT_NAME(HTTPMethod);
|
|
|
42 |
// clang-format on
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* FIRHTTPMetric object can be used to make the SDK record information about a HTTP network request.
|
|
|
46 |
*/
|
|
|
47 |
NS_SWIFT_NAME(HTTPMetric)
|
|
|
48 |
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
|
|
|
49 |
@interface FIRHTTPMetric : NSObject <FIRPerformanceAttributable>
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Creates HTTPMetric object for a network request.
|
|
|
53 |
* @param URL The URL for which the metrics are recorded.
|
|
|
54 |
* @param httpMethod HTTP method used by the request.
|
|
|
55 |
*/
|
|
|
56 |
- (nullable instancetype)initWithURL:(nonnull NSURL *)URL
|
|
|
57 |
HTTPMethod:(FIRHTTPMethod)httpMethod NS_SWIFT_NAME(init(url:httpMethod:));
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Use `initWithURL:HTTPMethod:` for Objective-C and `init(url:httpMethod:)` for Swift.
|
|
|
61 |
*/
|
|
|
62 |
- (nonnull instancetype)init NS_UNAVAILABLE;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* @brief HTTP Response code. Values are greater than 0.
|
|
|
66 |
*/
|
|
|
67 |
@property(nonatomic, assign) NSInteger responseCode;
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* @brief Size of the request payload.
|
|
|
71 |
*/
|
|
|
72 |
@property(nonatomic, assign) long requestPayloadSize;
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
* @brief Size of the response payload.
|
|
|
76 |
*/
|
|
|
77 |
@property(nonatomic, assign) long responsePayloadSize;
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* @brief HTTP Response content type.
|
|
|
81 |
*/
|
|
|
82 |
@property(nonatomic, nullable, copy) NSString *responseContentType;
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Marks the start time of the request.
|
|
|
86 |
*/
|
|
|
87 |
- (void)start;
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Marks the end time of the response and queues the network request metric on the device for
|
|
|
91 |
* transmission. Check the logs if the metric is valid.
|
|
|
92 |
*/
|
|
|
93 |
- (void)stop;
|
|
|
94 |
|
|
|
95 |
@end
|