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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/json/json_file_value_serializer.h" | 16 #include "base/json/json_file_value_serializer.h" |
17 #include "base/json/json_string_value_serializer.h" | 17 #include "base/json/json_string_value_serializer.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/sequenced_task_runner.h" | 21 #include "base/sequenced_task_runner.h" |
22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/task_runner_util.h" | 24 #include "base/task_runner_util.h" |
25 #include "base/threading/sequenced_task_runner_handle.h" | 25 #include "base/threading/sequenced_task_runner_handle.h" |
26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
27 #include "base/time/default_clock.h" | 27 #include "base/time/default_clock.h" |
28 #include "base/values.h" | 28 #include "base/values.h" |
29 #include "components/prefs/pref_filter.h" | 29 #include "components/prefs/pref_filter.h" |
gab
2017/05/15 16:33:20
rm
| |
30 | 30 |
31 // Result returned from internal read tasks. | 31 // Result returned from internal read tasks. |
32 struct JsonPrefStore::ReadResult { | 32 struct JsonPrefStore::ReadResult { |
33 public: | 33 public: |
34 ReadResult(); | 34 ReadResult(); |
35 ~ReadResult(); | 35 ~ReadResult(); |
36 | 36 |
37 std::unique_ptr<base::Value> value; | 37 std::unique_ptr<base::Value> value; |
38 PrefReadError error; | 38 PrefReadError error; |
39 bool no_dir; | 39 bool no_dir; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 base::SequencedWorkerPool* worker_pool) { | 136 base::SequencedWorkerPool* worker_pool) { |
137 std::string token("json_pref_store-"); | 137 std::string token("json_pref_store-"); |
138 token.append(filename.AsUTF8Unsafe()); | 138 token.append(filename.AsUTF8Unsafe()); |
139 return worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 139 return worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
140 worker_pool->GetNamedSequenceToken(token), | 140 worker_pool->GetNamedSequenceToken(token), |
141 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 141 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
142 } | 142 } |
143 | 143 |
144 JsonPrefStore::JsonPrefStore( | 144 JsonPrefStore::JsonPrefStore( |
145 const base::FilePath& pref_filename, | 145 const base::FilePath& pref_filename, |
146 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, | 146 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner, |
147 std::unique_ptr<PrefFilter> pref_filter) | 147 std::unique_ptr<PrefFilter> pref_filter) |
148 : path_(pref_filename), | 148 : path_(pref_filename), |
149 sequenced_task_runner_(sequenced_task_runner), | 149 sequenced_task_runner_(std::move(sequenced_task_runner)), |
150 prefs_(new base::DictionaryValue()), | 150 prefs_(new base::DictionaryValue()), |
151 read_only_(false), | 151 read_only_(false), |
152 writer_(pref_filename, sequenced_task_runner), | 152 writer_(pref_filename, sequenced_task_runner_), |
153 pref_filter_(std::move(pref_filter)), | 153 pref_filter_(std::move(pref_filter)), |
154 initialized_(false), | 154 initialized_(false), |
155 filtering_in_progress_(false), | 155 filtering_in_progress_(false), |
156 pending_lossy_write_(false), | 156 pending_lossy_write_(false), |
157 read_error_(PREF_READ_ERROR_NONE), | 157 read_error_(PREF_READ_ERROR_NONE), |
158 has_pending_write_reply_(false), | 158 has_pending_write_reply_(false), |
159 write_count_histogram_(writer_.commit_interval(), path_) { | 159 write_count_histogram_(writer_.commit_interval(), path_) { |
160 DCHECK(!path_.empty()); | 160 DCHECK(!path_.empty()); |
161 } | 161 } |
162 | 162 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 DCHECK_EQ(31, num_buckets); | 585 DCHECK_EQ(31, num_buckets); |
586 | 586 |
587 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 587 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
588 // macro adapted to allow for a dynamically suffixed histogram name. | 588 // macro adapted to allow for a dynamically suffixed histogram name. |
589 // Note: The factory creates and owns the histogram. | 589 // Note: The factory creates and owns the histogram. |
590 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 590 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
591 histogram_name, min_value, max_value, num_buckets, | 591 histogram_name, min_value, max_value, num_buckets, |
592 base::HistogramBase::kUmaTargetedHistogramFlag); | 592 base::HistogramBase::kUmaTargetedHistogramFlag); |
593 return histogram; | 593 return histogram; |
594 } | 594 } |
OLD | NEW |