Chromium Code Reviews| Index: content/browser/in_process_webkit/dom_storage_namespace.cc |
| diff --git a/content/browser/in_process_webkit/dom_storage_namespace.cc b/content/browser/in_process_webkit/dom_storage_namespace.cc |
| index 508786f1aaf58d7d8ba23b01793775028de8a052..15704bfcd7596ca86b166434ba2792e9b5f8c803 100644 |
| --- a/content/browser/in_process_webkit/dom_storage_namespace.cc |
| +++ b/content/browser/in_process_webkit/dom_storage_namespace.cc |
| @@ -21,24 +21,29 @@ DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace( |
| DOMStorageContext* dom_storage_context, const FilePath& data_dir_path) { |
| int64 id = kLocalStorageNamespaceId; |
| DCHECK(!dom_storage_context->GetStorageNamespace(id, false)); |
| - return new DOMStorageNamespace(dom_storage_context, id, |
| + return new DOMStorageNamespace(dom_storage_context, id, FilePath(""), |
| webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_LOCAL); |
| } |
| /* static */ |
| DOMStorageNamespace* DOMStorageNamespace::CreateSessionStorageNamespace( |
| - DOMStorageContext* dom_storage_context, int64 id) { |
| + DOMStorageContext* dom_storage_context, const FilePath& data_dir_path, |
| + int64 id) { |
| DCHECK(!dom_storage_context->GetStorageNamespace(id, false)); |
| - return new DOMStorageNamespace(dom_storage_context, id, WebString(), |
| - DOM_STORAGE_SESSION); |
| + return new DOMStorageNamespace( |
| + dom_storage_context, id, data_dir_path.BaseName(), |
| + webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_SESSION); |
| } |
| -DOMStorageNamespace::DOMStorageNamespace(DOMStorageContext* dom_storage_context, |
| - int64 id, |
| - const WebString& data_dir_path, |
| - DOMStorageType dom_storage_type) |
| +DOMStorageNamespace::DOMStorageNamespace( |
| + DOMStorageContext* dom_storage_context, |
| + int64 id, |
| + const FilePath& session_storage_directory, |
| + const WebString& data_dir_path, |
| + DOMStorageType dom_storage_type) |
| : dom_storage_context_(dom_storage_context), |
| id_(id), |
| + session_storage_directory_(session_storage_directory), |
| data_dir_path_(data_dir_path), |
| dom_storage_type_(dom_storage_type) { |
| DCHECK(dom_storage_context_); |
| @@ -70,10 +75,12 @@ DOMStorageArea* DOMStorageNamespace::GetStorageArea(const string16& origin) { |
| } |
| DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) { |
| + // FIXME-before-landing: how can we copy session storage namespaces now? |
| DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION); |
| DCHECK(!dom_storage_context_->GetStorageNamespace(id, false)); |
| DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace( |
| - dom_storage_context_, id, data_dir_path_, dom_storage_type_); |
| + dom_storage_context_, id, session_storage_directory_, data_dir_path_, |
| + dom_storage_type_); |
| // If we haven't used the namespace yet, there's nothing to copy. |
| if (storage_namespace_.get()) |
| new_storage_namespace->storage_namespace_.reset(storage_namespace_->copy()); |
| @@ -81,7 +88,8 @@ DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) { |
| } |
| void DOMStorageNamespace::PurgeMemory() { |
| - DCHECK(dom_storage_type_ == DOM_STORAGE_LOCAL); |
| + // FIXME-before-landing: how do we purge session storage? |
| + //DCHECK(dom_storage_type_ == DOM_STORAGE_LOCAL); |
| for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin()); |
| iter != origin_to_storage_area_.end(); ++iter) |
| iter->second->PurgeMemory(); |
| @@ -98,12 +106,10 @@ void DOMStorageNamespace::CreateWebStorageNamespaceIfNecessary() { |
| if (storage_namespace_.get()) |
| return; |
| - if (dom_storage_type_ == DOM_STORAGE_LOCAL) { |
| - storage_namespace_.reset( |
| - WebStorageNamespace::createLocalStorageNamespace(data_dir_path_, |
| - WebStorageNamespace::m_localStorageQuota)); |
| - } else { |
| - storage_namespace_.reset(WebStorageNamespace::createSessionStorageNamespace( |
| - WebStorageNamespace::m_sessionStorageQuota)); |
| - } |
| + // Note: from WebKit point of view, also sessionStorage is localStorage, since |
| + // we want to save it on disk. |
|
michaeln
2011/12/13 20:40:03
So we won't be using the SessionStorage stuff in w
|
| + storage_namespace_.reset( |
| + WebStorageNamespace::createLocalStorageNamespace( |
| + data_dir_path_, |
| + WebStorageNamespace::m_localStorageQuota)); |
| } |