OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/prefs/json_pref_store.h" | 5 #include "base/prefs/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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // We keep the old file for possible support and debugging assistance | 123 // We keep the old file for possible support and debugging assistance |
124 // as well as to detect if they're seeing these errors repeatedly. | 124 // as well as to detect if they're seeing these errors repeatedly. |
125 // TODO(erikkay) Instead, use the last known good file. | 125 // TODO(erikkay) Instead, use the last known good file. |
126 base::FilePath bad = path.ReplaceExtension(kBadExtension); | 126 base::FilePath bad = path.ReplaceExtension(kBadExtension); |
127 | 127 |
128 // If they've ever had a parse error before, put them in another bucket. | 128 // If they've ever had a parse error before, put them in another bucket. |
129 // TODO(erikkay) if we keep this error checking for very long, we may | 129 // TODO(erikkay) if we keep this error checking for very long, we may |
130 // want to differentiate between recent and long ago errors. | 130 // want to differentiate between recent and long ago errors. |
131 if (file_util::PathExists(bad)) | 131 if (file_util::PathExists(bad)) |
132 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; | 132 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; |
133 file_util::Move(path, bad); | 133 base::Move(path, bad); |
134 break; | 134 break; |
135 } | 135 } |
136 } else if (!value->IsType(base::Value::TYPE_DICTIONARY)) { | 136 } else if (!value->IsType(base::Value::TYPE_DICTIONARY)) { |
137 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; | 137 *error = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 } // namespace | 141 } // namespace |
142 | 142 |
143 scoped_refptr<base::SequencedTaskRunner> JsonPrefStore::GetTaskRunnerForFile( | 143 scoped_refptr<base::SequencedTaskRunner> JsonPrefStore::GetTaskRunnerForFile( |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 copy->Set(key, new base::ListValue); | 349 copy->Set(key, new base::ListValue); |
350 } else if (value->IsType(base::Value::TYPE_DICTIONARY)) { | 350 } else if (value->IsType(base::Value::TYPE_DICTIONARY)) { |
351 const base::DictionaryValue* dict = NULL; | 351 const base::DictionaryValue* dict = NULL; |
352 if (value->GetAsDictionary(&dict) && dict->empty()) | 352 if (value->GetAsDictionary(&dict) && dict->empty()) |
353 copy->Set(key, new base::DictionaryValue); | 353 copy->Set(key, new base::DictionaryValue); |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 return serializer.Serialize(*(copy.get())); | 357 return serializer.Serialize(*(copy.get())); |
358 } | 358 } |
OLD | NEW |