Chromium Code Reviews| 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/filesystem/public/cpp/prefs/filesystem_json_pref_store.h" | 5 #include "components/filesystem/public/cpp/prefs/filesystem_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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 PerformWrite(); | 222 PerformWrite(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void FilesystemJsonPrefStore::ReportValueChanged(const std::string& key, | 225 void FilesystemJsonPrefStore::ReportValueChanged(const std::string& key, |
| 226 uint32_t flags) { | 226 uint32_t flags) { |
| 227 DCHECK(CalledOnValidThread()); | 227 DCHECK(CalledOnValidThread()); |
| 228 | 228 |
| 229 if (pref_filter_) | 229 if (pref_filter_) |
| 230 pref_filter_->FilterUpdate(key); | 230 pref_filter_->FilterUpdate(key); |
| 231 | 231 |
| 232 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 232 for (PrefStore::Observer& observer : observers_) |
| 233 observer.OnPrefValueChanged(key); | |
| 233 | 234 |
| 234 ScheduleWrite(flags); | 235 ScheduleWrite(flags); |
| 235 } | 236 } |
| 236 | 237 |
| 237 void FilesystemJsonPrefStore::OnFileSystemShutdown() {} | 238 void FilesystemJsonPrefStore::OnFileSystemShutdown() {} |
| 238 | 239 |
| 239 void FilesystemJsonPrefStore::OnFileRead( | 240 void FilesystemJsonPrefStore::OnFileRead( |
| 240 std::unique_ptr<ReadResult> read_result) { | 241 std::unique_ptr<ReadResult> read_result) { |
| 241 DCHECK(CalledOnValidThread()); | 242 DCHECK(CalledOnValidThread()); |
| 242 | 243 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 prefs_ = std::move(prefs); | 302 prefs_ = std::move(prefs); |
| 302 | 303 |
| 303 initialized_ = true; | 304 initialized_ = true; |
| 304 | 305 |
| 305 if (schedule_write) | 306 if (schedule_write) |
| 306 ScheduleWrite(DEFAULT_PREF_WRITE_FLAGS); | 307 ScheduleWrite(DEFAULT_PREF_WRITE_FLAGS); |
| 307 | 308 |
| 308 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) | 309 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) |
| 309 error_delegate_->OnError(read_error_); | 310 error_delegate_->OnError(read_error_); |
| 310 | 311 |
| 311 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 312 for (PrefStore::Observer& observer : observers_) |
| 312 OnInitializationCompleted(true)); | 313 observer.OnInitializationCompleted(true); |
| 313 | 314 |
| 314 return; | 315 return; |
|
sdefresne
2016/10/24 20:31:12
nit: remove
Eric Willigers
2016/10/24 22:55:20
Done.
| |
| 315 } | 316 } |
| 316 | 317 |
| 317 void FilesystemJsonPrefStore::ScheduleWrite(uint32_t flags) { | 318 void FilesystemJsonPrefStore::ScheduleWrite(uint32_t flags) { |
| 318 if (read_only_) | 319 if (read_only_) |
| 319 return; | 320 return; |
| 320 | 321 |
| 321 if (flags & LOSSY_PREF_WRITE_FLAG) | 322 if (flags & LOSSY_PREF_WRITE_FLAG) |
| 322 pending_lossy_write_ = true; | 323 pending_lossy_write_ = true; |
| 323 else | 324 else |
| 324 PerformWrite(); | 325 PerformWrite(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 reinterpret_cast<char*>(&contents.front()), contents.size())); | 418 reinterpret_cast<char*>(&contents.front()), contents.size())); |
| 418 read_result->value = deserializer.Deserialize(&error_code, &error_msg); | 419 read_result->value = deserializer.Deserialize(&error_code, &error_msg); |
| 419 read_result->error = HandleReadErrors(read_result->value.get()); | 420 read_result->error = HandleReadErrors(read_result->value.get()); |
| 420 } | 421 } |
| 421 } | 422 } |
| 422 | 423 |
| 423 OnFileRead(std::move(read_result)); | 424 OnFileRead(std::move(read_result)); |
| 424 } | 425 } |
| 425 | 426 |
| 426 } // namespace filesystem | 427 } // namespace filesystem |
| OLD | NEW |