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/testing_settings_storage.h" | 5 #include "chrome/browser/extensions/settings/testing_settings_storage.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace extensions { | 9 namespace extensions { |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 SettingsStorage::ReadResult TestingSettingsStorage::Get() { | 62 SettingsStorage::ReadResult TestingSettingsStorage::Get() { |
63 if (fail_all_requests_) { | 63 if (fail_all_requests_) { |
64 return ReadResultError(); | 64 return ReadResultError(); |
65 } | 65 } |
66 return ReadResult(storage_.DeepCopy()); | 66 return ReadResult(storage_.DeepCopy()); |
67 } | 67 } |
68 | 68 |
69 SettingsStorage::WriteResult TestingSettingsStorage::Set( | 69 SettingsStorage::WriteResult TestingSettingsStorage::Set( |
70 const std::string& key, const Value& value) { | 70 WriteOptions options, const std::string& key, const Value& value) { |
71 DictionaryValue settings; | 71 DictionaryValue settings; |
72 settings.SetWithoutPathExpansion(key, value.DeepCopy()); | 72 settings.SetWithoutPathExpansion(key, value.DeepCopy()); |
73 return Set(settings); | 73 return Set(options, settings); |
74 } | 74 } |
75 | 75 |
76 SettingsStorage::WriteResult TestingSettingsStorage::Set( | 76 SettingsStorage::WriteResult TestingSettingsStorage::Set( |
77 const DictionaryValue& settings) { | 77 WriteOptions options, const DictionaryValue& settings) { |
78 if (fail_all_requests_) { | 78 if (fail_all_requests_) { |
79 return WriteResultError(); | 79 return WriteResultError(); |
80 } | 80 } |
81 | 81 |
82 scoped_ptr<SettingChangeList> changes(new SettingChangeList()); | 82 scoped_ptr<SettingChangeList> changes(new SettingChangeList()); |
83 for (DictionaryValue::Iterator it(settings); it.HasNext(); it.Advance()) { | 83 for (DictionaryValue::Iterator it(settings); it.HasNext(); it.Advance()) { |
84 Value* old_value = NULL; | 84 Value* old_value = NULL; |
85 storage_.GetWithoutPathExpansion(it.key(), &old_value); | 85 storage_.GetWithoutPathExpansion(it.key(), &old_value); |
86 if (!old_value || !old_value->Equals(&it.value())) { | 86 if (!old_value || !old_value->Equals(&it.value())) { |
87 changes->push_back( | 87 changes->push_back( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 std::vector<std::string> keys; | 126 std::vector<std::string> keys; |
127 for (DictionaryValue::Iterator it(storage_); it.HasNext(); it.Advance()) { | 127 for (DictionaryValue::Iterator it(storage_); it.HasNext(); it.Advance()) { |
128 keys.push_back(it.key()); | 128 keys.push_back(it.key()); |
129 } | 129 } |
130 return Remove(keys); | 130 return Remove(keys); |
131 } | 131 } |
132 | 132 |
133 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |