OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/json_pref_store.h" | 5 #include "chrome/common/json_pref_store.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 FilePath bad = path.ReplaceExtension(kBadExtension); | 122 FilePath bad = path.ReplaceExtension(kBadExtension); |
123 | 123 |
124 // If they've ever had a parse error before, put them in another bucket. | 124 // If they've ever had a parse error before, put them in another bucket. |
125 // TODO(erikkay) if we keep this error checking for very long, we may | 125 // TODO(erikkay) if we keep this error checking for very long, we may |
126 // want to differentiate between recent and long ago errors. | 126 // want to differentiate between recent and long ago errors. |
127 if (file_util::PathExists(bad)) | 127 if (file_util::PathExists(bad)) |
128 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; | 128 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; |
129 file_util::Move(path, bad); | 129 file_util::Move(path, bad); |
130 break; | 130 break; |
131 } | 131 } |
132 } else if (!value->IsType(Value::TYPE_DICTIONARY)) { | 132 } else if (!value->IsDictionary()) { |
133 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; | 133 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 } // namespace | 137 } // namespace |
138 | 138 |
139 JsonPrefStore::JsonPrefStore(const FilePath& filename, | 139 JsonPrefStore::JsonPrefStore(const FilePath& filename, |
140 base::MessageLoopProxy* file_message_loop_proxy) | 140 base::MessageLoopProxy* file_message_loop_proxy) |
141 : path_(filename), | 141 : path_(filename), |
142 file_message_loop_proxy_(file_message_loop_proxy), | 142 file_message_loop_proxy_(file_message_loop_proxy), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 311 } |
312 | 312 |
313 bool JsonPrefStore::SerializeData(std::string* output) { | 313 bool JsonPrefStore::SerializeData(std::string* output) { |
314 // TODO(tc): Do we want to prune webkit preferences that match the default | 314 // TODO(tc): Do we want to prune webkit preferences that match the default |
315 // value? | 315 // value? |
316 JSONStringValueSerializer serializer(output); | 316 JSONStringValueSerializer serializer(output); |
317 serializer.set_pretty_print(true); | 317 serializer.set_pretty_print(true); |
318 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); | 318 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); |
319 return serializer.Serialize(*(copy.get())); | 319 return serializer.Serialize(*(copy.get())); |
320 } | 320 } |
OLD | NEW |