diff options
author | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 02:12:06 +0000 |
---|---|---|
committer | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 02:12:06 +0000 |
commit | 87474c1a9db80986fab7aeea49b72dd3bb74f159 (patch) | |
tree | fa3bf3d067bc0c557cb69da55de8e6eef21fd590 /chrome/browser/extensions/extension_settings_storage_cache.cc | |
parent | 7baf2a59aed93553893350b24660c931c97a5796 (diff) | |
download | chromium_src-87474c1a9db80986fab7aeea49b72dd3bb74f159.zip chromium_src-87474c1a9db80986fab7aeea49b72dd3bb74f159.tar.gz chromium_src-87474c1a9db80986fab7aeea49b72dd3bb74f159.tar.bz2 |
Add onChanged events to the extension settings API, both from sync and between
split mode background pages.
BUG=97545
TEST=Updated ExtensionSettingsStorageUnittest, ExtensionSettingsSyncUnittest, ExtensionSettingsApitest
Review URL: http://codereview.chromium.org/8177022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_settings_storage_cache.cc')
-rw-r--r-- | chrome/browser/extensions/extension_settings_storage_cache.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/chrome/browser/extensions/extension_settings_storage_cache.cc b/chrome/browser/extensions/extension_settings_storage_cache.cc index f20f068..2df99ed 100644 --- a/chrome/browser/extensions/extension_settings_storage_cache.cc +++ b/chrome/browser/extensions/extension_settings_storage_cache.cc @@ -15,7 +15,7 @@ ExtensionSettingsStorage::Result ExtensionSettingsStorageCache::Get( if (GetFromCache(key, &value)) { DictionaryValue* settings = new DictionaryValue(); settings->SetWithoutPathExpansion(key, value); - return Result(settings, NULL); + return Result(settings, NULL, NULL); } Result result = delegate_->Get(key); @@ -43,7 +43,7 @@ ExtensionSettingsStorage::Result ExtensionSettingsStorageCache::Get( } if (missing_keys.empty()) { - return Result(from_cache.release(), NULL); + return Result(from_cache.release(), NULL, NULL); } Result result = delegate_->Get(keys); @@ -52,8 +52,10 @@ ExtensionSettingsStorage::Result ExtensionSettingsStorageCache::Get( } cache_.MergeDictionary(result.GetSettings()); - result.GetSettings()->MergeDictionary(from_cache.get()); - return result; + + DictionaryValue* settings_with_cache = result.GetSettings()->DeepCopy(); + settings_with_cache->MergeDictionary(from_cache.get()); + return Result(settings_with_cache, NULL, NULL); } ExtensionSettingsStorage::Result ExtensionSettingsStorageCache::Get() { @@ -80,9 +82,9 @@ ExtensionSettingsStorage::Result ExtensionSettingsStorageCache::Set( return result; } - std::set<std::string>* changed_keys = result.GetChangedKeys(); + const std::set<std::string>* changed_keys = result.GetChangedKeys(); DCHECK(changed_keys); - for (std::set<std::string>::iterator it = changed_keys->begin(); + for (std::set<std::string>::const_iterator it = changed_keys->begin(); it != changed_keys->end(); ++it) { Value* new_value = NULL; result.GetSettings()->GetWithoutPathExpansion(*it, &new_value); @@ -108,9 +110,9 @@ ExtensionSettingsStorage::Result ExtensionSettingsStorageCache::Remove( return result; } - std::set<std::string>* changed_keys = result.GetChangedKeys(); + const std::set<std::string>* changed_keys = result.GetChangedKeys(); DCHECK(changed_keys); - for (std::set<std::string>::iterator it = changed_keys->begin(); + for (std::set<std::string>::const_iterator it = changed_keys->begin(); it != changed_keys->end(); ++it) { cache_.RemoveWithoutPathExpansion(*it, NULL); } |