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/state_store.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/state_store.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
8 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 12 #include "base/values.h" |
11 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" | 14 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" |
13 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h
" | 15 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h
" |
14 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
15 | 17 |
16 namespace safe_browsing { | 18 namespace safe_browsing { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 132 |
131 InitializationResult state_store_init_result = PSS_MATCHES; | 133 InitializationResult state_store_init_result = PSS_MATCHES; |
132 if (!value_dict) { | 134 if (!value_dict) { |
133 state_store_init_result = PSS_NULL; | 135 state_store_init_result = PSS_NULL; |
134 } else if (value_dict->empty()) { | 136 } else if (value_dict->empty()) { |
135 if (incidents_sent_ && !incidents_sent_->empty()) | 137 if (incidents_sent_ && !incidents_sent_->empty()) |
136 state_store_init_result = PSS_EMPTY; | 138 state_store_init_result = PSS_EMPTY; |
137 transaction.ClearAll(); | 139 transaction.ClearAll(); |
138 } else if (!incidents_sent_ || !incidents_sent_->Equals(value_dict.get())) { | 140 } else if (!incidents_sent_ || !incidents_sent_->Equals(value_dict.get())) { |
139 state_store_init_result = PSS_DIFFERS; | 141 state_store_init_result = PSS_DIFFERS; |
140 transaction.ReplacePrefDict(value_dict.Pass()); | 142 transaction.ReplacePrefDict(std::move(value_dict)); |
141 } | 143 } |
142 UMA_HISTOGRAM_ENUMERATION("SBIRS.StateStoreInit", state_store_init_result, | 144 UMA_HISTOGRAM_ENUMERATION("SBIRS.StateStoreInit", state_store_init_result, |
143 NUM_INITIALIZATION_RESULTS); | 145 NUM_INITIALIZATION_RESULTS); |
144 if (incidents_sent_) | 146 if (incidents_sent_) |
145 CleanLegacyValues(&transaction); | 147 CleanLegacyValues(&transaction); |
146 } | 148 } |
147 | 149 |
148 StateStore::~StateStore() { | 150 StateStore::~StateStore() { |
149 #if DCHECK_IS_ON() | 151 #if DCHECK_IS_ON() |
150 DCHECK(!has_transaction_); | 152 DCHECK(!has_transaction_); |
(...skipping 16 matching lines...) Expand all Loading... |
167 static const IncidentType kLegacyTypes[] = { | 169 static const IncidentType kLegacyTypes[] = { |
168 // TODO(grt): remove in M44 (crbug.com/451173). | 170 // TODO(grt): remove in M44 (crbug.com/451173). |
169 IncidentType::OMNIBOX_INTERACTION, | 171 IncidentType::OMNIBOX_INTERACTION, |
170 }; | 172 }; |
171 | 173 |
172 for (IncidentType type : kLegacyTypes) | 174 for (IncidentType type : kLegacyTypes) |
173 transaction->ClearForType(type); | 175 transaction->ClearForType(type); |
174 } | 176 } |
175 | 177 |
176 } // namespace safe_browsing | 178 } // namespace safe_browsing |
OLD | NEW |