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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 DCHECK(CalledOnValidThread()); | 316 DCHECK(CalledOnValidThread()); |
317 | 317 |
318 if (pref_filter_) | 318 if (pref_filter_) |
319 pref_filter_->FilterUpdate(key); | 319 pref_filter_->FilterUpdate(key); |
320 | 320 |
321 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 321 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
322 | 322 |
323 ScheduleWrite(flags); | 323 ScheduleWrite(flags); |
324 } | 324 } |
325 | 325 |
326 void JsonPrefStore::RegisterOnNextSuccessfulWriteCallback( | 326 void JsonPrefStore::RegisterOnNextSuccessfulWriteReply( |
327 const base::Closure& on_next_successful_write) { | 327 const base::Closure& on_next_successful_write_reply) { |
328 DCHECK(CalledOnValidThread()); | 328 DCHECK(CalledOnValidThread()); |
329 | 329 |
330 writer_.RegisterOnNextSuccessfulWriteCallback(on_next_successful_write); | 330 writer_.RegisterOnNextSuccessfulWriteReply(on_next_successful_write_reply); |
331 } | |
332 | |
333 void JsonPrefStore::RegisterOnNextWriteSynchronousCallback( | |
334 const base::Callback<void(bool success)>& on_next_write_callback) { | |
335 DCHECK(CalledOnValidThread()); | |
336 | |
337 writer_.RegisterOnNextWriteSynchronousCallback(on_next_write_callback); | |
331 } | 338 } |
332 | 339 |
333 void JsonPrefStore::ClearMutableValues() { | 340 void JsonPrefStore::ClearMutableValues() { |
334 NOTIMPLEMENTED(); | 341 NOTIMPLEMENTED(); |
335 } | 342 } |
336 | 343 |
337 void JsonPrefStore::OnFileRead(std::unique_ptr<ReadResult> read_result) { | 344 void JsonPrefStore::OnFileRead(std::unique_ptr<ReadResult> read_result) { |
338 DCHECK(CalledOnValidThread()); | 345 DCHECK(CalledOnValidThread()); |
339 | 346 |
340 DCHECK(read_result); | 347 DCHECK(read_result); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 CommitPendingWrite(); | 401 CommitPendingWrite(); |
395 } | 402 } |
396 | 403 |
397 bool JsonPrefStore::SerializeData(std::string* output) { | 404 bool JsonPrefStore::SerializeData(std::string* output) { |
398 DCHECK(CalledOnValidThread()); | 405 DCHECK(CalledOnValidThread()); |
399 | 406 |
400 pending_lossy_write_ = false; | 407 pending_lossy_write_ = false; |
401 | 408 |
402 write_count_histogram_.RecordWriteOccured(); | 409 write_count_histogram_.RecordWriteOccured(); |
403 | 410 |
404 if (pref_filter_) | 411 if (pref_filter_) { |
405 pref_filter_->FilterSerializeData(prefs_.get()); | 412 RegisterOnNextWriteSynchronousCallback( |
413 pref_filter_->FilterSerializeData(prefs_.get())); | |
gab
2016/08/08 04:37:45
Save the return value in a var and only register i
proberge
2016/08/31 17:30:16
Done.
| |
414 } | |
406 | 415 |
407 JSONStringValueSerializer serializer(output); | 416 JSONStringValueSerializer serializer(output); |
408 // Not pretty-printing prefs shrinks pref file size by ~30%. To obtain | 417 // 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 | 418 // readable prefs for debugging purposes, you can dump your prefs into any |
410 // command-line or online JSON pretty printing tool. | 419 // command-line or online JSON pretty printing tool. |
411 serializer.set_pretty_print(false); | 420 serializer.set_pretty_print(false); |
412 return serializer.Serialize(*prefs_); | 421 return serializer.Serialize(*prefs_); |
413 } | 422 } |
414 | 423 |
415 void JsonPrefStore::FinalizeFileRead( | 424 void JsonPrefStore::FinalizeFileRead( |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 DCHECK_EQ(31, num_buckets); | 542 DCHECK_EQ(31, num_buckets); |
534 | 543 |
535 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 544 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
536 // macro adapted to allow for a dynamically suffixed histogram name. | 545 // macro adapted to allow for a dynamically suffixed histogram name. |
537 // Note: The factory creates and owns the histogram. | 546 // Note: The factory creates and owns the histogram. |
538 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 547 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
539 histogram_name, min_value, max_value, num_buckets, | 548 histogram_name, min_value, max_value, num_buckets, |
540 base::HistogramBase::kUmaTargetedHistogramFlag); | 549 base::HistogramBase::kUmaTargetedHistogramFlag); |
541 return histogram; | 550 return histogram; |
542 } | 551 } |
OLD | NEW |