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 "base/prefs/json_pref_store.h" | 5 #include "base/prefs/json_pref_store.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 scoped_refptr<base::SequencedTaskRunner> JsonPrefStore::GetTaskRunnerForFile( | 117 scoped_refptr<base::SequencedTaskRunner> JsonPrefStore::GetTaskRunnerForFile( |
118 const base::FilePath& filename, | 118 const base::FilePath& filename, |
119 base::SequencedWorkerPool* worker_pool) { | 119 base::SequencedWorkerPool* worker_pool) { |
120 std::string token("json_pref_store-"); | 120 std::string token("json_pref_store-"); |
121 token.append(filename.AsUTF8Unsafe()); | 121 token.append(filename.AsUTF8Unsafe()); |
122 return worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 122 return worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
123 worker_pool->GetNamedSequenceToken(token), | 123 worker_pool->GetNamedSequenceToken(token), |
124 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 124 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
125 } | 125 } |
126 | 126 |
127 JsonPrefStore::JsonPrefStore(const base::FilePath& filename, | 127 JsonPrefStore::JsonPrefStore( |
128 base::SequencedTaskRunner* sequenced_task_runner, | 128 const base::FilePath& filename, |
129 scoped_ptr<PrefFilter> pref_filter) | 129 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, |
| 130 scoped_ptr<PrefFilter> pref_filter) |
130 : path_(filename), | 131 : path_(filename), |
131 sequenced_task_runner_(sequenced_task_runner), | 132 sequenced_task_runner_(sequenced_task_runner), |
132 prefs_(new base::DictionaryValue()), | 133 prefs_(new base::DictionaryValue()), |
133 read_only_(false), | 134 read_only_(false), |
134 writer_(filename, sequenced_task_runner), | 135 writer_(filename, sequenced_task_runner), |
135 pref_filter_(pref_filter.Pass()), | 136 pref_filter_(pref_filter.Pass()), |
136 initialized_(false), | 137 initialized_(false), |
137 filtering_in_progress_(false), | 138 filtering_in_progress_(false), |
138 read_error_(PREF_READ_ERROR_NONE) { | 139 read_error_(PREF_READ_ERROR_NONE) { |
139 } | 140 } |
140 | 141 |
141 JsonPrefStore::JsonPrefStore(const base::FilePath& filename, | 142 JsonPrefStore::JsonPrefStore( |
142 const base::FilePath& alternate_filename, | 143 const base::FilePath& filename, |
143 base::SequencedTaskRunner* sequenced_task_runner, | 144 const base::FilePath& alternate_filename, |
144 scoped_ptr<PrefFilter> pref_filter) | 145 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, |
| 146 scoped_ptr<PrefFilter> pref_filter) |
145 : path_(filename), | 147 : path_(filename), |
146 alternate_path_(alternate_filename), | 148 alternate_path_(alternate_filename), |
147 sequenced_task_runner_(sequenced_task_runner), | 149 sequenced_task_runner_(sequenced_task_runner), |
148 prefs_(new base::DictionaryValue()), | 150 prefs_(new base::DictionaryValue()), |
149 read_only_(false), | 151 read_only_(false), |
150 writer_(filename, sequenced_task_runner), | 152 writer_(filename, sequenced_task_runner), |
151 pref_filter_(pref_filter.Pass()), | 153 pref_filter_(pref_filter.Pass()), |
152 initialized_(false), | 154 initialized_(false), |
153 filtering_in_progress_(false), | 155 filtering_in_progress_(false), |
154 read_error_(PREF_READ_ERROR_NONE) { | 156 read_error_(PREF_READ_ERROR_NONE) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 436 |
435 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) | 437 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) |
436 error_delegate_->OnError(read_error_); | 438 error_delegate_->OnError(read_error_); |
437 | 439 |
438 FOR_EACH_OBSERVER(PrefStore::Observer, | 440 FOR_EACH_OBSERVER(PrefStore::Observer, |
439 observers_, | 441 observers_, |
440 OnInitializationCompleted(true)); | 442 OnInitializationCompleted(true)); |
441 | 443 |
442 return; | 444 return; |
443 } | 445 } |
OLD | NEW |