| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // If the file just doesn't exist, maybe this is first run. In any case | 307 // If the file just doesn't exist, maybe this is first run. In any case |
| 308 // there's no harm in writing out default prefs in this case. | 308 // there's no harm in writing out default prefs in this case. |
| 309 break; | 309 break; |
| 310 case PREF_READ_ERROR_JSON_PARSE: | 310 case PREF_READ_ERROR_JSON_PARSE: |
| 311 case PREF_READ_ERROR_JSON_REPEAT: | 311 case PREF_READ_ERROR_JSON_REPEAT: |
| 312 break; | 312 break; |
| 313 default: | 313 default: |
| 314 NOTREACHED() << "Unknown error: " << error; | 314 NOTREACHED() << "Unknown error: " << error; |
| 315 } | 315 } |
| 316 | 316 |
| 317 if (pref_filter_) | 317 if (pref_filter_ && pref_filter_->FilterOnLoad(prefs_.get())) |
| 318 pref_filter_->FilterOnLoad(prefs_.get()); | 318 writer_.ScheduleWrite(this); |
| 319 | 319 |
| 320 if (error_delegate_.get() && error != PREF_READ_ERROR_NONE) | 320 if (error_delegate_.get() && error != PREF_READ_ERROR_NONE) |
| 321 error_delegate_->OnError(error); | 321 error_delegate_->OnError(error); |
| 322 | 322 |
| 323 FOR_EACH_OBSERVER(PrefStore::Observer, | 323 FOR_EACH_OBSERVER(PrefStore::Observer, |
| 324 observers_, | 324 observers_, |
| 325 OnInitializationCompleted(true)); | 325 OnInitializationCompleted(true)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 JsonPrefStore::~JsonPrefStore() { | 328 JsonPrefStore::~JsonPrefStore() { |
| 329 CommitPendingWrite(); | 329 CommitPendingWrite(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool JsonPrefStore::SerializeData(std::string* output) { | 332 bool JsonPrefStore::SerializeData(std::string* output) { |
| 333 if (pref_filter_) | 333 if (pref_filter_) |
| 334 pref_filter_->FilterSerializeData(prefs_.get()); | 334 pref_filter_->FilterSerializeData(prefs_.get()); |
| 335 | 335 |
| 336 JSONStringValueSerializer serializer(output); | 336 JSONStringValueSerializer serializer(output); |
| 337 serializer.set_pretty_print(true); | 337 serializer.set_pretty_print(true); |
| 338 return serializer.Serialize(*prefs_); | 338 return serializer.Serialize(*prefs_); |
| 339 } | 339 } |
| OLD | NEW |