| 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 "components/prefs/json_pref_store.h" | 5 #include "components/prefs/json_pref_store.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 CommitPendingWrite(); | 455 CommitPendingWrite(); |
| 456 } | 456 } |
| 457 | 457 |
| 458 bool JsonPrefStore::SerializeData(std::string* output) { | 458 bool JsonPrefStore::SerializeData(std::string* output) { |
| 459 DCHECK(CalledOnValidThread()); | 459 DCHECK(CalledOnValidThread()); |
| 460 | 460 |
| 461 pending_lossy_write_ = false; | 461 pending_lossy_write_ = false; |
| 462 | 462 |
| 463 write_count_histogram_.RecordWriteOccured(); | 463 write_count_histogram_.RecordWriteOccured(); |
| 464 | 464 |
| 465 if (pref_filter_) | 465 if (pref_filter_) { |
| 466 pref_filter_->FilterSerializeData(prefs_.get()); | 466 base::Callback<void(bool)> pref_filter_post_write_callback = |
| 467 pref_filter_->FilterSerializeData(prefs_.get()); |
| 468 if (!pref_filter_post_write_callback.is_null()) |
| 469 RegisterOnNextWriteSynchronousCallback(pref_filter_post_write_callback); |
| 470 } |
| 467 | 471 |
| 468 JSONStringValueSerializer serializer(output); | 472 JSONStringValueSerializer serializer(output); |
| 469 // Not pretty-printing prefs shrinks pref file size by ~30%. To obtain | 473 // Not pretty-printing prefs shrinks pref file size by ~30%. To obtain |
| 470 // readable prefs for debugging purposes, you can dump your prefs into any | 474 // readable prefs for debugging purposes, you can dump your prefs into any |
| 471 // command-line or online JSON pretty printing tool. | 475 // command-line or online JSON pretty printing tool. |
| 472 serializer.set_pretty_print(false); | 476 serializer.set_pretty_print(false); |
| 473 return serializer.Serialize(*prefs_); | 477 return serializer.Serialize(*prefs_); |
| 474 } | 478 } |
| 475 | 479 |
| 476 void JsonPrefStore::FinalizeFileRead( | 480 void JsonPrefStore::FinalizeFileRead( |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 DCHECK_EQ(31, num_buckets); | 598 DCHECK_EQ(31, num_buckets); |
| 595 | 599 |
| 596 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 600 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
| 597 // macro adapted to allow for a dynamically suffixed histogram name. | 601 // macro adapted to allow for a dynamically suffixed histogram name. |
| 598 // Note: The factory creates and owns the histogram. | 602 // Note: The factory creates and owns the histogram. |
| 599 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 603 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 600 histogram_name, min_value, max_value, num_buckets, | 604 histogram_name, min_value, max_value, num_buckets, |
| 601 base::HistogramBase::kUmaTargetedHistogramFlag); | 605 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 602 return histogram; | 606 return histogram; |
| 603 } | 607 } |
| OLD | NEW |