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

Side by Side Diff: chrome/browser/prefs/tracked/pref_hash_calculator.cc

Issue 1150863002: Make DictionaryValue::DeepCopyWithoutEmptyChildren return a scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove semicolons Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/prefs/tracked/pref_hash_calculator.h" 5 #include "chrome/browser/prefs/tracked/pref_hash_calculator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Renders |value| as a string. |value| may be NULL, in which case the result 45 // Renders |value| as a string. |value| may be NULL, in which case the result
46 // is an empty string. This method can be expensive and its result should be 46 // is an empty string. This method can be expensive and its result should be
47 // re-used rather than recomputed where possible. 47 // re-used rather than recomputed where possible.
48 std::string ValueAsString(const base::Value* value) { 48 std::string ValueAsString(const base::Value* value) {
49 // Dictionary values may contain empty lists and sub-dictionaries. Make a 49 // Dictionary values may contain empty lists and sub-dictionaries. Make a
50 // deep copy with those removed to make the hash more stable. 50 // deep copy with those removed to make the hash more stable.
51 const base::DictionaryValue* dict_value; 51 const base::DictionaryValue* dict_value;
52 scoped_ptr<base::DictionaryValue> canonical_dict_value; 52 scoped_ptr<base::DictionaryValue> canonical_dict_value;
53 if (value && value->GetAsDictionary(&dict_value)) { 53 if (value && value->GetAsDictionary(&dict_value)) {
54 canonical_dict_value.reset(dict_value->DeepCopyWithoutEmptyChildren()); 54 canonical_dict_value = dict_value->DeepCopyWithoutEmptyChildren();
55 value = canonical_dict_value.get(); 55 value = canonical_dict_value.get();
56 } 56 }
57 57
58 std::string value_as_string; 58 std::string value_as_string;
59 if (value) { 59 if (value) {
60 JSONStringValueSerializer serializer(&value_as_string); 60 JSONStringValueSerializer serializer(&value_as_string);
61 serializer.Serialize(*value); 61 serializer.Serialize(*value);
62 } 62 }
63 63
64 return value_as_string; 64 return value_as_string;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 digest_string)) { 115 digest_string)) {
116 return VALID; 116 return VALID;
117 } 117 }
118 if (VerifyDigestString(seed_, 118 if (VerifyDigestString(seed_,
119 GetMessage(legacy_device_id_, path, value_as_string), 119 GetMessage(legacy_device_id_, path, value_as_string),
120 digest_string)) { 120 digest_string)) {
121 return VALID_SECURE_LEGACY; 121 return VALID_SECURE_LEGACY;
122 } 122 }
123 return INVALID; 123 return INVALID;
124 } 124 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/echo_private_api.cc ('k') | chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698