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

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: No export 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)) {
405 serializer.set_pretty_print(true);
406 }
402 return serializer.Serialize(*prefs_); 407 return serializer.Serialize(*prefs_);
403 } 408 }
404 409
405 void JsonPrefStore::FinalizeFileRead(bool initialization_successful, 410 void JsonPrefStore::FinalizeFileRead(bool initialization_successful,
406 scoped_ptr<base::DictionaryValue> prefs, 411 scoped_ptr<base::DictionaryValue> prefs,
407 bool schedule_write) { 412 bool schedule_write) {
408 DCHECK(CalledOnValidThread()); 413 DCHECK(CalledOnValidThread());
409 414
410 filtering_in_progress_ = false; 415 filtering_in_progress_ = false;
411 416
(...skipping 13 matching lines...) Expand all
425 430
426 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) 431 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE)
427 error_delegate_->OnError(read_error_); 432 error_delegate_->OnError(read_error_);
428 433
429 FOR_EACH_OBSERVER(PrefStore::Observer, 434 FOR_EACH_OBSERVER(PrefStore::Observer,
430 observers_, 435 observers_,
431 OnInitializationCompleted(true)); 436 OnInitializationCompleted(true));
432 437
433 return; 438 return;
434 } 439 }
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