Chromium Code Reviews| 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 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // // final_tag is hash code of "call_bool_branch_1". | 187 // // final_tag is hash code of "call_bool_branch_1". |
| 188 // net::URLFetcher::Create(url1, ..., final_tag); | 188 // net::URLFetcher::Create(url1, ..., final_tag); |
| 189 // } else { | 189 // } else { |
| 190 // auto final_tag = BranchedCompleteNetworkTrafficAnnotation( | 190 // auto final_tag = BranchedCompleteNetworkTrafficAnnotation( |
| 191 // "call_bool_branch_2", "completion_by_bar", tag, [rest_of_proto]); | 191 // "call_bool_branch_2", "completion_by_bar", tag, [rest_of_proto]); |
| 192 // // final_tag is hash code of "call_bool_branch_2". | 192 // // final_tag is hash code of "call_bool_branch_2". |
| 193 // net::URLFetcher::Create(url2, ..., final_tag); | 193 // net::URLFetcher::Create(url2, ..., final_tag); |
| 194 // } | 194 // } |
| 195 // } | 195 // } |
| 196 | 196 |
| 197 #define TRAFFIC_ANNOTATION_UNINITIALIZED -1 | |
| 198 | |
| 199 // Do not use this unless net-serialization is required. | |
| 200 // TODO(crbug.com/690323): Add tools to check constructor of this structure is | |
| 201 // used only in .mojom.cc files. | |
| 202 struct MutableNetworkTrafficAnnotationTag { | |
| 203 MutableNetworkTrafficAnnotationTag() | |
| 204 : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} | |
| 205 MutableNetworkTrafficAnnotationTag( | |
|
battre
2017/06/01 12:36:36
explicit MutableNetworkTrafficAnnotationTag
same
Ramin Halavati
2017/06/01 13:14:27
Done.
| |
| 206 const NetworkTrafficAnnotationTag& traffic_annotation) | |
| 207 : unique_id_hash_code(traffic_annotation.unique_id_hash_code) {} | |
| 208 int32_t unique_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; | |
|
battre
2017/06/01 12:36:36
isn't this default value duplicative given the con
Ramin Halavati
2017/06/01 13:14:27
Done.
| |
| 209 | |
| 210 explicit operator NetworkTrafficAnnotationTag() const { | |
| 211 return NetworkTrafficAnnotationTag({unique_id_hash_code}); | |
| 212 } | |
| 213 }; | |
| 214 | |
| 215 struct MutablePartialNetworkTrafficAnnotationTag { | |
| 216 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) | |
| 217 MutablePartialNetworkTrafficAnnotationTag() | |
| 218 : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED), | |
| 219 completing_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} | |
| 220 MutablePartialNetworkTrafficAnnotationTag( | |
| 221 const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) | |
| 222 : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code), | |
| 223 completing_id_hash_code( | |
| 224 partial_traffic_annotation.completing_id_hash_code) {} | |
| 225 int32_t unique_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; | |
| 226 int32_t completing_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; | |
| 227 | |
| 228 explicit operator PartialNetworkTrafficAnnotationTag() const { | |
| 229 return PartialNetworkTrafficAnnotationTag( | |
| 230 {unique_id_hash_code, completing_id_hash_code}); | |
| 231 } | |
| 232 #else | |
| 233 MutablePartialNetworkTrafficAnnotationTag() | |
| 234 : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} | |
| 235 MutablePartialNetworkTrafficAnnotationTag( | |
| 236 const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) | |
| 237 : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code) {} | |
| 238 int32_t unique_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; | |
| 239 | |
| 240 explicit operator PartialNetworkTrafficAnnotationTag() const { | |
| 241 return PartialNetworkTrafficAnnotationTag({unique_id_hash_code}); | |
| 242 } | |
| 243 #endif // defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) | |
| 244 }; | |
| 245 | |
| 197 } // namespace net | 246 } // namespace net |
| 198 | 247 |
| 199 // Placeholder for unannotated usages. | 248 // Placeholder for unannotated usages. |
| 200 #define NO_TRAFFIC_ANNOTATION_YET \ | 249 #define NO_TRAFFIC_ANNOTATION_YET \ |
| 201 net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.") | 250 net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.") |
| 202 | 251 |
| 203 #define NO_PARTIAL_TRAFFIC_ANNOTATION_YET \ | 252 #define NO_PARTIAL_TRAFFIC_ANNOTATION_YET \ |
| 204 net::DefinePartialNetworkTrafficAnnotation("undefined", "undefined", \ | 253 net::DefinePartialNetworkTrafficAnnotation("undefined", "undefined", \ |
| 205 "Nothing here yet.") | 254 "Nothing here yet.") |
| 206 | 255 |
| 207 #define MISSING_TRAFFIC_ANNOTATION \ | 256 #define MISSING_TRAFFIC_ANNOTATION \ |
| 208 net::DefineNetworkTrafficAnnotation( \ | 257 net::DefineNetworkTrafficAnnotation( \ |
| 209 "missing", "Function called without traffic annotation.") | 258 "missing", "Function called without traffic annotation.") |
| 210 | 259 |
| 211 #undef COMPUTE_STRING_HASH | 260 #undef COMPUTE_STRING_HASH |
| 212 | 261 |
| 213 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ | 262 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ |
| OLD | NEW |