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

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

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and added important_file_writer CL as dependent patchset Created 4 years, 3 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
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 "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
323 ScheduleWrite(flags); 323 ScheduleWrite(flags);
324 } 324 }
325 325
326 void JsonPrefStore::RegisterOnNextSuccessfulWriteReply( 326 void JsonPrefStore::RegisterOnNextSuccessfulWriteReply(
327 const base::Closure& on_next_successful_write_reply) { 327 const base::Closure& on_next_successful_write_reply) {
328 DCHECK(CalledOnValidThread()); 328 DCHECK(CalledOnValidThread());
329 329
330 writer_.RegisterOnNextSuccessfulWriteReply(on_next_successful_write_reply); 330 writer_.RegisterOnNextSuccessfulWriteReply(on_next_successful_write_reply);
331 } 331 }
332 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);
338 }
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);
341 348
342 std::unique_ptr<base::DictionaryValue> unfiltered_prefs( 349 std::unique_ptr<base::DictionaryValue> unfiltered_prefs(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::Callback<void(bool)> pref_filter_post_write_callback =
413 pref_filter_->FilterSerializeData(prefs_.get());
414 if (!pref_filter_post_write_callback.is_null())
415 RegisterOnNextWriteSynchronousCallback(pref_filter_post_write_callback);
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698