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

Unified Diff: chrome/browser/safe_browsing/tracked_preference_incident_handlers.cc

Issue 411793004: More fine-grained pruning in safe browsing incident reporting service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: extract incident-specific code into its own file Created 6 years, 5 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
Index: chrome/browser/safe_browsing/tracked_preference_incident_handlers.cc
diff --git a/chrome/browser/safe_browsing/tracked_preference_incident_handlers.cc b/chrome/browser/safe_browsing/tracked_preference_incident_handlers.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3c86b2d71476caa763b5bf4987c1294fa284f099
--- /dev/null
+++ b/chrome/browser/safe_browsing/tracked_preference_incident_handlers.cc
@@ -0,0 +1,46 @@
+// Copyright 2014 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/safe_browsing/tracked_preference_incident_handlers.h"
+
+#include "base/logging.h"
+#include "chrome/browser/safe_browsing/incident_handler_util.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
+
+namespace safe_browsing {
+
+std::string GetTrackedPreferenceIncidentKey(
+ const ClientIncidentReport_IncidentData& incident_data) {
+ DCHECK(incident_data.has_tracked_preference());
+ DCHECK(incident_data.tracked_preference().has_path());
+ return incident_data.tracked_preference().path();
+}
+
+uint32_t GetTrackedPreferenceIncidentDigest(
+ const ClientIncidentReport_IncidentData& incident_data) {
+ DCHECK(incident_data.has_tracked_preference());
+
+ // Make a canonical representation of the incident's payload over which a hash
+ // digest is computed.
+ const ClientIncidentReport_IncidentData_TrackedPreferenceIncident& input =
+ incident_data.tracked_preference();
+ ClientIncidentReport_IncidentData_TrackedPreferenceIncident incident;
+
+ if (input.has_path() && !input.path().empty())
+ incident.set_path(input.path());
+ if (input.has_atomic_value() && !input.atomic_value().empty()) {
+ incident.set_atomic_value(input.atomic_value());
+ } else {
+ for (int i = 0; i < input.split_key_size(); ++i) {
+ if (!input.split_key(i).empty())
+ incident.add_split_key(input.split_key(i));
+ }
+ }
+ if (input.has_value_state())
+ incident.set_value_state(input.value_state());
+
+ return HashMessage(incident);
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698