Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / api / storage / leveldb_settings_storage_factory.cc
blobef7d302bd516a00437417fe928c621def4e9a587
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 // Statistics are logged to UMA with this string as part of histogram name. They
16 // can all be found under Extensions.Database.Open.<client>. Changing this needs
17 // to synchronize with histograms.xml, AND will also become incompatible with
18 // older browsers still reporting the previous values.
19 const char kDatabaseUMAClientName[] = "Settings";
21 base::FilePath GetDatabasePath(const base::FilePath& base_path,
22 const std::string& extension_id) {
23 return base_path.AppendASCII(extension_id);
26 } // namespace
28 ValueStore* LeveldbSettingsStorageFactory::Create(
29 const base::FilePath& base_path,
30 const std::string& extension_id) {
31 return new LeveldbValueStore(kDatabaseUMAClientName,
32 GetDatabasePath(base_path, extension_id));
35 void LeveldbSettingsStorageFactory::DeleteDatabaseIfExists(
36 const base::FilePath& base_path,
37 const std::string& extension_id) {
38 base::FilePath path = GetDatabasePath(base_path, extension_id);
39 if (base::PathExists(path))
40 base::DeleteFile(path, true /* recursive */);
43 } // namespace extensions