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

Unified Diff: chrome/browser/extensions/settings/in_memory_settings_storage.cc

Issue 8539037: Extension Settings API: make it so that when changes received from Sync fail to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable all sync, not just outgoing Created 9 years, 1 month 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/browser/extensions/settings/in_memory_settings_storage.cc
diff --git a/chrome/browser/extensions/settings/in_memory_settings_storage.cc b/chrome/browser/extensions/settings/in_memory_settings_storage.cc
deleted file mode 100644
index d017a692d598a9dbb6c4ca5967b862e081412d85..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/settings/in_memory_settings_storage.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/settings/in_memory_settings_storage.h"
-
-#include "base/logging.h"
-
-namespace extensions {
-
-namespace {
-
-std::vector<std::string> CreateVector(const std::string& string) {
- std::vector<std::string> strings;
- strings.push_back(string);
- return strings;
-}
-
-} // namespace
-
-SettingsStorage::ReadResult InMemorySettingsStorage::Get(
- const std::string& key) {
- return Get(CreateVector(key));
-}
-
-SettingsStorage::ReadResult InMemorySettingsStorage::Get(
- const std::vector<std::string>& keys) {
- DictionaryValue* settings = new DictionaryValue();
- for (std::vector<std::string>::const_iterator it = keys.begin();
- it != keys.end(); ++it) {
- Value* value = NULL;
- if (storage_.GetWithoutPathExpansion(*it, &value)) {
- settings->SetWithoutPathExpansion(*it, value->DeepCopy());
- }
- }
- return ReadResult(settings);
-}
-
-SettingsStorage::ReadResult InMemorySettingsStorage::Get() {
- return ReadResult(storage_.DeepCopy());
-}
-
-SettingsStorage::WriteResult InMemorySettingsStorage::Set(
- const std::string& key, const Value& value) {
- DictionaryValue settings;
- settings.SetWithoutPathExpansion(key, value.DeepCopy());
- return Set(settings);
-}
-
-SettingsStorage::WriteResult InMemorySettingsStorage::Set(
- const DictionaryValue& settings) {
- scoped_ptr<SettingChangeList> changes(
- new SettingChangeList());
- for (DictionaryValue::Iterator it(settings); it.HasNext(); it.Advance()) {
- Value* old_value = NULL;
- storage_.GetWithoutPathExpansion(it.key(), &old_value);
- if (!old_value || !old_value->Equals(&it.value())) {
- changes->push_back(
- SettingChange(
- it.key(),
- old_value ? old_value->DeepCopy() : old_value,
- it.value().DeepCopy()));
- storage_.SetWithoutPathExpansion(it.key(), it.value().DeepCopy());
- }
- }
- return WriteResult(changes.release());
-}
-
-SettingsStorage::WriteResult InMemorySettingsStorage::Remove(
- const std::string& key) {
- return Remove(CreateVector(key));
-}
-
-SettingsStorage::WriteResult InMemorySettingsStorage::Remove(
- const std::vector<std::string>& keys) {
- scoped_ptr<SettingChangeList> changes(
- new SettingChangeList());
- for (std::vector<std::string>::const_iterator it = keys.begin();
- it != keys.end(); ++it) {
- Value* old_value = NULL;
- if (storage_.RemoveWithoutPathExpansion(*it, &old_value)) {
- changes->push_back(SettingChange(*it, old_value, NULL));
- }
- }
- return WriteResult(changes.release());
-}
-
-SettingsStorage::WriteResult
-InMemorySettingsStorage::Clear() {
- std::vector<std::string> keys;
- for (DictionaryValue::Iterator it(storage_); it.HasNext(); it.Advance()) {
- keys.push_back(it.key());
- }
- return Remove(keys);
-}
-
-} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698