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

Side by Side Diff: chrome/common/json_pref_store.cc

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/extension_unpacker.cc ('k') | chrome/common/json_schema_validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_unpacker.cc ('k') | chrome/common/json_schema_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698