OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/prefs/leveldb_pref_store.h" | 5 #include "chrome/browser/prefs/leveldb_pref_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 332 |
333 void LevelDBPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate) { | 333 void LevelDBPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate) { |
334 DCHECK_EQ(false, initialized_); | 334 DCHECK_EQ(false, initialized_); |
335 error_delegate_.reset(error_delegate); | 335 error_delegate_.reset(error_delegate); |
336 if (path_.empty()) { | 336 if (path_.empty()) { |
337 scoped_ptr<ReadingResults> reading_results(new ReadingResults); | 337 scoped_ptr<ReadingResults> reading_results(new ReadingResults); |
338 reading_results->error = FILE_NOT_SPECIFIED; | 338 reading_results->error = FILE_NOT_SPECIFIED; |
339 OnStorageRead(reading_results.Pass()); | 339 OnStorageRead(reading_results.Pass()); |
340 return; | 340 return; |
341 } | 341 } |
342 PostTaskAndReplyWithResult(sequenced_task_runner_, | 342 PostTaskAndReplyWithResult(sequenced_task_runner_.get(), |
343 FROM_HERE, | 343 FROM_HERE, |
344 base::Bind(&LevelDBPrefStore::DoReading, path_), | 344 base::Bind(&LevelDBPrefStore::DoReading, path_), |
345 base::Bind(&LevelDBPrefStore::OnStorageRead, | 345 base::Bind(&LevelDBPrefStore::OnStorageRead, |
346 weak_ptr_factory_.GetWeakPtr())); | 346 weak_ptr_factory_.GetWeakPtr())); |
347 } | 347 } |
348 | 348 |
349 void LevelDBPrefStore::CommitPendingWrite() { | 349 void LevelDBPrefStore::CommitPendingWrite() { |
350 if (timer_.IsRunning()) { | 350 if (timer_.IsRunning()) { |
351 timer_.Stop(); | 351 timer_.Stop(); |
352 PersistFromUIThread(); | 352 PersistFromUIThread(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 410 } |
411 | 411 |
412 // TODO(dgrogan): Call pref_filter_->FilterOnLoad | 412 // TODO(dgrogan): Call pref_filter_->FilterOnLoad |
413 | 413 |
414 if (error_delegate_.get() && read_error_ != PREF_READ_ERROR_NONE) | 414 if (error_delegate_.get() && read_error_ != PREF_READ_ERROR_NONE) |
415 error_delegate_->OnError(read_error_); | 415 error_delegate_->OnError(read_error_); |
416 | 416 |
417 FOR_EACH_OBSERVER( | 417 FOR_EACH_OBSERVER( |
418 PrefStore::Observer, observers_, OnInitializationCompleted(true)); | 418 PrefStore::Observer, observers_, OnInitializationCompleted(true)); |
419 } | 419 } |
OLD | NEW |