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

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

Issue 2845113002: Remove raw base::DictionaryValue::SetWithoutPathExpansion in //chrome (Closed)
Patch Set: Created 3 years, 7 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/state_store.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/state_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" 14 #include "chrome/browser/safe_browsing/incident_reporting/incident.h"
14 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h " 15 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h "
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
17 18
18 namespace safe_browsing { 19 namespace safe_browsing {
(...skipping 16 matching lines...) Expand all
35 } 36 }
36 37
37 void StateStore::Transaction::MarkAsReported(IncidentType type, 38 void StateStore::Transaction::MarkAsReported(IncidentType type,
38 const std::string& key, 39 const std::string& key,
39 IncidentDigest digest) { 40 IncidentDigest digest) {
40 std::string type_string(base::IntToString(static_cast<int32_t>(type))); 41 std::string type_string(base::IntToString(static_cast<int32_t>(type)));
41 base::DictionaryValue* incidents_sent = GetPrefDict(); 42 base::DictionaryValue* incidents_sent = GetPrefDict();
42 base::DictionaryValue* type_dict = nullptr; 43 base::DictionaryValue* type_dict = nullptr;
43 if (!incidents_sent->GetDictionaryWithoutPathExpansion(type_string, 44 if (!incidents_sent->GetDictionaryWithoutPathExpansion(type_string,
44 &type_dict)) { 45 &type_dict)) {
45 type_dict = new base::DictionaryValue(); 46 incidents_sent->SetWithoutPathExpansion(
46 incidents_sent->SetWithoutPathExpansion(type_string, type_dict); 47 type_string, base::MakeUnique<base::DictionaryValue>());
48 incidents_sent->GetDictionaryWithoutPathExpansion(type_string, &type_dict);
47 } 49 }
48 type_dict->SetStringWithoutPathExpansion(key, base::UintToString(digest)); 50 type_dict->SetStringWithoutPathExpansion(key, base::UintToString(digest));
49 } 51 }
50 52
51 void StateStore::Transaction::Clear(IncidentType type, const std::string& key) { 53 void StateStore::Transaction::Clear(IncidentType type, const std::string& key) {
52 // Nothing to do if the pref dict does not exist. 54 // Nothing to do if the pref dict does not exist.
53 if (!store_->incidents_sent_) 55 if (!store_->incidents_sent_)
54 return; 56 return;
55 57
56 // Use the read-only view on the preference to figure out if there is a value 58 // Use the read-only view on the preference to figure out if there is a value
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 static const IncidentType kLegacyTypes[] = { 171 static const IncidentType kLegacyTypes[] = {
170 // TODO(grt): remove in M44 (crbug.com/451173). 172 // TODO(grt): remove in M44 (crbug.com/451173).
171 IncidentType::OMNIBOX_INTERACTION, 173 IncidentType::OMNIBOX_INTERACTION,
172 }; 174 };
173 175
174 for (IncidentType type : kLegacyTypes) 176 for (IncidentType type : kLegacyTypes)
175 transaction->ClearForType(type); 177 transaction->ClearForType(type);
176 } 178 }
177 179
178 } // namespace safe_browsing 180 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698