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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 ScheduleWrite(flags); | 323 ScheduleWrite(flags); |
324 } | 324 } |
325 | 325 |
326 void JsonPrefStore::RegisterOnNextSuccessfulWriteCallback( | 326 void JsonPrefStore::RegisterOnNextSuccessfulWriteCallback( |
327 const base::Closure& on_next_successful_write) { | 327 const base::Closure& on_next_successful_write) { |
328 DCHECK(CalledOnValidThread()); | 328 DCHECK(CalledOnValidThread()); |
329 | 329 |
330 writer_.RegisterOnNextSuccessfulWriteCallback(on_next_successful_write); | 330 writer_.RegisterOnNextSuccessfulWriteCallback(on_next_successful_write); |
331 } | 331 } |
332 | 332 |
| 333 void JsonPrefStore::RegisterOnNextSuccessfulWriteBlockingCallback( |
| 334 const base::Closure& on_next_successful_write) { |
| 335 DCHECK(CalledOnValidThread()); |
| 336 |
| 337 writer_.RegisterOnNextSuccessfulWriteBlockingCallback( |
| 338 on_next_successful_write); |
| 339 } |
| 340 |
333 void JsonPrefStore::ClearMutableValues() { | 341 void JsonPrefStore::ClearMutableValues() { |
334 NOTIMPLEMENTED(); | 342 NOTIMPLEMENTED(); |
335 } | 343 } |
336 | 344 |
337 void JsonPrefStore::OnFileRead(std::unique_ptr<ReadResult> read_result) { | 345 void JsonPrefStore::OnFileRead(std::unique_ptr<ReadResult> read_result) { |
338 DCHECK(CalledOnValidThread()); | 346 DCHECK(CalledOnValidThread()); |
339 | 347 |
340 DCHECK(read_result); | 348 DCHECK(read_result); |
341 | 349 |
342 std::unique_ptr<base::DictionaryValue> unfiltered_prefs( | 350 std::unique_ptr<base::DictionaryValue> unfiltered_prefs( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 CommitPendingWrite(); | 402 CommitPendingWrite(); |
395 } | 403 } |
396 | 404 |
397 bool JsonPrefStore::SerializeData(std::string* output) { | 405 bool JsonPrefStore::SerializeData(std::string* output) { |
398 DCHECK(CalledOnValidThread()); | 406 DCHECK(CalledOnValidThread()); |
399 | 407 |
400 pending_lossy_write_ = false; | 408 pending_lossy_write_ = false; |
401 | 409 |
402 write_count_histogram_.RecordWriteOccured(); | 410 write_count_histogram_.RecordWriteOccured(); |
403 | 411 |
404 if (pref_filter_) | 412 if (pref_filter_) { |
| 413 RegisterOnNextSuccessfulWriteBlockingCallback( |
| 414 pref_filter_->GetPostSerializeCallback(prefs_.get())); |
405 pref_filter_->FilterSerializeData(prefs_.get()); | 415 pref_filter_->FilterSerializeData(prefs_.get()); |
| 416 } |
406 | 417 |
407 JSONStringValueSerializer serializer(output); | 418 JSONStringValueSerializer serializer(output); |
408 // Not pretty-printing prefs shrinks pref file size by ~30%. To obtain | 419 // Not pretty-printing prefs shrinks pref file size by ~30%. To obtain |
409 // readable prefs for debugging purposes, you can dump your prefs into any | 420 // readable prefs for debugging purposes, you can dump your prefs into any |
410 // command-line or online JSON pretty printing tool. | 421 // command-line or online JSON pretty printing tool. |
411 serializer.set_pretty_print(false); | 422 serializer.set_pretty_print(false); |
412 return serializer.Serialize(*prefs_); | 423 return serializer.Serialize(*prefs_); |
413 } | 424 } |
414 | 425 |
415 void JsonPrefStore::FinalizeFileRead( | 426 void JsonPrefStore::FinalizeFileRead( |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 DCHECK_EQ(31, num_buckets); | 544 DCHECK_EQ(31, num_buckets); |
534 | 545 |
535 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 546 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
536 // macro adapted to allow for a dynamically suffixed histogram name. | 547 // macro adapted to allow for a dynamically suffixed histogram name. |
537 // Note: The factory creates and owns the histogram. | 548 // Note: The factory creates and owns the histogram. |
538 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 549 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
539 histogram_name, min_value, max_value, num_buckets, | 550 histogram_name, min_value, max_value, num_buckets, |
540 base::HistogramBase::kUmaTargetedHistogramFlag); | 551 base::HistogramBase::kUmaTargetedHistogramFlag); |
541 return histogram; | 552 return histogram; |
542 } | 553 } |
OLD | NEW |