Add testing/scripts/OWNERS
[chromium-blink-merge.git] / extensions / browser / api / storage / leveldb_settings_storage_factory.cc
blobf4d9884ec5ae4b65b50deab684c72cb7a2635057
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/browser/api/storage/leveldb_settings_storage_factory.h"
7 #include "base/files/file_util.h"
8 #include "base/logging.h"
9 #include "extensions/browser/value_store/leveldb_value_store.h"
11 namespace extensions {
13 namespace {
15 base::FilePath GetDatabasePath(const base::FilePath& base_path,
16 const std::string& extension_id) {
17 return base_path.AppendASCII(extension_id);
20 } // namespace
22 ValueStore* LeveldbSettingsStorageFactory::Create(
23 const base::FilePath& base_path,
24 const std::string& extension_id) {
25 return new LeveldbValueStore(GetDatabasePath(base_path, extension_id));
28 void LeveldbSettingsStorageFactory::DeleteDatabaseIfExists(
29 const base::FilePath& base_path,
30 const std::string& extension_id) {
31 base::FilePath path = GetDatabasePath(base_path, extension_id);
32 if (base::PathExists(path))
33 base::DeleteFile(path, true /* recursive */);
36 } // namespace extensions