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 explicit MutableNetworkTrafficAnnotationTag( | |
| 206 const NetworkTrafficAnnotationTag& traffic_annotation) | |
| 207 : unique_id_hash_code(traffic_annotation.unique_id_hash_code) {} | |
| 208 | |
| 209 int32_t unique_id_hash_code; | |
| 210 | |
| 211 explicit operator NetworkTrafficAnnotationTag() const { | |
| 212 return NetworkTrafficAnnotationTag({unique_id_hash_code}); | |
| 213 } | |
| 214 }; | |
| 215 | |
| 216 struct MutablePartialNetworkTrafficAnnotationTag { | |
| 217 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) | |
|
jochen (gone - plz use gerrit)
2017/06/08 17:00:58
why _DEBUG?
Ramin Halavati
2017/06/09 07:08:53
Replaced it with '#ifndef NDEBUG' for all cases.
| |
| 218 MutablePartialNetworkTrafficAnnotationTag() | |
| 219 : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED), | |
| 220 completing_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} | |
| 221 explicit MutablePartialNetworkTrafficAnnotationTag( | |
| 222 const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) | |
| 223 : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code), | |
| 224 completing_id_hash_code( | |
| 225 partial_traffic_annotation.completing_id_hash_code) {} | |
| 226 | |
| 227 int32_t unique_id_hash_code; | |
| 228 int32_t completing_id_hash_code; | |
| 229 | |
| 230 explicit operator PartialNetworkTrafficAnnotationTag() const { | |
| 231 return PartialNetworkTrafficAnnotationTag( | |
| 232 {unique_id_hash_code, completing_id_hash_code}); | |
| 233 } | |
| 234 #else | |
| 235 MutablePartialNetworkTrafficAnnotationTag() | |
| 236 : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} | |
| 237 explicit MutablePartialNetworkTrafficAnnotationTag( | |
| 238 const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) | |
| 239 : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code) {} | |
| 240 | |
| 241 int32_t unique_id_hash_code; | |
| 242 | |
| 243 explicit operator PartialNetworkTrafficAnnotationTag() const { | |
| 244 return PartialNetworkTrafficAnnotationTag({unique_id_hash_code}); | |
| 245 } | |
| 246 #endif // defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) | |
| 247 }; | |
| 248 | |
| 197 } // namespace net | 249 } // namespace net |
| 198 | 250 |
| 199 // Placeholder for unannotated usages. | 251 // Placeholder for unannotated usages. |
| 200 #define NO_TRAFFIC_ANNOTATION_YET \ | 252 #define NO_TRAFFIC_ANNOTATION_YET \ |
| 201 net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.") | 253 net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.") |
| 202 | 254 |
| 203 #define NO_PARTIAL_TRAFFIC_ANNOTATION_YET \ | 255 #define NO_PARTIAL_TRAFFIC_ANNOTATION_YET \ |
| 204 net::DefinePartialNetworkTrafficAnnotation("undefined", "undefined", \ | 256 net::DefinePartialNetworkTrafficAnnotation("undefined", "undefined", \ |
| 205 "Nothing here yet.") | 257 "Nothing here yet.") |
| 206 | 258 |
| 207 #define MISSING_TRAFFIC_ANNOTATION \ | 259 #define MISSING_TRAFFIC_ANNOTATION \ |
| 208 net::DefineNetworkTrafficAnnotation( \ | 260 net::DefineNetworkTrafficAnnotation( \ |
| 209 "missing", "Function called without traffic annotation.") | 261 "missing", "Function called without traffic annotation.") |
| 210 | 262 |
| 211 #undef COMPUTE_STRING_HASH | 263 #undef COMPUTE_STRING_HASH |
| 212 | 264 |
| 213 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ | 265 #endif // NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ |
| OLD | NEW |