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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress 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
« no previous file with comments | « base/prefs/base_prefs_switches.cc ('k') | base/prefs/pref_member.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"
11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
14 #include "base/json/json_file_value_serializer.h" 13 #include "base/json/json_file_value_serializer.h"
15 #include "base/json/json_string_value_serializer.h" 14 #include "base/json/json_string_value_serializer.h"
16 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
17 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
18 #include "base/prefs/base_prefs_switches.h"
19 #include "base/prefs/pref_filter.h" 17 #include "base/prefs/pref_filter.h"
20 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
21 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
22 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
23 #include "base/threading/sequenced_worker_pool.h" 21 #include "base/threading/sequenced_worker_pool.h"
24 #include "base/values.h" 22 #include "base/values.h"
25 23
26 // Result returned from internal read tasks. 24 // Result returned from internal read tasks.
27 struct JsonPrefStore::ReadResult { 25 struct JsonPrefStore::ReadResult {
28 public: 26 public:
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 CommitPendingWrite(); 391 CommitPendingWrite();
394 } 392 }
395 393
396 bool JsonPrefStore::SerializeData(std::string* output) { 394 bool JsonPrefStore::SerializeData(std::string* output) {
397 DCHECK(CalledOnValidThread()); 395 DCHECK(CalledOnValidThread());
398 396
399 if (pref_filter_) 397 if (pref_filter_)
400 pref_filter_->FilterSerializeData(prefs_.get()); 398 pref_filter_->FilterSerializeData(prefs_.get());
401 399
402 JSONStringValueSerializer serializer(output); 400 JSONStringValueSerializer serializer(output);
403 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 401 // Not pretty-printing prefs shrinks pref file size by ~30%. To obtain
404 switches::kPrettyPrintPrefs)) { 402 // readable prefs for debugging purposes, you can dump your prefs into any
405 serializer.set_pretty_print(true); 403 // command-line or online JSON pretty printing tool.
406 } 404 serializer.set_pretty_print(false);
407 return serializer.Serialize(*prefs_); 405 return serializer.Serialize(*prefs_);
408 } 406 }
409 407
410 void JsonPrefStore::FinalizeFileRead(bool initialization_successful, 408 void JsonPrefStore::FinalizeFileRead(bool initialization_successful,
411 scoped_ptr<base::DictionaryValue> prefs, 409 scoped_ptr<base::DictionaryValue> prefs,
412 bool schedule_write) { 410 bool schedule_write) {
413 DCHECK(CalledOnValidThread()); 411 DCHECK(CalledOnValidThread());
414 412
415 filtering_in_progress_ = false; 413 filtering_in_progress_ = false;
416 414
(...skipping 13 matching lines...) Expand all
430 428
431 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) 429 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE)
432 error_delegate_->OnError(read_error_); 430 error_delegate_->OnError(read_error_);
433 431
434 FOR_EACH_OBSERVER(PrefStore::Observer, 432 FOR_EACH_OBSERVER(PrefStore::Observer,
435 observers_, 433 observers_,
436 OnInitializationCompleted(true)); 434 OnInitializationCompleted(true));
437 435
438 return; 436 return;
439 } 437 }
OLDNEW
« no previous file with comments | « base/prefs/base_prefs_switches.cc ('k') | base/prefs/pref_member.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698