| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 |
| 14 namespace safe_browsing { |
| 15 |
| 16 class ClientIncidentReport_IncidentData; |
| 17 |
| 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 |
| 20 // existing values. |
| 21 enum class IncidentType : int32_t { |
| 22 // Start with 1 rather than zero; otherwise there won't be enough buckets for |
| 23 // the histogram. |
| 24 TRACKED_PREFERENCE = 1, |
| 25 BINARY_INTEGRITY = 2, |
| 26 BLACKLIST_LOAD = 3, |
| 27 OMNIBOX_INTERACTION = 4, |
| 28 VARIATIONS_SEED_SIGNATURE = 5, |
| 29 // Values for new incident types go here. |
| 30 NUM_TYPES = 6 |
| 31 }; |
| 32 |
| 33 // An abstract incident. Subclasses provide type-specific functionality to |
| 34 // enable logging and pruning by the incident reporting service. |
| 35 class Incident { |
| 36 public: |
| 37 virtual ~Incident(); |
| 38 |
| 39 // Returns the type of the incident. |
| 40 virtual IncidentType GetType() const = 0; |
| 41 |
| 42 // Returns a key that identifies a particular instance among the type's |
| 43 // possibilities. |
| 44 virtual std::string GetKey() const = 0; |
| 45 |
| 46 // Returns a computed fingerprint of the payload. Incidents of the same |
| 47 // incident must result in the same digest. |
| 48 virtual uint32_t ComputeDigest() const = 0; |
| 49 |
| 50 // Returns the incident's payload. |
| 51 virtual scoped_ptr<ClientIncidentReport_IncidentData> TakePayload(); |
| 52 |
| 53 protected: |
| 54 // Constructs the payload with an empty protobuf, setting its incident time to |
| 55 // the current time. |
| 56 Incident(); |
| 57 |
| 58 // Accessors for the payload. These must not be called after the payload has |
| 59 // been taken. |
| 60 ClientIncidentReport_IncidentData* payload(); |
| 61 const ClientIncidentReport_IncidentData* payload() const; |
| 62 |
| 63 private: |
| 64 scoped_ptr<ClientIncidentReport_IncidentData> payload_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(Incident); |
| 67 }; |
| 68 |
| 69 } // namespace safe_browsing |
| 70 |
| 71 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ |
| OLD | NEW |