| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/settings/settings_storage_cache.h" | 5 #include "chrome/browser/extensions/settings/settings_storage_cache.h" |
| 6 | 6 |
| 7 namespace extensions { | 7 namespace extensions { |
| 8 | 8 |
| 9 SettingsStorageCache::SettingsStorageCache( | 9 SettingsStorageCache::SettingsStorageCache( |
| 10 SettingsStorage* delegate) : delegate_(delegate) {} | 10 SettingsStorage* delegate) : delegate_(delegate) {} |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 SettingsStorage::ReadResult SettingsStorageCache::Get() { | 61 SettingsStorage::ReadResult SettingsStorageCache::Get() { |
| 62 ReadResult result = delegate_->Get(); | 62 ReadResult result = delegate_->Get(); |
| 63 if (!result.HasError()) { | 63 if (!result.HasError()) { |
| 64 cache_.MergeDictionary(&result.settings()); | 64 cache_.MergeDictionary(&result.settings()); |
| 65 } | 65 } |
| 66 return result; | 66 return result; |
| 67 } | 67 } |
| 68 | 68 |
| 69 SettingsStorage::WriteResult SettingsStorageCache::Set( | 69 SettingsStorage::WriteResult SettingsStorageCache::Set( |
| 70 const std::string& key, const Value& value) { | 70 WriteOptions options, const std::string& key, const Value& value) { |
| 71 WriteResult result = delegate_->Set(key, value); | 71 WriteResult result = delegate_->Set(options, key, value); |
| 72 if (!result.HasError()) { | 72 if (!result.HasError()) { |
| 73 cache_.SetWithoutPathExpansion(key, value.DeepCopy()); | 73 cache_.SetWithoutPathExpansion(key, value.DeepCopy()); |
| 74 } | 74 } |
| 75 return result; | 75 return result; |
| 76 } | 76 } |
| 77 | 77 |
| 78 SettingsStorage::WriteResult SettingsStorageCache::Set( | 78 SettingsStorage::WriteResult SettingsStorageCache::Set( |
| 79 const DictionaryValue& settings) { | 79 WriteOptions options, const DictionaryValue& settings) { |
| 80 WriteResult result = delegate_->Set(settings); | 80 WriteResult result = delegate_->Set(options, settings); |
| 81 if (result.HasError()) { | 81 if (result.HasError()) { |
| 82 return result; | 82 return result; |
| 83 } | 83 } |
| 84 | 84 |
| 85 for (SettingChangeList::const_iterator it = result.changes().begin(); | 85 for (SettingChangeList::const_iterator it = result.changes().begin(); |
| 86 it != result.changes().end(); ++it) { | 86 it != result.changes().end(); ++it) { |
| 87 DCHECK(it->new_value()); | 87 DCHECK(it->new_value()); |
| 88 cache_.SetWithoutPathExpansion(it->key(), it->new_value()->DeepCopy()); | 88 cache_.SetWithoutPathExpansion(it->key(), it->new_value()->DeepCopy()); |
| 89 } | 89 } |
| 90 | 90 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Value* cached_value; | 128 Value* cached_value; |
| 129 if (!cache_.GetWithoutPathExpansion(key, &cached_value)) { | 129 if (!cache_.GetWithoutPathExpansion(key, &cached_value)) { |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 *value = cached_value->DeepCopy(); | 133 *value = cached_value->DeepCopy(); |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace extensions | 137 } // namespace extensions |
| OLD | NEW |