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..145a1c3ed3a0c3c86ac48e86062be78dbe54537f 100644 |
| --- a/net/traffic_annotation/network_traffic_annotation.h |
| +++ b/net/traffic_annotation/network_traffic_annotation.h |
| @@ -38,7 +38,7 @@ struct NetworkTrafficAnnotationTag { |
| struct PartialNetworkTrafficAnnotationTag { |
| const int32_t unique_id_hash_code; |
| -#if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
| +#ifndef NDEBUG |
|
jochen (gone - plz use gerrit)
2017/06/12 08:34:25
can you keep the DCHECK_ALWAYS_ON check? i.e.
!de
Ramin Halavati
2017/06/12 09:04:55
Done.
|
| // |completing_id_hash_code| holds a reference to the hash coded unique id |
| // of a network traffic annotation (or group id of several network traffic |
| // annotations) that complete a partial network annotation. Please refer to |
| @@ -97,7 +97,7 @@ constexpr PartialNetworkTrafficAnnotationTag |
| DefinePartialNetworkTrafficAnnotation(const char (&unique_id)[N1], |
| const char (&completing_id)[N2], |
| const char (&proto)[N3]) { |
| -#if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
| +#ifndef NDEBUG |
| return PartialNetworkTrafficAnnotationTag( |
| {COMPUTE_STRING_HASH(unique_id), COMPUTE_STRING_HASH(completing_id)}); |
| #else |
| @@ -114,7 +114,7 @@ NetworkTrafficAnnotationTag CompleteNetworkTrafficAnnotation( |
| const char (&unique_id)[N1], |
| const PartialNetworkTrafficAnnotationTag& partial_annotation, |
| const char (&proto)[N2]) { |
| -#if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
| +#ifndef NDEBUG |
| DCHECK(partial_annotation.completing_id_hash_code == |
| COMPUTE_STRING_HASH(unique_id) || |
| partial_annotation.unique_id_hash_code == |
| @@ -135,7 +135,7 @@ NetworkTrafficAnnotationTag BranchedCompleteNetworkTrafficAnnotation( |
| const char (&group_id)[N2], |
| const PartialNetworkTrafficAnnotationTag& partial_annotation, |
| const char (&proto)[N3]) { |
| -#if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
| +#ifndef NDEBUG |
| DCHECK(partial_annotation.completing_id_hash_code == |
| COMPUTE_STRING_HASH(unique_id) || |
| partial_annotation.unique_id_hash_code == |
| @@ -194,6 +194,58 @@ 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) {} |
| + explicit MutableNetworkTrafficAnnotationTag( |
| + const NetworkTrafficAnnotationTag& traffic_annotation) |
| + : unique_id_hash_code(traffic_annotation.unique_id_hash_code) {} |
| + |
| + int32_t unique_id_hash_code; |
| + |
| + explicit operator NetworkTrafficAnnotationTag() const { |
| + return NetworkTrafficAnnotationTag({unique_id_hash_code}); |
| + } |
| +}; |
| + |
| +struct MutablePartialNetworkTrafficAnnotationTag { |
| +#ifndef NDEBUG |
| + MutablePartialNetworkTrafficAnnotationTag() |
| + : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED), |
| + completing_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} |
| + explicit 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; |
| + int32_t completing_id_hash_code; |
| + |
| + explicit operator PartialNetworkTrafficAnnotationTag() const { |
| + return PartialNetworkTrafficAnnotationTag( |
| + {unique_id_hash_code, completing_id_hash_code}); |
| + } |
| +#else |
| + MutablePartialNetworkTrafficAnnotationTag() |
| + : unique_id_hash_code(TRAFFIC_ANNOTATION_UNINITIALIZED) {} |
| + explicit MutablePartialNetworkTrafficAnnotationTag( |
| + const PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) |
| + : unique_id_hash_code(partial_traffic_annotation.unique_id_hash_code) {} |
| + |
| + int32_t unique_id_hash_code; |
| + |
| + explicit operator PartialNetworkTrafficAnnotationTag() const { |
| + return PartialNetworkTrafficAnnotationTag({unique_id_hash_code}); |
| + } |
| +#endif // NDEBUG |
| +}; |
| + |
| } // namespace net |
| // Placeholder for unannotated usages. |