Index: chrome/browser/net/traffic_annotation/network_traffic_annotation_checker.cc |
diff --git a/chrome/browser/net/traffic_annotation/network_traffic_annotation_checker.cc b/chrome/browser/net/traffic_annotation/network_traffic_annotation_checker.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3d790a9fc51bd137cce632b4a55a3ea259899807 |
--- /dev/null |
+++ b/chrome/browser/net/traffic_annotation/network_traffic_annotation_checker.cc |
@@ -0,0 +1,49 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/net/traffic_annotation/network_traffic_annotation_checker.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace {} |
+ |
+NetworkTrafficAnnotationChecker::NetworkTrafficAnnotationChecker() {} |
+ |
+NetworkTrafficAnnotationChecker::~NetworkTrafficAnnotationChecker() {} |
+ |
+void NetworkTrafficAnnotationChecker::CheckAnnotation( |
+ const net::NetworkTrafficAnnotationTag& traffic_annotation) { |
+#if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON) |
+ if (visited_annotations_.find(traffic_annotation.unique_id) != |
+ visited_annotations_.end()) |
+ return; |
+ |
+ bool syntax_checked = false; |
+ // Check if unique_id/content pair is unique. |
+ for (const auto& other_annotation : visited_annotations_) { |
+ if (!strcmp(other_annotation.first, traffic_annotation.unique_id)) { |
+ if (!strcmp(other_annotation.second, traffic_annotation.proto)) { |
+ // For some reason, there are more than one copie of one pair. |
+ DLOG(WARNING) |
+ << "Traffic other_annotation comes from multiple sources: " |
+ << traffic_annotation.unique_id; |
+ syntax_checked = true; |
+ break; |
+ } else { |
+ DLOG(ERROR) |
+ << "Traffic other_annotation unique id with multiple protos: " |
+ << traffic_annotation.unique_id; |
+ } |
+ } |
+ } |
+ // Check if content syntax is correct and complete. |
+ if (!syntax_checked) { |
+ // Proto stuff. |
+ } |
+ |
+ // Add it to the list. |
+ visited_annotations_.insert( |
+ std::make_pair(traffic_annotation.unique_id, traffic_annotation.proto)); |
+#endif |
+} |