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 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
14 namespace safe_browsing
{
16 class ClientIncidentReport_IncidentData
;
18 // An incident's type. Values from this enum are used for histograms (hence the
19 // making underlying type the same as histogram samples.). Do not re-use
21 enum class IncidentType
: int32_t {
22 // Start with 1 rather than zero; otherwise there won't be enough buckets for
24 TRACKED_PREFERENCE
= 1,
27 OMNIBOX_INTERACTION
= 4,
28 VARIATIONS_SEED_SIGNATURE
= 5,
30 // Values for new incident types go here.
34 // An abstract incident. Subclasses provide type-specific functionality to
35 // enable logging and pruning by the incident reporting service.
40 // Returns the type of the incident.
41 virtual IncidentType
GetType() const = 0;
43 // Returns a key that identifies a particular instance among the type's
45 virtual std::string
GetKey() const = 0;
47 // Returns a computed fingerprint of the payload. Incidents of the same
48 // incident must result in the same digest.
49 virtual uint32_t ComputeDigest() const = 0;
51 // Returns the incident's payload.
52 virtual scoped_ptr
<ClientIncidentReport_IncidentData
> TakePayload();
55 // Constructs the payload with an empty protobuf, setting its incident time to
59 // Accessors for the payload. These must not be called after the payload has
61 ClientIncidentReport_IncidentData
* payload();
62 const ClientIncidentReport_IncidentData
* payload() const;
65 scoped_ptr
<ClientIncidentReport_IncidentData
> payload_
;
67 DISALLOW_COPY_AND_ASSIGN(Incident
);
70 } // namespace safe_browsing
72 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_