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

Side by Side Diff: chrome/browser/prefs/leveldb_pref_store.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/leveldb_pref_store.h" 5 #include "chrome/browser/prefs/leveldb_pref_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return reading_results.Pass(); 160 return reading_results.Pass();
161 } 161 }
162 162
163 DCHECK(reading_results->error & OPENED); 163 DCHECK(reading_results->error & OPENED);
164 reading_results->value_map.reset(new PrefValueMap); 164 reading_results->value_map.reset(new PrefValueMap);
165 scoped_ptr<leveldb::Iterator> it( 165 scoped_ptr<leveldb::Iterator> it(
166 reading_results->db->NewIterator(leveldb::ReadOptions())); 166 reading_results->db->NewIterator(leveldb::ReadOptions()));
167 // TODO(dgrogan): Is it really necessary to check it->status() each iteration? 167 // TODO(dgrogan): Is it really necessary to check it->status() each iteration?
168 for (it->SeekToFirst(); it->Valid() && it->status().ok(); it->Next()) { 168 for (it->SeekToFirst(); it->Valid() && it->status().ok(); it->Next()) {
169 const std::string value_string = it->value().ToString(); 169 const std::string value_string = it->value().ToString();
170 JSONStringValueSerializer deserializer(value_string); 170 JSONStringValueDeserializer deserializer(value_string);
171 std::string error_message; 171 std::string error_message;
172 int error_code; 172 int error_code;
173 base::Value* json_value = 173 base::Value* json_value =
174 deserializer.Deserialize(&error_code, &error_message); 174 deserializer.Deserialize(&error_code, &error_message);
175 if (json_value) { 175 if (json_value) {
176 reading_results->value_map->SetValue(it->key().ToString(), json_value); 176 reading_results->value_map->SetValue(it->key().ToString(), json_value);
177 } else { 177 } else {
178 DLOG(ERROR) << "Invalid json for key " << it->key().ToString() 178 DLOG(ERROR) << "Invalid json for key " << it->key().ToString()
179 << ": " << error_message; 179 << ": " << error_message;
180 reading_results->error |= DATA_LOST; 180 reading_results->error |= DATA_LOST;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 409 }
410 410
411 // TODO(dgrogan): Call pref_filter_->FilterOnLoad 411 // TODO(dgrogan): Call pref_filter_->FilterOnLoad
412 412
413 if (error_delegate_.get() && read_error_ != PREF_READ_ERROR_NONE) 413 if (error_delegate_.get() && read_error_ != PREF_READ_ERROR_NONE)
414 error_delegate_->OnError(read_error_); 414 error_delegate_->OnError(read_error_);
415 415
416 FOR_EACH_OBSERVER( 416 FOR_EACH_OBSERVER(
417 PrefStore::Observer, observers_, OnInitializationCompleted(true)); 417 PrefStore::Observer, observers_, OnInitializationCompleted(true));
418 } 418 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/user_script_listener_unittest.cc ('k') | chrome/browser/prefs/pref_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698