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

Side by Side Diff: chrome/browser/net/traffic_annotation/network_traffic_annotation_checker.cc

Issue 2866183003: Syntax and coverage checking added to Network Traffic Annotations. (Closed)
Patch Set: Protobuf build updated. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/traffic_annotation/network_traffic_annotation_check er.h"
6
7 #include "base/logging.h"
8
9 namespace {}
10
11 NetworkTrafficAnnotationChecker::NetworkTrafficAnnotationChecker() {}
12
13 NetworkTrafficAnnotationChecker::~NetworkTrafficAnnotationChecker() {}
14
15 void NetworkTrafficAnnotationChecker::CheckAnnotation(
16 const net::NetworkTrafficAnnotationTag& traffic_annotation) {
17 #if defined(_DEBUG) || defined(DCHECK_ALWAYS_ON)
18 if (visited_annotations_.find(traffic_annotation.unique_id) !=
19 visited_annotations_.end())
20 return;
21
22 bool syntax_checked = false;
23 // Check if unique_id/content pair is unique.
24 for (const auto& other_annotation : visited_annotations_) {
25 if (!strcmp(other_annotation.first, traffic_annotation.unique_id)) {
26 if (!strcmp(other_annotation.second, traffic_annotation.proto)) {
27 // For some reason, there are more than one copie of one pair.
28 DLOG(WARNING)
29 << "Traffic other_annotation comes from multiple sources: "
30 << traffic_annotation.unique_id;
31 syntax_checked = true;
32 break;
33 } else {
34 DLOG(ERROR)
35 << "Traffic other_annotation unique id with multiple protos: "
36 << traffic_annotation.unique_id;
37 }
38 }
39 }
40 // Check if content syntax is correct and complete.
41 if (!syntax_checked) {
42 // Proto stuff.
43 }
44
45 // Add it to the list.
46 visited_annotations_.insert(
47 std::make_pair(traffic_annotation.unique_id, traffic_annotation.proto));
48 #endif
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698