| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/dom_storage/dom_storage_context_impl.h" | 5 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 11 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "webkit/dom_storage/dom_storage_area.h" | 13 #include "webkit/dom_storage/dom_storage_area.h" |
| 14 #include "webkit/dom_storage/dom_storage_context.h" | 14 #include "webkit/dom_storage/dom_storage_context.h" |
| 15 #include "webkit/dom_storage/dom_storage_task_runner.h" | 15 #include "webkit/dom_storage/dom_storage_task_runner.h" |
| 16 | 16 |
| 17 using content::BrowserThread; | |
| 18 using content::DOMStorageContext; | |
| 19 using dom_storage::DomStorageArea; | 17 using dom_storage::DomStorageArea; |
| 20 using dom_storage::DomStorageContext; | 18 using dom_storage::DomStorageContext; |
| 21 using dom_storage::DomStorageTaskRunner; | 19 using dom_storage::DomStorageTaskRunner; |
| 22 using dom_storage::DomStorageWorkerPoolTaskRunner; | 20 using dom_storage::DomStorageWorkerPoolTaskRunner; |
| 23 | 21 |
| 22 namespace content { |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 const char kLocalStorageDirectory[] = "Local Storage"; | 25 const char kLocalStorageDirectory[] = "Local Storage"; |
| 27 const char kSessionStorageDirectory[] = "Session Storage"; | 26 const char kSessionStorageDirectory[] = "Session Storage"; |
| 28 | 27 |
| 29 void InvokeLocalStorageUsageCallbackHelper( | 28 void InvokeLocalStorageUsageCallbackHelper( |
| 30 const DOMStorageContext::GetLocalStorageUsageCallback& callback, | 29 const DOMStorageContext::GetLocalStorageUsageCallback& callback, |
| 31 const std::vector<DomStorageContext::LocalStorageUsageInfo>* infos) { | 30 const std::vector<DomStorageContext::LocalStorageUsageInfo>* infos) { |
| 32 callback.Run(*infos); | 31 callback.Run(*infos); |
| 33 } | 32 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 123 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
| 125 base::Bind(&DomStorageContext::DeleteSessionStorage, context_, | 124 base::Bind(&DomStorageContext::DeleteSessionStorage, context_, |
| 126 usage_info)); | 125 usage_info)); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void DOMStorageContextImpl::SetSaveSessionStorageOnDisk() { | 128 void DOMStorageContextImpl::SetSaveSessionStorageOnDisk() { |
| 130 DCHECK(context_); | 129 DCHECK(context_); |
| 131 context_->SetSaveSessionStorageOnDisk(); | 130 context_->SetSaveSessionStorageOnDisk(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 scoped_refptr<content::SessionStorageNamespace> | 133 scoped_refptr<SessionStorageNamespace> |
| 135 DOMStorageContextImpl::RecreateSessionStorage( | 134 DOMStorageContextImpl::RecreateSessionStorage( |
| 136 const std::string& persistent_id) { | 135 const std::string& persistent_id) { |
| 137 return scoped_refptr<content::SessionStorageNamespace>( | 136 return scoped_refptr<SessionStorageNamespace>( |
| 138 new SessionStorageNamespaceImpl(this, persistent_id)); | 137 new SessionStorageNamespaceImpl(this, persistent_id)); |
| 139 } | 138 } |
| 140 | 139 |
| 141 void DOMStorageContextImpl::StartScavengingUnusedSessionStorage() { | 140 void DOMStorageContextImpl::StartScavengingUnusedSessionStorage() { |
| 142 DCHECK(context_); | 141 DCHECK(context_); |
| 143 context_->task_runner()->PostShutdownBlockingTask( | 142 context_->task_runner()->PostShutdownBlockingTask( |
| 144 FROM_HERE, | 143 FROM_HERE, |
| 145 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 144 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
| 146 base::Bind(&DomStorageContext::StartScavengingUnusedSessionStorage, | 145 base::Bind(&DomStorageContext::StartScavengingUnusedSessionStorage, |
| 147 context_)); | 146 context_)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 163 base::Bind(&DomStorageContext::SetForceKeepSessionState, context_)); | 162 base::Bind(&DomStorageContext::SetForceKeepSessionState, context_)); |
| 164 } | 163 } |
| 165 | 164 |
| 166 void DOMStorageContextImpl::Shutdown() { | 165 void DOMStorageContextImpl::Shutdown() { |
| 167 DCHECK(context_); | 166 DCHECK(context_); |
| 168 context_->task_runner()->PostShutdownBlockingTask( | 167 context_->task_runner()->PostShutdownBlockingTask( |
| 169 FROM_HERE, | 168 FROM_HERE, |
| 170 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 169 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
| 171 base::Bind(&DomStorageContext::Shutdown, context_)); | 170 base::Bind(&DomStorageContext::Shutdown, context_)); |
| 172 } | 171 } |
| 172 |
| 173 } // namespace content |
| OLD | NEW |