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

Unified Diff: net/traffic_annotation/network_traffic_annotation.h

Issue 2893233002: Network traffic annotation added to URLLoaderImpl. (Closed)
Patch Set: Comment addressed, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/network/url_loader_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9f5d8ea0e70d13123946731ef0a6c2baab9fe3d1 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)
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
// |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)
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
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)
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
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)
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
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 {
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
+ 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 // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
+};
+
} // namespace net
// Placeholder for unannotated usages.
« no previous file with comments | « content/network/url_loader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698