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

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

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 // This file implements the platform-neutral Load() and Store() functions for a 5 // This file implements the platform-neutral Load() and Store() functions for a
6 // profile's safebrowsing.incidents_sent preference dictionary. The preference 6 // profile's safebrowsing.incidents_sent preference dictionary. The preference
7 // dict is converted to a protocol buffer message which is then serialized into 7 // dict is converted to a protocol buffer message which is then serialized into
8 // a byte array. This serialized data is written to or read from some 8 // a byte array. This serialized data is written to or read from some
9 // platform-specific storage via {Read,Write}StoreData implemented elsewhere. 9 // platform-specific storage via {Read,Write}StoreData implemented elsewhere.
10 // 10 //
(...skipping 28 matching lines...) Expand all
39 // Copies the (key, digest) pairs from |keys_and_digests| (a dict of string 39 // Copies the (key, digest) pairs from |keys_and_digests| (a dict of string
40 // values) to the |key_digest_pairs| protobuf. 40 // values) to the |key_digest_pairs| protobuf.
41 void KeysAndDigestsToProtobuf( 41 void KeysAndDigestsToProtobuf(
42 const base::DictionaryValue& keys_and_digests, 42 const base::DictionaryValue& keys_and_digests,
43 RepeatedPtrField<StateStoreData::Incidents::KeyDigestMapFieldEntry>* 43 RepeatedPtrField<StateStoreData::Incidents::KeyDigestMapFieldEntry>*
44 key_digest_pairs) { 44 key_digest_pairs) {
45 std::string digest_value; 45 std::string digest_value;
46 for (base::DictionaryValue::Iterator iter(keys_and_digests); !iter.IsAtEnd(); 46 for (base::DictionaryValue::Iterator iter(keys_and_digests); !iter.IsAtEnd();
47 iter.Advance()) { 47 iter.Advance()) {
48 uint32_t digest = 0; 48 uint32_t digest = 0;
49 if (iter.value().GetType() != base::Value::TYPE_STRING || 49 if (iter.value().GetType() != base::Value::Type::STRING ||
50 !iter.value().GetAsString(&digest_value) || 50 !iter.value().GetAsString(&digest_value) ||
51 !base::StringToUint(digest_value, &digest)) { 51 !base::StringToUint(digest_value, &digest)) {
52 NOTREACHED(); 52 NOTREACHED();
53 continue; 53 continue;
54 } 54 }
55 StateStoreData::Incidents::KeyDigestMapFieldEntry* key_digest = 55 StateStoreData::Incidents::KeyDigestMapFieldEntry* key_digest =
56 key_digest_pairs->Add(); 56 key_digest_pairs->Add();
57 key_digest->set_key(iter.key()); 57 key_digest->set_key(iter.key());
58 key_digest->set_digest(digest); 58 key_digest->set_digest(digest);
59 } 59 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return PlatformStateStoreLoadResult::PARSE_ERROR; 193 return PlatformStateStoreLoadResult::PARSE_ERROR;
194 value_dict->Clear(); 194 value_dict->Clear();
195 RestoreFromProtobuf(store_data.type_to_incidents(), value_dict); 195 RestoreFromProtobuf(store_data.type_to_incidents(), value_dict);
196 return PlatformStateStoreLoadResult::SUCCESS; 196 return PlatformStateStoreLoadResult::SUCCESS;
197 } 197 }
198 198
199 #endif // USE_PLATFORM_STATE_STORE 199 #endif // USE_PLATFORM_STATE_STORE
200 200
201 } // namespace platform_state_store 201 } // namespace platform_state_store
202 } // namespace safe_browsing 202 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698