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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 error_delegate_.reset(error_delegate); | 275 error_delegate_.reset(error_delegate); |
276 if (path_.empty()) { | 276 if (path_.empty()) { |
277 scoped_ptr<ReadResult> no_file_result; | 277 scoped_ptr<ReadResult> no_file_result; |
278 no_file_result->error = PREF_READ_ERROR_FILE_NOT_SPECIFIED; | 278 no_file_result->error = PREF_READ_ERROR_FILE_NOT_SPECIFIED; |
279 OnFileRead(no_file_result.Pass()); | 279 OnFileRead(no_file_result.Pass()); |
280 return; | 280 return; |
281 } | 281 } |
282 | 282 |
283 // Weakly binds the read task so that it doesn't kick in during shutdown. | 283 // Weakly binds the read task so that it doesn't kick in during shutdown. |
284 base::PostTaskAndReplyWithResult( | 284 base::PostTaskAndReplyWithResult( |
285 sequenced_task_runner_, | 285 sequenced_task_runner_.get(), |
286 FROM_HERE, | 286 FROM_HERE, |
287 base::Bind(&ReadPrefsFromDisk, path_, alternate_path_), | 287 base::Bind(&ReadPrefsFromDisk, path_, alternate_path_), |
288 base::Bind(&JsonPrefStore::OnFileRead, AsWeakPtr())); | 288 base::Bind(&JsonPrefStore::OnFileRead, AsWeakPtr())); |
289 } | 289 } |
290 | 290 |
291 void JsonPrefStore::CommitPendingWrite() { | 291 void JsonPrefStore::CommitPendingWrite() { |
292 DCHECK(CalledOnValidThread()); | 292 DCHECK(CalledOnValidThread()); |
293 | 293 |
294 if (writer_.HasPendingWrite() && !read_only_) | 294 if (writer_.HasPendingWrite() && !read_only_) |
295 writer_.DoScheduledWrite(); | 295 writer_.DoScheduledWrite(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 434 |
435 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) | 435 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) |
436 error_delegate_->OnError(read_error_); | 436 error_delegate_->OnError(read_error_); |
437 | 437 |
438 FOR_EACH_OBSERVER(PrefStore::Observer, | 438 FOR_EACH_OBSERVER(PrefStore::Observer, |
439 observers_, | 439 observers_, |
440 OnInitializationCompleted(true)); | 440 OnInitializationCompleted(true)); |
441 | 441 |
442 return; | 442 return; |
443 } | 443 } |
OLD | NEW |