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

Side by Side Diff: base/prefs/json_pref_store.cc

Issue 226633002: Commit changes after a reset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « no previous file | base/prefs/pref_filter.h » ('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) 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
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_) {
318 pref_filter_->FilterOnLoad(prefs_.get()); 318 if (pref_filter_->FilterOnLoad(prefs_.get())) {
319 writer_.ScheduleWrite(this);
320 writer_.DoScheduledWrite();
gab 2014/04/04 21:02:07 I don't think you need to commit changes, scheduli
erikwright (departed) 2014/04/07 14:57:14 Fair enough.
321 }
322 }
319 323
320 if (error_delegate_.get() && error != PREF_READ_ERROR_NONE) 324 if (error_delegate_.get() && error != PREF_READ_ERROR_NONE)
321 error_delegate_->OnError(error); 325 error_delegate_->OnError(error);
322 326
323 FOR_EACH_OBSERVER(PrefStore::Observer, 327 FOR_EACH_OBSERVER(PrefStore::Observer,
324 observers_, 328 observers_,
325 OnInitializationCompleted(true)); 329 OnInitializationCompleted(true));
326 } 330 }
327 331
328 JsonPrefStore::~JsonPrefStore() { 332 JsonPrefStore::~JsonPrefStore() {
329 CommitPendingWrite(); 333 CommitPendingWrite();
330 } 334 }
331 335
332 bool JsonPrefStore::SerializeData(std::string* output) { 336 bool JsonPrefStore::SerializeData(std::string* output) {
333 if (pref_filter_) 337 if (pref_filter_)
334 pref_filter_->FilterSerializeData(prefs_.get()); 338 pref_filter_->FilterSerializeData(prefs_.get());
335 339
336 JSONStringValueSerializer serializer(output); 340 JSONStringValueSerializer serializer(output);
337 serializer.set_pretty_print(true); 341 serializer.set_pretty_print(true);
338 return serializer.Serialize(*prefs_); 342 return serializer.Serialize(*prefs_);
339 } 343 }
OLDNEW
« no previous file with comments | « no previous file | base/prefs/pref_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698