blob: e35ed295d699b68ffe50d707d1864b8dcc046125 [file] [log] [blame]
[email protected]d3b05ea2012-01-24 22:57:051// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]277404c22010-04-22 13:09:452// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]03b9b4e2012-10-22 20:01:525#include "base/prefs/json_pref_store.h"
[email protected]277404c22010-04-22 13:09:456
7#include <algorithm>
8
[email protected]844a1002011-04-19 11:37:219#include "base/bind.h"
10#include "base/callback.h"
[email protected]ac771fb362014-07-16 06:04:4411#include "base/files/file_path.h"
[email protected]e3177dd52014-08-13 20:22:1412#include "base/files/file_util.h"
[email protected]ffbec692012-02-26 20:26:4213#include "base/json/json_file_value_serializer.h"
14#include "base/json/json_string_value_serializer.h"
[email protected]844a1002011-04-19 11:37:2115#include "base/memory/ref_counted.h"
[email protected]ac771fb362014-07-16 06:04:4416#include "base/metrics/histogram.h"
[email protected]56cbcb3a2013-12-23 21:24:4617#include "base/prefs/pref_filter.h"
[email protected]fb441962013-05-08 05:35:2418#include "base/sequenced_task_runner.h"
[email protected]ac771fb362014-07-16 06:04:4419#include "base/strings/string_util.h"
[email protected]f2456592014-07-22 19:30:1720#include "base/task_runner_util.h"
[email protected]0de615a2012-11-08 04:40:5921#include "base/threading/sequenced_worker_pool.h"
[email protected]277404c22010-04-22 13:09:4522#include "base/values.h"
[email protected]277404c22010-04-22 13:09:4523
[email protected]f2456592014-07-22 19:30:1724// Result returned from internal read tasks.
25struct JsonPrefStore::ReadResult {
26 public:
27 ReadResult();
28 ~ReadResult();
29
30 scoped_ptr<base::Value> value;
31 PrefReadError error;
32 bool no_dir;
33
34 private:
35 DISALLOW_COPY_AND_ASSIGN(ReadResult);
36};
37
38JsonPrefStore::ReadResult::ReadResult()
39 : error(PersistentPrefStore::PREF_READ_ERROR_NONE), no_dir(false) {
40}
41
42JsonPrefStore::ReadResult::~ReadResult() {
43}
44
[email protected]277404c22010-04-22 13:09:4545namespace {
46
47// Some extensions we'll tack on to copies of the Preferences files.
[email protected]f2456592014-07-22 19:30:1748const base::FilePath::CharType kBadExtension[] = FILE_PATH_LITERAL("bad");
[email protected]277404c22010-04-22 13:09:4549
[email protected]f2456592014-07-22 19:30:1750PersistentPrefStore::PrefReadError HandleReadErrors(
[email protected]a43a667b2013-06-14 17:56:0851 const base::Value* value,
[email protected]023ad6ab2013-02-17 05:07:2352 const base::FilePath& path,
[email protected]844a1002011-04-19 11:37:2153 int error_code,
[email protected]f2456592014-07-22 19:30:1754 const std::string& error_msg) {
[email protected]844a1002011-04-19 11:37:2155 if (!value) {
[email protected]0de615a2012-11-08 04:40:5956 DVLOG(1) << "Error while loading JSON file: " << error_msg
57 << ", file: " << path.value();
[email protected]844a1002011-04-19 11:37:2158 switch (error_code) {
59 case JSONFileValueSerializer::JSON_ACCESS_DENIED:
[email protected]f2456592014-07-22 19:30:1760 return PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED;
[email protected]844a1002011-04-19 11:37:2161 break;
62 case JSONFileValueSerializer::JSON_CANNOT_READ_FILE:
[email protected]f2456592014-07-22 19:30:1763 return PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER;
[email protected]844a1002011-04-19 11:37:2164 break;
65 case JSONFileValueSerializer::JSON_FILE_LOCKED:
[email protected]f2456592014-07-22 19:30:1766 return PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED;
[email protected]844a1002011-04-19 11:37:2167 break;
68 case JSONFileValueSerializer::JSON_NO_SUCH_FILE:
[email protected]f2456592014-07-22 19:30:1769 return PersistentPrefStore::PREF_READ_ERROR_NO_FILE;
[email protected]844a1002011-04-19 11:37:2170 break;
71 default:
[email protected]844a1002011-04-19 11:37:2172 // JSON errors indicate file corruption of some sort.
73 // Since the file is corrupt, move it to the side and continue with
74 // empty preferences. This will result in them losing their settings.
75 // We keep the old file for possible support and debugging assistance
76 // as well as to detect if they're seeing these errors repeatedly.
77 // TODO(erikkay) Instead, use the last known good file.
[email protected]023ad6ab2013-02-17 05:07:2378 base::FilePath bad = path.ReplaceExtension(kBadExtension);
[email protected]844a1002011-04-19 11:37:2179
80 // If they've ever had a parse error before, put them in another bucket.
81 // TODO(erikkay) if we keep this error checking for very long, we may
82 // want to differentiate between recent and long ago errors.
[email protected]f2456592014-07-22 19:30:1783 bool bad_existed = base::PathExists(bad);
[email protected]5553d5b2013-07-01 23:07:3684 base::Move(path, bad);
[email protected]f2456592014-07-22 19:30:1785 return bad_existed ? PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT
86 : PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE;
[email protected]844a1002011-04-19 11:37:2187 }
[email protected]a43a667b2013-06-14 17:56:0888 } else if (!value->IsType(base::Value::TYPE_DICTIONARY)) {
[email protected]f2456592014-07-22 19:30:1789 return PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE;
[email protected]844a1002011-04-19 11:37:2190 }
[email protected]f2456592014-07-22 19:30:1791 return PersistentPrefStore::PREF_READ_ERROR_NONE;
92}
93
94scoped_ptr<JsonPrefStore::ReadResult> ReadPrefsFromDisk(
95 const base::FilePath& path,
96 const base::FilePath& alternate_path) {
97 if (!base::PathExists(path) && !alternate_path.empty() &&
98 base::PathExists(alternate_path)) {
99 base::Move(alternate_path, path);
100 }
101
102 int error_code;
103 std::string error_msg;
104 scoped_ptr<JsonPrefStore::ReadResult> read_result(
105 new JsonPrefStore::ReadResult);
106 JSONFileValueSerializer serializer(path);
107 read_result->value.reset(serializer.Deserialize(&error_code, &error_msg));
108 read_result->error =
109 HandleReadErrors(read_result->value.get(), path, error_code, error_msg);
110 read_result->no_dir = !base::PathExists(path.DirName());
111 return read_result.Pass();
[email protected]844a1002011-04-19 11:37:21112}
113
[email protected]277404c22010-04-22 13:09:45114} // namespace
115
[email protected]f2456592014-07-22 19:30:17116// static
[email protected]0de615a2012-11-08 04:40:59117scoped_refptr<base::SequencedTaskRunner> JsonPrefStore::GetTaskRunnerForFile(
[email protected]023ad6ab2013-02-17 05:07:23118 const base::FilePath& filename,
[email protected]0de615a2012-11-08 04:40:59119 base::SequencedWorkerPool* worker_pool) {
120 std::string token("json_pref_store-");
121 token.append(filename.AsUTF8Unsafe());
122 return worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
123 worker_pool->GetNamedSequenceToken(token),
124 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
125}
126
dcheng077d1b22014-08-28 18:47:38127JsonPrefStore::JsonPrefStore(
128 const base::FilePath& filename,
129 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner,
130 scoped_ptr<PrefFilter> pref_filter)
[email protected]277404c22010-04-22 13:09:45131 : path_(filename),
[email protected]0de615a2012-11-08 04:40:59132 sequenced_task_runner_(sequenced_task_runner),
[email protected]a43a667b2013-06-14 17:56:08133 prefs_(new base::DictionaryValue()),
[email protected]277404c22010-04-22 13:09:45134 read_only_(false),
[email protected]0de615a2012-11-08 04:40:59135 writer_(filename, sequenced_task_runner),
[email protected]56cbcb3a2013-12-23 21:24:46136 pref_filter_(pref_filter.Pass()),
[email protected]59c10712012-03-13 02:10:34137 initialized_(false),
[email protected]e33c9512014-05-12 02:24:13138 filtering_in_progress_(false),
139 read_error_(PREF_READ_ERROR_NONE) {
bratell970f39d2015-01-07 16:40:58140 DCHECK(!path_.empty());
[email protected]e33c9512014-05-12 02:24:13141}
[email protected]277404c22010-04-22 13:09:45142
dcheng077d1b22014-08-28 18:47:38143JsonPrefStore::JsonPrefStore(
144 const base::FilePath& filename,
145 const base::FilePath& alternate_filename,
146 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner,
147 scoped_ptr<PrefFilter> pref_filter)
[email protected]cfcf0e52014-06-20 18:29:47148 : path_(filename),
149 alternate_path_(alternate_filename),
150 sequenced_task_runner_(sequenced_task_runner),
151 prefs_(new base::DictionaryValue()),
152 read_only_(false),
153 writer_(filename, sequenced_task_runner),
154 pref_filter_(pref_filter.Pass()),
155 initialized_(false),
156 filtering_in_progress_(false),
157 read_error_(PREF_READ_ERROR_NONE) {
bratell970f39d2015-01-07 16:40:58158 DCHECK(!path_.empty());
[email protected]cfcf0e52014-06-20 18:29:47159}
160
[email protected]892f1d62012-11-08 18:24:34161bool JsonPrefStore::GetValue(const std::string& key,
[email protected]a43a667b2013-06-14 17:56:08162 const base::Value** result) const {
[email protected]f2456592014-07-22 19:30:17163 DCHECK(CalledOnValidThread());
164
[email protected]a43a667b2013-06-14 17:56:08165 base::Value* tmp = NULL;
[email protected]892f1d62012-11-08 18:24:34166 if (!prefs_->Get(key, &tmp))
167 return false;
168
169 if (result)
170 *result = tmp;
171 return true;
[email protected]f2d1f612010-12-09 15:10:17172}
173
174void JsonPrefStore::AddObserver(PrefStore::Observer* observer) {
[email protected]f2456592014-07-22 19:30:17175 DCHECK(CalledOnValidThread());
176
[email protected]f2d1f612010-12-09 15:10:17177 observers_.AddObserver(observer);
178}
179
180void JsonPrefStore::RemoveObserver(PrefStore::Observer* observer) {
[email protected]f2456592014-07-22 19:30:17181 DCHECK(CalledOnValidThread());
182
[email protected]f2d1f612010-12-09 15:10:17183 observers_.RemoveObserver(observer);
184}
185
[email protected]14e0ec62013-08-26 22:01:39186bool JsonPrefStore::HasObservers() const {
[email protected]f2456592014-07-22 19:30:17187 DCHECK(CalledOnValidThread());
188
[email protected]14e0ec62013-08-26 22:01:39189 return observers_.might_have_observers();
[email protected]d3b05ea2012-01-24 22:57:05190}
191
[email protected]845b43a82011-05-11 10:14:43192bool JsonPrefStore::IsInitializationComplete() const {
[email protected]f2456592014-07-22 19:30:17193 DCHECK(CalledOnValidThread());
194
[email protected]845b43a82011-05-11 10:14:43195 return initialized_;
196}
197
[email protected]892f1d62012-11-08 18:24:34198bool JsonPrefStore::GetMutableValue(const std::string& key,
[email protected]a43a667b2013-06-14 17:56:08199 base::Value** result) {
[email protected]f2456592014-07-22 19:30:17200 DCHECK(CalledOnValidThread());
201
[email protected]892f1d62012-11-08 18:24:34202 return prefs_->Get(key, result);
[email protected]68bf41a2011-03-25 16:38:31203}
204
[email protected]a43a667b2013-06-14 17:56:08205void JsonPrefStore::SetValue(const std::string& key, base::Value* value) {
[email protected]f2456592014-07-22 19:30:17206 DCHECK(CalledOnValidThread());
207
[email protected]9b5f56b42011-08-24 21:17:59208 DCHECK(value);
[email protected]a43a667b2013-06-14 17:56:08209 scoped_ptr<base::Value> new_value(value);
210 base::Value* old_value = NULL;
[email protected]9b5f56b42011-08-24 21:17:59211 prefs_->Get(key, &old_value);
212 if (!old_value || !value->Equals(old_value)) {
213 prefs_->Set(key, new_value.release());
[email protected]25308672011-10-10 17:22:50214 ReportValueChanged(key);
[email protected]9b5f56b42011-08-24 21:17:59215 }
[email protected]f2d1f612010-12-09 15:10:17216}
217
[email protected]a43a667b2013-06-14 17:56:08218void JsonPrefStore::SetValueSilently(const std::string& key,
219 base::Value* value) {
[email protected]f2456592014-07-22 19:30:17220 DCHECK(CalledOnValidThread());
221
[email protected]9b5f56b42011-08-24 21:17:59222 DCHECK(value);
[email protected]a43a667b2013-06-14 17:56:08223 scoped_ptr<base::Value> new_value(value);
224 base::Value* old_value = NULL;
[email protected]9b5f56b42011-08-24 21:17:59225 prefs_->Get(key, &old_value);
[email protected]25308672011-10-10 17:22:50226 if (!old_value || !value->Equals(old_value)) {
[email protected]9b5f56b42011-08-24 21:17:59227 prefs_->Set(key, new_value.release());
[email protected]25308672011-10-10 17:22:50228 if (!read_only_)
229 writer_.ScheduleWrite(this);
230 }
[email protected]f2d1f612010-12-09 15:10:17231}
232
233void JsonPrefStore::RemoveValue(const std::string& key) {
[email protected]f2456592014-07-22 19:30:17234 DCHECK(CalledOnValidThread());
235
[email protected]aa3283392013-11-27 01:38:24236 if (prefs_->RemovePath(key, NULL))
[email protected]25308672011-10-10 17:22:50237 ReportValueChanged(key);
[email protected]f2d1f612010-12-09 15:10:17238}
239
[email protected]e33c9512014-05-12 02:24:13240void JsonPrefStore::RemoveValueSilently(const std::string& key) {
[email protected]f2456592014-07-22 19:30:17241 DCHECK(CalledOnValidThread());
242
[email protected]e33c9512014-05-12 02:24:13243 prefs_->RemovePath(key, NULL);
244 if (!read_only_)
245 writer_.ScheduleWrite(this);
246}
247
[email protected]ddb1e5a2010-12-13 20:10:45248bool JsonPrefStore::ReadOnly() const {
[email protected]f2456592014-07-22 19:30:17249 DCHECK(CalledOnValidThread());
250
[email protected]ddb1e5a2010-12-13 20:10:45251 return read_only_;
252}
253
[email protected]59c10712012-03-13 02:10:34254PersistentPrefStore::PrefReadError JsonPrefStore::GetReadError() const {
[email protected]f2456592014-07-22 19:30:17255 DCHECK(CalledOnValidThread());
256
[email protected]59c10712012-03-13 02:10:34257 return read_error_;
258}
259
[email protected]7b2720b2012-04-25 16:59:11260PersistentPrefStore::PrefReadError JsonPrefStore::ReadPrefs() {
[email protected]f2456592014-07-22 19:30:17261 DCHECK(CalledOnValidThread());
262
[email protected]f2456592014-07-22 19:30:17263 OnFileRead(ReadPrefsFromDisk(path_, alternate_path_));
264 return filtering_in_progress_ ? PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE
265 : read_error_;
[email protected]7b2720b2012-04-25 16:59:11266}
267
[email protected]e33c9512014-05-12 02:24:13268void JsonPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate) {
[email protected]f2456592014-07-22 19:30:17269 DCHECK(CalledOnValidThread());
270
[email protected]7b2720b2012-04-25 16:59:11271 initialized_ = false;
272 error_delegate_.reset(error_delegate);
[email protected]7b2720b2012-04-25 16:59:11273
[email protected]3b268bc2014-07-28 17:43:15274 // Weakly binds the read task so that it doesn't kick in during shutdown.
[email protected]f2456592014-07-22 19:30:17275 base::PostTaskAndReplyWithResult(
dchengd81e7d72014-08-27 00:23:23276 sequenced_task_runner_.get(),
[email protected]f2456592014-07-22 19:30:17277 FROM_HERE,
278 base::Bind(&ReadPrefsFromDisk, path_, alternate_path_),
[email protected]3b268bc2014-07-28 17:43:15279 base::Bind(&JsonPrefStore::OnFileRead, AsWeakPtr()));
[email protected]7b2720b2012-04-25 16:59:11280}
281
282void JsonPrefStore::CommitPendingWrite() {
[email protected]f2456592014-07-22 19:30:17283 DCHECK(CalledOnValidThread());
284
[email protected]7b2720b2012-04-25 16:59:11285 if (writer_.HasPendingWrite() && !read_only_)
286 writer_.DoScheduledWrite();
287}
288
289void JsonPrefStore::ReportValueChanged(const std::string& key) {
[email protected]f2456592014-07-22 19:30:17290 DCHECK(CalledOnValidThread());
291
[email protected]a0ce7e72014-01-21 16:50:56292 if (pref_filter_)
293 pref_filter_->FilterUpdate(key);
[email protected]56cbcb3a2013-12-23 21:24:46294
[email protected]7b2720b2012-04-25 16:59:11295 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
[email protected]56cbcb3a2013-12-23 21:24:46296
[email protected]7b2720b2012-04-25 16:59:11297 if (!read_only_)
298 writer_.ScheduleWrite(this);
299}
300
[email protected]e33c9512014-05-12 02:24:13301void JsonPrefStore::RegisterOnNextSuccessfulWriteCallback(
302 const base::Closure& on_next_successful_write) {
[email protected]f2456592014-07-22 19:30:17303 DCHECK(CalledOnValidThread());
304
[email protected]e33c9512014-05-12 02:24:13305 writer_.RegisterOnNextSuccessfulWriteCallback(on_next_successful_write);
306}
307
[email protected]f2456592014-07-22 19:30:17308void JsonPrefStore::OnFileRead(scoped_ptr<ReadResult> read_result) {
309 DCHECK(CalledOnValidThread());
310
311 DCHECK(read_result);
312
[email protected]e33c9512014-05-12 02:24:13313 scoped_ptr<base::DictionaryValue> unfiltered_prefs(new base::DictionaryValue);
314
[email protected]f2456592014-07-22 19:30:17315 read_error_ = read_result->error;
[email protected]845b43a82011-05-11 10:14:43316
[email protected]f2456592014-07-22 19:30:17317 bool initialization_successful = !read_result->no_dir;
[email protected]e33c9512014-05-12 02:24:13318
319 if (initialization_successful) {
320 switch (read_error_) {
321 case PREF_READ_ERROR_ACCESS_DENIED:
322 case PREF_READ_ERROR_FILE_OTHER:
323 case PREF_READ_ERROR_FILE_LOCKED:
324 case PREF_READ_ERROR_JSON_TYPE:
325 case PREF_READ_ERROR_FILE_NOT_SPECIFIED:
326 read_only_ = true;
327 break;
328 case PREF_READ_ERROR_NONE:
[email protected]f2456592014-07-22 19:30:17329 DCHECK(read_result->value.get());
[email protected]e33c9512014-05-12 02:24:13330 unfiltered_prefs.reset(
[email protected]f2456592014-07-22 19:30:17331 static_cast<base::DictionaryValue*>(read_result->value.release()));
[email protected]e33c9512014-05-12 02:24:13332 break;
333 case PREF_READ_ERROR_NO_FILE:
334 // If the file just doesn't exist, maybe this is first run. In any case
335 // there's no harm in writing out default prefs in this case.
336 break;
337 case PREF_READ_ERROR_JSON_PARSE:
338 case PREF_READ_ERROR_JSON_REPEAT:
339 break;
340 case PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE:
341 // This is a special error code to be returned by ReadPrefs when it
342 // can't complete synchronously, it should never be returned by the read
343 // operation itself.
344 NOTREACHED();
345 break;
[email protected]3edebd952014-05-28 08:27:58346 case PREF_READ_ERROR_LEVELDB_IO:
347 case PREF_READ_ERROR_LEVELDB_CORRUPTION_READ_ONLY:
348 case PREF_READ_ERROR_LEVELDB_CORRUPTION:
349 // These are specific to LevelDBPrefStore.
350 NOTREACHED();
[email protected]e33c9512014-05-12 02:24:13351 case PREF_READ_ERROR_MAX_ENUM:
352 NOTREACHED();
353 break;
354 }
[email protected]845b43a82011-05-11 10:14:43355 }
356
[email protected]e33c9512014-05-12 02:24:13357 if (pref_filter_) {
358 filtering_in_progress_ = true;
359 const PrefFilter::PostFilterOnLoadCallback post_filter_on_load_callback(
360 base::Bind(
[email protected]3b268bc2014-07-28 17:43:15361 &JsonPrefStore::FinalizeFileRead, AsWeakPtr(),
362 initialization_successful));
[email protected]e33c9512014-05-12 02:24:13363 pref_filter_->FilterOnLoad(post_filter_on_load_callback,
364 unfiltered_prefs.Pass());
365 } else {
366 FinalizeFileRead(initialization_successful, unfiltered_prefs.Pass(), false);
[email protected]844a1002011-04-19 11:37:21367 }
[email protected]844a1002011-04-19 11:37:21368}
369
[email protected]7b2720b2012-04-25 16:59:11370JsonPrefStore::~JsonPrefStore() {
371 CommitPendingWrite();
[email protected]f89ee342011-03-07 09:28:27372}
373
[email protected]277404c22010-04-22 13:09:45374bool JsonPrefStore::SerializeData(std::string* output) {
[email protected]f2456592014-07-22 19:30:17375 DCHECK(CalledOnValidThread());
376
[email protected]bc831ff12014-01-31 20:48:33377 if (pref_filter_)
[email protected]a0ce7e72014-01-21 16:50:56378 pref_filter_->FilterSerializeData(prefs_.get());
379
[email protected]277404c22010-04-22 13:09:45380 JSONStringValueSerializer serializer(output);
381 serializer.set_pretty_print(true);
[email protected]ac771fb362014-07-16 06:04:44382 bool result = serializer.Serialize(*prefs_);
383
384 if (result) {
385 std::string spaceless_basename;
386 base::ReplaceChars(path_.BaseName().MaybeAsASCII(), " ", "_",
387 &spaceless_basename);
388
389 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_10000
390 // macro adapted to allow for a dynamically suffixed histogram name.
391 // Note: The factory creates and owns the histogram.
392 base::HistogramBase* histogram =
393 base::LinearHistogram::FactoryGet(
394 "Settings.JsonDataSizeKilobytes." + spaceless_basename,
395 1,
396 10000,
397 50,
398 base::HistogramBase::kUmaTargetedHistogramFlag);
399 histogram->Add(static_cast<int>(output->size()) / 1024);
400 }
401
402 return result;
[email protected]277404c22010-04-22 13:09:45403}
[email protected]e33c9512014-05-12 02:24:13404
405void JsonPrefStore::FinalizeFileRead(bool initialization_successful,
406 scoped_ptr<base::DictionaryValue> prefs,
407 bool schedule_write) {
[email protected]f2456592014-07-22 19:30:17408 DCHECK(CalledOnValidThread());
409
[email protected]e33c9512014-05-12 02:24:13410 filtering_in_progress_ = false;
411
412 if (!initialization_successful) {
413 FOR_EACH_OBSERVER(PrefStore::Observer,
414 observers_,
415 OnInitializationCompleted(false));
416 return;
417 }
418
419 prefs_ = prefs.Pass();
420
421 initialized_ = true;
422
423 if (schedule_write && !read_only_)
424 writer_.ScheduleWrite(this);
425
426 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE)
427 error_delegate_->OnError(read_error_);
428
429 FOR_EACH_OBSERVER(PrefStore::Observer,
430 observers_,
431 OnInitializationCompleted(true));
432
433 return;
434}