Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / safe_browsing / incident_reporting / resource_request_incident.cc
blob03b80fa126b1ffd916779d88c05c0985236ecbbc
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
3 // found in the LICENSE file.
5 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_incident.h"
7 #include "base/logging.h"
8 #include "chrome/browser/safe_browsing/incident_reporting/incident_handler_util.h"
9 #include "chrome/common/safe_browsing/csd.pb.h"
11 namespace safe_browsing {
13 ResourceRequestIncident::ResourceRequestIncident(
14 scoped_ptr<ClientIncidentReport_IncidentData_ResourceRequestIncident>
15 script_request_incident) {
16 DCHECK(script_request_incident);
17 DCHECK(script_request_incident->has_digest());
18 payload()->set_allocated_resource_request(script_request_incident.release());
21 ResourceRequestIncident::~ResourceRequestIncident() {
24 IncidentType ResourceRequestIncident::GetType() const {
25 return IncidentType::RESOURCE_REQUEST;
28 std::string ResourceRequestIncident::GetKey() const {
29 // Use a static key per resource request type in addition to a fixed digest
30 // below to ensure that only one incident per user (and incident type) is
31 // reported.
32 return payload()->resource_request().type() ==
33 ClientIncidentReport_IncidentData_ResourceRequestIncident::
34 TYPE_SCRIPT
35 ? "script_request_incident"
36 : "domain_request_incident";
39 uint32_t ResourceRequestIncident::ComputeDigest() const {
40 // Return a constant in addition to a fixed key per resource request type
41 // above to ensure that only one incident per user is reported.
42 return 42;
45 } // namespace safe_browsing