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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/script_request_incident.cc

Issue 961483003: Throttle script request incidents to one per user. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure peer acceptance of key name. Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/incident_reporting/script_request_inciden t.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/script_request_inciden t.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/safe_browsing/incident_reporting/incident_handler_util. h" 8 #include "chrome/browser/safe_browsing/incident_reporting/incident_handler_util. h"
9 #include "chrome/common/safe_browsing/csd.pb.h" 9 #include "chrome/common/safe_browsing/csd.pb.h"
10 10
11 namespace safe_browsing { 11 namespace safe_browsing {
12 12
13 ScriptRequestIncident::ScriptRequestIncident( 13 ScriptRequestIncident::ScriptRequestIncident(
14 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> 14 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident>
15 script_request_incident) { 15 script_request_incident) {
16 DCHECK(script_request_incident); 16 DCHECK(script_request_incident);
17 DCHECK(script_request_incident->has_script_digest()); 17 DCHECK(script_request_incident->has_script_digest());
18 payload()->set_allocated_script_request(script_request_incident.release()); 18 payload()->set_allocated_script_request(script_request_incident.release());
19 } 19 }
20 20
21 ScriptRequestIncident::~ScriptRequestIncident() { 21 ScriptRequestIncident::~ScriptRequestIncident() {
22 } 22 }
23 23
24 IncidentType ScriptRequestIncident::GetType() const { 24 IncidentType ScriptRequestIncident::GetType() const {
25 return IncidentType::SCRIPT_REQUEST; 25 return IncidentType::SCRIPT_REQUEST;
26 } 26 }
27 27
28 std::string ScriptRequestIncident::GetKey() const { 28 std::string ScriptRequestIncident::GetKey() const {
29 return payload()->script_request().script_digest(); 29 // Use a static key in addition to a fixed digest below to ensure that only
30 // one incident per user is reported.
31 return "script_request_incident";
30 } 32 }
31 33
32 uint32_t ScriptRequestIncident::ComputeDigest() const { 34 uint32_t ScriptRequestIncident::ComputeDigest() const {
33 // Return a constant to ensure that only one incident per digest is reported. 35 // Return a constant in addition to a fixed key above to ensure that only one
36 // incident per user is reported.
34 return 42; 37 return 42;
35 } 38 }
36 39
37 } // namespace safe_browsing 40 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698