OLD | NEW |
---|---|
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_key"; | |
grt (UTC plus 2)
2015/02/26 03:21:37
i prefer simply "script_request_incident" so that
robertshield
2015/02/26 04:27:52
Those other preferences sound like jerks to me.
grt (UTC plus 2)
2015/02/26 04:47:18
Their mothers didn't raise them right.
| |
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 to ensure in addition to a fixed key above to ensure that |
grt (UTC plus 2)
2015/02/26 03:21:37
please reduce the ensure-factor of this comment
robertshield
2015/02/26 04:27:52
You can never be too sure.
grt (UTC plus 2)
2015/02/26 04:47:18
Indubitably.
| |
36 // only one incident per user is reported. | |
34 return 42; | 37 return 42; |
35 } | 38 } |
36 | 39 |
37 } // namespace safe_browsing | 40 } // namespace safe_browsing |
OLD | NEW |