Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: net/traffic_annotation/network_traffic_annotation.h

Issue 2908723002: Partial network traffic annotation check for tests updated. (Closed)
Patch Set: Merged. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace { 10 namespace {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // This function can be used to define a completing partial annotation. This 108 // This function can be used to define a completing partial annotation. This
109 // annotation adds details to another annotation that is defined before. 109 // annotation adds details to another annotation that is defined before.
110 // |partial_annotation| is the PartialNetworkTrafficAnnotationTag returned 110 // |partial_annotation| is the PartialNetworkTrafficAnnotationTag returned
111 // by a call to DefinePartialNetworkTrafficAnnotation(). 111 // by a call to DefinePartialNetworkTrafficAnnotation().
112 template <size_t N1, size_t N2> 112 template <size_t N1, size_t N2>
113 NetworkTrafficAnnotationTag CompleteNetworkTrafficAnnotation( 113 NetworkTrafficAnnotationTag CompleteNetworkTrafficAnnotation(
114 const char (&unique_id)[N1], 114 const char (&unique_id)[N1],
115 const PartialNetworkTrafficAnnotationTag& partial_annotation, 115 const PartialNetworkTrafficAnnotationTag& partial_annotation,
116 const char (&proto)[N2]) { 116 const char (&proto)[N2]) {
117 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) 117 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON)
118 DCHECK_EQ(COMPUTE_STRING_HASH(unique_id), 118 DCHECK(partial_annotation.completing_id_hash_code ==
119 partial_annotation.completing_id_hash_code); 119 COMPUTE_STRING_HASH(unique_id) ||
120 partial_annotation.unique_id_hash_code ==
121 COMPUTE_STRING_HASH("test_partial"));
120 #endif 122 #endif
121 return NetworkTrafficAnnotationTag({partial_annotation.unique_id_hash_code}); 123 return NetworkTrafficAnnotationTag({partial_annotation.unique_id_hash_code});
122 } 124 }
123 125
124 // This function can be used to define a completing partial annotation that is 126 // This function can be used to define a completing partial annotation that is
125 // branched into several annotations. In this case, |group_id| is a common id 127 // branched into several annotations. In this case, |group_id| is a common id
126 // that is used by all members of the branch and referenced by partial 128 // that is used by all members of the branch and referenced by partial
127 // annotation that is completed by them. 129 // annotation that is completed by them.
128 template <size_t N1, size_t N2, size_t N3> 130 template <size_t N1, size_t N2, size_t N3>
129 NetworkTrafficAnnotationTag BranchedCompleteNetworkTrafficAnnotation( 131 NetworkTrafficAnnotationTag BranchedCompleteNetworkTrafficAnnotation(
130 const char (&unique_id)[N1], 132 const char (&unique_id)[N1],
131 const char (&group_id)[N2], 133 const char (&group_id)[N2],
132 const PartialNetworkTrafficAnnotationTag& partial_annotation, 134 const PartialNetworkTrafficAnnotationTag& partial_annotation,
133 const char (&proto)[N3]) { 135 const char (&proto)[N3]) {
134 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) 136 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON)
135 DCHECK_EQ(COMPUTE_STRING_HASH(group_id), 137 DCHECK(partial_annotation.completing_id_hash_code ==
136 partial_annotation.completing_id_hash_code); 138 COMPUTE_STRING_HASH(unique_id) ||
139 partial_annotation.unique_id_hash_code ==
140 COMPUTE_STRING_HASH("test_partial"));
137 #endif 141 #endif
138 return NetworkTrafficAnnotationTag({COMPUTE_STRING_HASH(unique_id)}); 142 return NetworkTrafficAnnotationTag({COMPUTE_STRING_HASH(unique_id)});
139 } 143 }
140 144
141 // Example for joining N x 1 partial annotations: 145 // Example for joining N x 1 partial annotations:
142 // N functions foo1(), ..., fooN() call one function bar(). Each 146 // N functions foo1(), ..., fooN() call one function bar(). Each
143 // foo...() function defines part of a network traffic annotation. 147 // foo...() function defines part of a network traffic annotation.
144 // These N partial annotations are combined with a second part in 148 // These N partial annotations are combined with a second part in
145 // bar(). 149 // bar().
146 // 150 //
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 #define NO_TRAFFIC_ANNOTATION_YET \ 196 #define NO_TRAFFIC_ANNOTATION_YET \
193 net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.") 197 net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.")
194 198
195 #define MISSING_TRAFFIC_ANNOTATION \ 199 #define MISSING_TRAFFIC_ANNOTATION \
196 net::DefineNetworkTrafficAnnotation( \ 200 net::DefineNetworkTrafficAnnotation( \
197 "missing", "Function called without traffic annotation.") 201 "missing", "Function called without traffic annotation.")
198 202
199 #undef COMPUTE_STRING_HASH 203 #undef COMPUTE_STRING_HASH
200 204
201 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ 205 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698