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

Unified Diff: webkit/dom_storage/dom_storage_context.cc

Issue 9999021: Don't hardcode the "Local Storage" directory name in DomStorageContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 months 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: webkit/dom_storage/dom_storage_context.cc
diff --git a/webkit/dom_storage/dom_storage_context.cc b/webkit/dom_storage/dom_storage_context.cc
index 78363d437469a597abc6b280edc309d819bdd085..1ae8e1dfd24ba0d60307c87f5edd3e6f25959d7f 100644
--- a/webkit/dom_storage/dom_storage_context.cc
+++ b/webkit/dom_storage/dom_storage_context.cc
@@ -17,6 +17,12 @@
using file_util::FileEnumerator;
+namespace {
+
+const char kLocalStorageDirectory[] = "Local Storage";
+
+} // namespace
+
namespace dom_storage {
DomStorageContext::UsageInfo::UsageInfo() : data_size(0) {}
@@ -48,15 +54,16 @@ DomStorageNamespace* DomStorageContext::GetStorageNamespace(
StorageNamespaceMap::iterator found = namespaces_.find(namespace_id);
if (found == namespaces_.end()) {
if (namespace_id == kLocalStorageNamespaceId) {
- if (!directory_.empty()) {
- if (!file_util::CreateDirectory(directory_)) {
+ FilePath target_directory = GetLocalStorageDirectory();
+ if (!target_directory.empty()) {
+ if (!file_util::CreateDirectory(target_directory)) {
LOG(ERROR) << "Failed to create 'Local Storage' directory,"
" falling back to in-memory only.";
- directory_ = FilePath();
+ target_directory = FilePath();
}
}
DomStorageNamespace* local =
- new DomStorageNamespace(directory_, task_runner_);
+ new DomStorageNamespace(target_directory, task_runner_);
namespaces_[kLocalStorageNamespaceId] = local;
return local;
}
@@ -65,11 +72,18 @@ DomStorageNamespace* DomStorageContext::GetStorageNamespace(
return found->second;
}
+FilePath DomStorageContext::GetLocalStorageDirectory() {
+ if (directory_.empty())
+ return FilePath();
+ return directory_.AppendASCII(kLocalStorageDirectory);
+}
+
void DomStorageContext::GetUsageInfo(std::vector<UsageInfo>* infos,
bool include_file_info) {
if (directory_.empty())
return;
- FileEnumerator enumerator(directory_, false, FileEnumerator::FILES);
+ FileEnumerator enumerator(GetLocalStorageDirectory(), false,
+ FileEnumerator::FILES);
for (FilePath path = enumerator.Next(); !path.empty();
path = enumerator.Next()) {
if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) {
@@ -225,7 +239,7 @@ void DomStorageContext::ClearLocalStateInCommitSequence() {
continue;
const bool kNotRecursive = false;
- FilePath database_file_path = directory_.Append(
+ FilePath database_file_path = GetLocalStorageDirectory().Append(
DomStorageArea::DatabaseFileNameFromOrigin(origin));
file_util::Delete(database_file_path, kNotRecursive);
file_util::Delete(

Powered by Google App Engine
This is Rietveld 408576698