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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 // static | 90 // static |
91 void FileThreadDeserializer::HandleErrors( | 91 void FileThreadDeserializer::HandleErrors( |
92 const Value* value, | 92 const Value* value, |
93 const FilePath& path, | 93 const FilePath& path, |
94 int error_code, | 94 int error_code, |
95 const std::string& error_msg, | 95 const std::string& error_msg, |
96 PersistentPrefStore::PrefReadError* error) { | 96 PersistentPrefStore::PrefReadError* error) { |
97 *error = PersistentPrefStore::PREF_READ_ERROR_NONE; | 97 *error = PersistentPrefStore::PREF_READ_ERROR_NONE; |
98 if (!value) { | 98 if (!value) { |
99 VLOG(1) << "Error while loading JSON file: " << error_msg; | 99 DVLOG(1) << "Error while loading JSON file: " << error_msg; |
100 switch (error_code) { | 100 switch (error_code) { |
101 case JSONFileValueSerializer::JSON_ACCESS_DENIED: | 101 case JSONFileValueSerializer::JSON_ACCESS_DENIED: |
102 *error = PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; | 102 *error = PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; |
103 break; | 103 break; |
104 case JSONFileValueSerializer::JSON_CANNOT_READ_FILE: | 104 case JSONFileValueSerializer::JSON_CANNOT_READ_FILE: |
105 *error = PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; | 105 *error = PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; |
106 break; | 106 break; |
107 case JSONFileValueSerializer::JSON_FILE_LOCKED: | 107 case JSONFileValueSerializer::JSON_FILE_LOCKED: |
108 *error = PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; | 108 *error = PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; |
109 break; | 109 break; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 bool JsonPrefStore::SerializeData(std::string* output) { | 316 bool JsonPrefStore::SerializeData(std::string* output) { |
317 // TODO(tc): Do we want to prune webkit preferences that match the default | 317 // TODO(tc): Do we want to prune webkit preferences that match the default |
318 // value? | 318 // value? |
319 JSONStringValueSerializer serializer(output); | 319 JSONStringValueSerializer serializer(output); |
320 serializer.set_pretty_print(true); | 320 serializer.set_pretty_print(true); |
321 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); | 321 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); |
322 return serializer.Serialize(*(copy.get())); | 322 return serializer.Serialize(*(copy.get())); |
323 } | 323 } |
OLD | NEW |