Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: chrome/common/json_pref_store.cc

Issue 10065040: RefCounted types should not have public destructors, chrome/ remaining parts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation fixes Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/json_pref_store.cc
diff --git a/chrome/common/json_pref_store.cc b/chrome/common/json_pref_store.cc
index 488d7c79dd61ebeeaaced577965ab2304ed6b0b1..65f4e107ddd889cc51f42c04a6e4884939459e95 100644
--- a/chrome/common/json_pref_store.cc
+++ b/chrome/common/json_pref_store.cc
@@ -79,6 +79,7 @@ class FileThreadDeserializer
private:
friend class base::RefCountedThreadSafe<FileThreadDeserializer>;
+ ~FileThreadDeserializer() {}
bool no_dir_;
PersistentPrefStore::PrefReadError error_;
@@ -148,10 +149,6 @@ JsonPrefStore::JsonPrefStore(const FilePath& filename,
read_error_(PREF_READ_ERROR_OTHER) {
}
-JsonPrefStore::~JsonPrefStore() {
- CommitPendingWrite();
-}
-
PrefStore::ReadResult JsonPrefStore::GetValue(const std::string& key,
const Value** result) const {
Value* tmp = NULL;
@@ -224,6 +221,45 @@ PersistentPrefStore::PrefReadError JsonPrefStore::GetReadError() const {
return read_error_;
}
+PersistentPrefStore::PrefReadError JsonPrefStore::ReadPrefs() {
+ if (path_.empty()) {
+ OnFileRead(NULL, PREF_READ_ERROR_FILE_NOT_SPECIFIED, false);
+ return PREF_READ_ERROR_FILE_NOT_SPECIFIED;
+ }
+
+ PrefReadError error;
+ bool no_dir;
+ Value* value = FileThreadDeserializer::DoReading(path_, &error, &no_dir);
+ OnFileRead(value, error, no_dir);
+ return error;
+}
+
+void JsonPrefStore::ReadPrefsAsync(ReadErrorDelegate *error_delegate) {
+ initialized_ = false;
+ error_delegate_.reset(error_delegate);
+ if (path_.empty()) {
+ OnFileRead(NULL, PREF_READ_ERROR_FILE_NOT_SPECIFIED, false);
+ return;
+ }
+
+ // Start async reading of the preferences file. It will delete itself
+ // in the end.
+ scoped_refptr<FileThreadDeserializer> deserializer(
+ new FileThreadDeserializer(this, file_message_loop_proxy_.get()));
+ deserializer->Start(path_);
+}
+
+void JsonPrefStore::CommitPendingWrite() {
+ if (writer_.HasPendingWrite() && !read_only_)
+ writer_.DoScheduledWrite();
+}
+
+void JsonPrefStore::ReportValueChanged(const std::string& key) {
+ FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
+ if (!read_only_)
+ writer_.ScheduleWrite(this);
+}
+
void JsonPrefStore::OnFileRead(Value* value_owned,
PersistentPrefStore::PrefReadError error,
bool no_dir) {
@@ -269,43 +305,8 @@ void JsonPrefStore::OnFileRead(Value* value_owned,
OnInitializationCompleted(true));
}
-void JsonPrefStore::ReadPrefsAsync(ReadErrorDelegate *error_delegate) {
- initialized_ = false;
- error_delegate_.reset(error_delegate);
- if (path_.empty()) {
- OnFileRead(NULL, PREF_READ_ERROR_FILE_NOT_SPECIFIED, false);
- return;
- }
-
- // Start async reading of the preferences file. It will delete itself
- // in the end.
- scoped_refptr<FileThreadDeserializer> deserializer(
- new FileThreadDeserializer(this, file_message_loop_proxy_.get()));
- deserializer->Start(path_);
-}
-
-PersistentPrefStore::PrefReadError JsonPrefStore::ReadPrefs() {
- if (path_.empty()) {
- OnFileRead(NULL, PREF_READ_ERROR_FILE_NOT_SPECIFIED, false);
- return PREF_READ_ERROR_FILE_NOT_SPECIFIED;
- }
-
- PrefReadError error;
- bool no_dir;
Nico 2012/04/25 13:20:37 why are you moving unrelated functions around?
Ryan Sleevi 2012/04/25 15:13:59 Places where the order of definition /almost/ matc
- Value* value = FileThreadDeserializer::DoReading(path_, &error, &no_dir);
- OnFileRead(value, error, no_dir);
- return error;
-}
-
-void JsonPrefStore::CommitPendingWrite() {
- if (writer_.HasPendingWrite() && !read_only_)
- writer_.DoScheduledWrite();
-}
-
-void JsonPrefStore::ReportValueChanged(const std::string& key) {
- FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
- if (!read_only_)
- writer_.ScheduleWrite(this);
+JsonPrefStore::~JsonPrefStore() {
+ CommitPendingWrite();
}
bool JsonPrefStore::SerializeData(std::string* output) {

Powered by Google App Engine
This is Rietveld 408576698