| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/browser/value_store/legacy_value_store_factory.h" | 5 #include "extensions/browser/value_store/legacy_value_store_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 bool LegacyValueStoreFactory::RulesDBExists() const { | 162 bool LegacyValueStoreFactory::RulesDBExists() const { |
| 163 return ValidDBExists(GetRulesDBPath()); | 163 return ValidDBExists(GetRulesDBPath()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool LegacyValueStoreFactory::StateDBExists() const { | 166 bool LegacyValueStoreFactory::StateDBExists() const { |
| 167 return ValidDBExists(GetStateDBPath()); | 167 return ValidDBExists(GetStateDBPath()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateRulesStore() { | 170 std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateRulesStore() { |
| 171 return base::WrapUnique( | 171 return base::MakeUnique<LeveldbValueStore>(kRulesDatabaseUMAClientName, |
| 172 new LeveldbValueStore(kRulesDatabaseUMAClientName, GetRulesDBPath())); | 172 GetRulesDBPath()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateStateStore() { | 175 std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateStateStore() { |
| 176 return base::WrapUnique( | 176 return base::MakeUnique<LeveldbValueStore>(kStateDatabaseUMAClientName, |
| 177 new LeveldbValueStore(kStateDatabaseUMAClientName, GetStateDBPath())); | 177 GetStateDBPath()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateSettingsStore( | 180 std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateSettingsStore( |
| 181 settings_namespace::Namespace settings_namespace, | 181 settings_namespace::Namespace settings_namespace, |
| 182 ModelType model_type, | 182 ModelType model_type, |
| 183 const ExtensionId& extension_id) { | 183 const ExtensionId& extension_id) { |
| 184 const ModelSettings* settings_root = | 184 const ModelSettings* settings_root = |
| 185 GetSettingsRoot(settings_namespace).GetModel(model_type); | 185 GetSettingsRoot(settings_namespace).GetModel(model_type); |
| 186 DCHECK(settings_root != nullptr); | 186 DCHECK(settings_root != nullptr); |
| 187 return base::WrapUnique(new LeveldbValueStore( | 187 return base::MakeUnique<LeveldbValueStore>( |
| 188 kSettingsDatabaseUMAClientName, settings_root->GetDBPath(extension_id))); | 188 kSettingsDatabaseUMAClientName, settings_root->GetDBPath(extension_id)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void LegacyValueStoreFactory::DeleteSettings( | 191 void LegacyValueStoreFactory::DeleteSettings( |
| 192 settings_namespace::Namespace settings_namespace, | 192 settings_namespace::Namespace settings_namespace, |
| 193 ModelType model_type, | 193 ModelType model_type, |
| 194 const ExtensionId& extension_id) { | 194 const ExtensionId& extension_id) { |
| 195 // TODO(cmumford): Verify that we always need to be called on FILE thread. | 195 // TODO(cmumford): Verify that we always need to be called on FILE thread. |
| 196 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 196 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 197 ModelSettings* model_settings = | 197 ModelSettings* model_settings = |
| 198 GetSettingsRoot(settings_namespace).GetModel(model_type); | 198 GetSettingsRoot(settings_namespace).GetModel(model_type); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 base::FilePath LegacyValueStoreFactory::GetRulesDBPath() const { | 256 base::FilePath LegacyValueStoreFactory::GetRulesDBPath() const { |
| 257 return profile_path_.AppendASCII(kRulesStoreName); | 257 return profile_path_.AppendASCII(kRulesStoreName); |
| 258 } | 258 } |
| 259 | 259 |
| 260 base::FilePath LegacyValueStoreFactory::GetStateDBPath() const { | 260 base::FilePath LegacyValueStoreFactory::GetStateDBPath() const { |
| 261 return profile_path_.AppendASCII(kStateStoreName); | 261 return profile_path_.AppendASCII(kStateStoreName); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace extensions | 264 } // namespace extensions |
| OLD | NEW |