Chromium Code Reviews| Index: net/traffic_annotation/network_traffic_annotation.h |
| diff --git a/net/traffic_annotation/network_traffic_annotation.h b/net/traffic_annotation/network_traffic_annotation.h |
| index 69c620655806300d8974997acace2b0578d64630..883ec986bd1390133d70989a17943a4202a541f5 100644 |
| --- a/net/traffic_annotation/network_traffic_annotation.h |
| +++ b/net/traffic_annotation/network_traffic_annotation.h |
| @@ -194,6 +194,55 @@ NetworkTrafficAnnotationTag BranchedCompleteNetworkTrafficAnnotation( |
| // } |
| // } |
| +#define TRAFFIC_ANNOTATION_UNINITIALIZED -1 |
| + |
| +// Do not use this unless net-serialization is required. |
| +// TODO(crbug.com/690323): Add tools to check constructor of this structure is |
| +// used only in .mojom.cc files. |
| +struct MutableNetworkTrafficAnnotationTag { |
| + MutableNetworkTrafficAnnotationTag() |
| + : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} |
| + MutableNetworkTrafficAnnotationTag( |
|
battre
2017/06/01 12:36:36
explicit MutableNetworkTrafficAnnotationTag
same
Ramin Halavati
2017/06/01 13:14:27
Done.
|
| + const NetworkTrafficAnnotationTag& traffic_annotation) |
| + : unique_id_hash_code(traffic_annotation.unique_id_hash_code) {} |
| + 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.
|
| + |
| + explicit operator NetworkTrafficAnnotationTag() const { |
| + return NetworkTrafficAnnotationTag({unique_id_hash_code}); |
| + } |
| +}; |
| + |
| +struct MutablePartialNetworkTrafficAnnotationTag { |
| +#if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
| + MutablePartialNetworkTrafficAnnotationTag() |
| + : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED), |
| + completing_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} |
| + MutablePartialNetworkTrafficAnnotationTag( |
| + const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) |
| + : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code), |
| + completing_id_hash_code( |
| + partial_traffic_annotation.completing_id_hash_code) {} |
| + int32_t unique_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; |
| + int32_t completing_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; |
| + |
| + explicit operator PartialNetworkTrafficAnnotationTag() const { |
| + return PartialNetworkTrafficAnnotationTag( |
| + {unique_id_hash_code, completing_id_hash_code}); |
| + } |
| +#else |
| + MutablePartialNetworkTrafficAnnotationTag() |
| + : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} |
| + MutablePartialNetworkTrafficAnnotationTag( |
| + const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) |
| + : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code) {} |
| + int32_t unique_id_hash_code = TRAFFIC_ANNOTATION_UNINITIALIZED; |
| + |
| + explicit operator PartialNetworkTrafficAnnotationTag() const { |
| + return PartialNetworkTrafficAnnotationTag({unique_id_hash_code}); |
| + } |
| +#endif // defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
| +}; |
| + |
| } // namespace net |
| // Placeholder for unannotated usages. |