OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/pref_service.h" | 5 #include "chrome/common/pref_service.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
13 #include "base/thread.h" | |
14 #include "build/build_config.h" | 13 #include "build/build_config.h" |
15 #include "chrome/common/json_value_serializer.h" | 14 #include "chrome/common/json_value_serializer.h" |
16 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
17 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 // A helper function for RegisterLocalized*Pref that creates a Value* based on | 20 // A helper function for RegisterLocalized*Pref that creates a Value* based on |
22 // the string value in the locale dll. Because we control the values in a | 21 // the string value in the locale dll. Because we control the values in a |
23 // locale dll, this should always return a Value of the appropriate type. | 22 // locale dll, this should always return a Value of the appropriate type. |
(...skipping 30 matching lines...) Expand all Loading... |
54 NOTREACHED() << | 53 NOTREACHED() << |
55 "list and dictionary types can not have default locale values"; | 54 "list and dictionary types can not have default locale values"; |
56 } | 55 } |
57 } | 56 } |
58 NOTREACHED(); | 57 NOTREACHED(); |
59 return Value::CreateNullValue(); | 58 return Value::CreateNullValue(); |
60 } | 59 } |
61 | 60 |
62 } // namespace | 61 } // namespace |
63 | 62 |
64 PrefService::PrefService(const FilePath& pref_filename, | 63 PrefService::PrefService(const FilePath& pref_filename) |
65 const base::Thread* backend_thread) | |
66 : persistent_(new DictionaryValue), | 64 : persistent_(new DictionaryValue), |
67 transient_(new DictionaryValue), | 65 transient_(new DictionaryValue), |
68 writer_(pref_filename, backend_thread) { | 66 writer_(pref_filename) { |
69 ReloadPersistentPrefs(); | 67 ReloadPersistentPrefs(); |
70 } | 68 } |
71 | 69 |
72 PrefService::~PrefService() { | 70 PrefService::~PrefService() { |
73 DCHECK(CalledOnValidThread()); | 71 DCHECK(CalledOnValidThread()); |
74 | 72 |
75 // Verify that there are no pref observers when we shut down. | 73 // Verify that there are no pref observers when we shut down. |
76 for (PrefObserverMap::iterator it = pref_observers_.begin(); | 74 for (PrefObserverMap::iterator it = pref_observers_.begin(); |
77 it != pref_observers_.end(); ++it) { | 75 it != pref_observers_.end(); ++it) { |
78 NotificationObserverList::Iterator obs_iterator(*(it->second)); | 76 NotificationObserverList::Iterator obs_iterator(*(it->second)); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 } | 695 } |
698 | 696 |
699 // Pref not found, just return the app default. | 697 // Pref not found, just return the app default. |
700 return default_value_.get(); | 698 return default_value_.get(); |
701 } | 699 } |
702 | 700 |
703 bool PrefService::Preference::IsDefaultValue() const { | 701 bool PrefService::Preference::IsDefaultValue() const { |
704 DCHECK(default_value_.get()); | 702 DCHECK(default_value_.get()); |
705 return default_value_->Equals(GetValue()); | 703 return default_value_->Equals(GetValue()); |
706 } | 704 } |
OLD | NEW |