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

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

Issue 974753002: Stop pretty-printing pref JSON (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add --pretty-print-prefs switch 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/test/data/prefs/write.golden.json » ('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"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
13 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
14 #include "base/json/json_string_value_serializer.h" 15 #include "base/json/json_string_value_serializer.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/prefs/base_prefs_switches.h"
17 #include "base/prefs/pref_filter.h" 19 #include "base/prefs/pref_filter.h"
18 #include "base/sequenced_task_runner.h" 20 #include "base/sequenced_task_runner.h"
19 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
20 #include "base/task_runner_util.h" 22 #include "base/task_runner_util.h"
21 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
22 #include "base/values.h" 24 #include "base/values.h"
23 25
24 // Result returned from internal read tasks. 26 // Result returned from internal read tasks.
25 struct JsonPrefStore::ReadResult { 27 struct JsonPrefStore::ReadResult {
26 public: 28 public:
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 CommitPendingWrite(); 393 CommitPendingWrite();
392 } 394 }
393 395
394 bool JsonPrefStore::SerializeData(std::string* output) { 396 bool JsonPrefStore::SerializeData(std::string* output) {
395 DCHECK(CalledOnValidThread()); 397 DCHECK(CalledOnValidThread());
396 398
397 if (pref_filter_) 399 if (pref_filter_)
398 pref_filter_->FilterSerializeData(prefs_.get()); 400 pref_filter_->FilterSerializeData(prefs_.get());
399 401
400 JSONStringValueSerializer serializer(output); 402 JSONStringValueSerializer serializer(output);
401 serializer.set_pretty_print(true); 403 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
404 switches::kPrettyPrintPrefs))
Bernhard Bauer 2015/03/04 10:07:58 Add braces around the body if the condition is mor
hashimoto 2015/03/04 14:18:40 Done.
405 serializer.set_pretty_print(true);
402 return serializer.Serialize(*prefs_); 406 return serializer.Serialize(*prefs_);
403 } 407 }
404 408
405 void JsonPrefStore::FinalizeFileRead(bool initialization_successful, 409 void JsonPrefStore::FinalizeFileRead(bool initialization_successful,
406 scoped_ptr<base::DictionaryValue> prefs, 410 scoped_ptr<base::DictionaryValue> prefs,
407 bool schedule_write) { 411 bool schedule_write) {
408 DCHECK(CalledOnValidThread()); 412 DCHECK(CalledOnValidThread());
409 413
410 filtering_in_progress_ = false; 414 filtering_in_progress_ = false;
411 415
(...skipping 13 matching lines...) Expand all
425 429
426 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) 430 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE)
427 error_delegate_->OnError(read_error_); 431 error_delegate_->OnError(read_error_);
428 432
429 FOR_EACH_OBSERVER(PrefStore::Observer, 433 FOR_EACH_OBSERVER(PrefStore::Observer,
430 observers_, 434 observers_,
431 OnInitializationCompleted(true)); 435 OnInitializationCompleted(true));
432 436
433 return; 437 return;
434 } 438 }
OLDNEW
« no previous file with comments | « base/prefs/base_prefs_switches.cc ('k') | base/test/data/prefs/write.golden.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698