OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ | 5 #ifndef NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ |
6 #define NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ | 6 #define NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ |
7 | 7 |
8 namespace net { | 8 namespace net { |
9 | 9 |
10 // Defined type for network traffic annotation tags. | 10 // Defined type for network traffic annotation tags. |
11 using NetworkTrafficAnnotationTag = const char*; | 11 using NetworkTrafficAnnotationTag = const char* const; |
12 | 12 |
13 // Function to convert a network traffic annotation's unique id and protobuf | 13 // Function to convert a network traffic annotation's unique id and protobuf |
14 // text into a NetworkTrafficAnnotationTag. | 14 // text into a NetworkTrafficAnnotationTag. |
15 // | 15 // |
16 // This function serves as a tag that can be discovered and extracted via | 16 // This function serves as a tag that can be discovered and extracted via |
17 // clang tools. This allows reviewing all network traffic that is generated | 17 // clang tools. This allows reviewing all network traffic that is generated |
18 // and annotated by Chrome. | 18 // and annotated by Chrome. |
19 // | 19 // |
20 // |unique_id| should be a string that uniquely identifies this annotation | 20 // |unique_id| should be a string that uniquely identifies this annotation |
21 // across all of Chromium source code. | 21 // across all of Chromium source code. |
22 // |proto| is a text-encoded NetworkTrafficAnnotation protobuf (see | 22 // |proto| is a text-encoded NetworkTrafficAnnotation protobuf (see |
23 // tools/traffic_annotaiton/traffic_annotation.proto) | 23 // tools/traffic_annotation/traffic_annotation.proto) |
24 // | 24 // |
25 // An empty and a sample template for the text-encoded protobuf can be found in | 25 // An empty and a sample template for the text-encoded protobuf can be found in |
26 // //tools/traffic_annotation/sample_traffic_annotation.cc. | 26 // //tools/traffic_annotation/sample_traffic_annotation.cc. |
27 // TODO(crbug.com/690323): Add tools to check annotation text's format during | 27 // TODO(crbug.com/690323): Add tools to check annotation text's format during |
28 // presubmit checks. | 28 // presubmit checks. |
29 template <size_t N1, size_t N2> | 29 template <size_t N1, size_t N2> |
30 constexpr NetworkTrafficAnnotationTag DefineNetworkTrafficAnnotation( | 30 constexpr NetworkTrafficAnnotationTag DefineNetworkTrafficAnnotation( |
31 const char (&unique_id)[N1], | 31 const char (&unique_id)[N1], |
32 const char (&proto)[N2]) { | 32 const char (&proto)[N2]) { |
33 return unique_id; | 33 return unique_id; |
34 } | 34 } |
35 | 35 |
36 } // namespace net | 36 } // namespace net |
37 | 37 |
38 // Placeholder for unannotated usages. | 38 // Placeholder for unannotated usages. |
39 #define NO_TRAFFIC_ANNOTATION_YET \ | 39 #define NO_TRAFFIC_ANNOTATION_YET \ |
40 net::DefineNetworkTrafficAnnotation("Undefined", "Nothing here yet.") | 40 net::DefineNetworkTrafficAnnotation("Undefined", "Nothing here yet.") |
41 | 41 |
42 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ | 42 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ |
OLD | NEW |