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

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

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments Created 4 years, 8 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
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/tracked_preference_inc ident.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_inc ident.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 TrackedPreferenceIncident::TrackedPreferenceIncident( 13 TrackedPreferenceIncident::TrackedPreferenceIncident(
14 scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident> 14 std::unique_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
15 tracked_preference_incident, 15 tracked_preference_incident,
16 bool is_personal) 16 bool is_personal)
17 : is_personal_(is_personal) { 17 : is_personal_(is_personal) {
18 DCHECK(tracked_preference_incident); 18 DCHECK(tracked_preference_incident);
19 DCHECK(tracked_preference_incident->has_path()); 19 DCHECK(tracked_preference_incident->has_path());
20 payload()->set_allocated_tracked_preference( 20 payload()->set_allocated_tracked_preference(
21 tracked_preference_incident.release()); 21 tracked_preference_incident.release());
22 } 22 }
23 23
24 TrackedPreferenceIncident::~TrackedPreferenceIncident() { 24 TrackedPreferenceIncident::~TrackedPreferenceIncident() {
25 } 25 }
26 26
27 IncidentType TrackedPreferenceIncident::GetType() const { 27 IncidentType TrackedPreferenceIncident::GetType() const {
28 return IncidentType::TRACKED_PREFERENCE; 28 return IncidentType::TRACKED_PREFERENCE;
29 } 29 }
30 30
31 // Returns the preference path. 31 // Returns the preference path.
32 std::string TrackedPreferenceIncident::GetKey() const { 32 std::string TrackedPreferenceIncident::GetKey() const {
33 return payload()->tracked_preference().path(); 33 return payload()->tracked_preference().path();
34 } 34 }
35 35
36 // Returns a digest computed over the payload. 36 // Returns a digest computed over the payload.
37 uint32_t TrackedPreferenceIncident::ComputeDigest() const { 37 uint32_t TrackedPreferenceIncident::ComputeDigest() const {
38 // Tracked preference incidents are sufficiently canonical (and have no 38 // Tracked preference incidents are sufficiently canonical (and have no
39 // default values), so it's safe to serialize the incident as given. 39 // default values), so it's safe to serialize the incident as given.
40 return HashMessage(payload()->tracked_preference()); 40 return HashMessage(payload()->tracked_preference());
41 } 41 }
42 42
43 // Filter out personal preferences. 43 // Filter out personal preferences.
44 scoped_ptr<ClientIncidentReport_IncidentData> 44 std::unique_ptr<ClientIncidentReport_IncidentData>
45 TrackedPreferenceIncident::TakePayload() { 45 TrackedPreferenceIncident::TakePayload() {
46 scoped_ptr<ClientIncidentReport_IncidentData> payload( 46 std::unique_ptr<ClientIncidentReport_IncidentData> payload(
47 Incident::TakePayload()); 47 Incident::TakePayload());
48 48
49 if (is_personal_) { 49 if (is_personal_) {
50 ClientIncidentReport_IncidentData_TrackedPreferenceIncident* incident = 50 ClientIncidentReport_IncidentData_TrackedPreferenceIncident* incident =
51 payload->mutable_tracked_preference(); 51 payload->mutable_tracked_preference();
52 incident->clear_atomic_value(); 52 incident->clear_atomic_value();
53 incident->clear_split_key(); 53 incident->clear_split_key();
54 } 54 }
55 55
56 return payload; 56 return payload;
57 } 57 }
58 58
59 } // namespace safe_browsing 59 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698