Chromium Code Reviews| 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/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 12 #include "webkit/database/database_util.h" | 12 #include "webkit/database/database_util.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 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 using content::DOMStorageContext; | 19 using content::DOMStorageContext; |
| 20 using dom_storage::DomStorageArea; | 20 using dom_storage::DomStorageArea; |
| 21 using dom_storage::DomStorageContext; | 21 using dom_storage::DomStorageContext; |
| 22 using dom_storage::DomStorageTaskRunner; | 22 using dom_storage::DomStorageTaskRunner; |
| 23 using dom_storage::DomStorageWorkerPoolTaskRunner; | 23 using dom_storage::DomStorageWorkerPoolTaskRunner; |
| 24 using webkit_database::DatabaseUtil; | 24 using webkit_database::DatabaseUtil; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const char kLocalStorageDirectory[] = "Local Storage"; | 28 const char kLocalStorageDirectory[] = "Local Storage"; |
| 29 | 29 |
| 30 // TODO(michaeln): Fix the content layer api, FilePaths and | 30 // TODO(michaeln): Fix the content layer api, FilePaths and |
|
michaeln
2012/05/31 22:49:07
along the lines of this comment
| |
| 31 // string16 origin_ids are just wrong. Then get rid of | 31 // string16 origin_ids are just wrong. Then get rid of |
| 32 // this conversion non-sense. Most of the includes are just | 32 // this conversion non-sense. Most of the includes are just |
| 33 // to support that non-sense. | 33 // to support that non-sense. |
| 34 | 34 |
| 35 GURL OriginIdToGURL(const string16& origin_id) { | 35 GURL OriginIdToGURL(const string16& origin_id) { |
| 36 return DatabaseUtil::GetOriginFromIdentifier(origin_id); | 36 return DatabaseUtil::GetOriginFromIdentifier(origin_id); |
| 37 } | 37 } |
| 38 | 38 |
| 39 FilePath OriginToFullFilePath(const FilePath& directory, | 39 FilePath OriginToFullFilePath(const FilePath& directory, |
| 40 const GURL& origin) { | 40 const GURL& origin) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 | 126 |
| 127 void DOMStorageContextImpl::DeleteLocalStorageFile(const FilePath& file_path) { | 127 void DOMStorageContextImpl::DeleteLocalStorageFile(const FilePath& file_path) { |
| 128 DCHECK(context_); | 128 DCHECK(context_); |
| 129 context_->task_runner()->PostShutdownBlockingTask( | 129 context_->task_runner()->PostShutdownBlockingTask( |
| 130 FROM_HERE, | 130 FROM_HERE, |
| 131 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 131 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
| 132 base::Bind(&DomStorageContext::DeleteOrigin, context_, | 132 base::Bind(&DomStorageContext::DeleteOrigin, context_, |
| 133 FilePathToOrigin(file_path))); | 133 FilePathToOrigin(file_path))); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void DOMStorageContextImpl::DeleteDataModifiedSince(const base::Time& cutoff) { | |
| 137 DCHECK(context_); | |
| 138 context_->task_runner()->PostShutdownBlockingTask( | |
| 139 FROM_HERE, | |
| 140 DomStorageTaskRunner::PRIMARY_SEQUENCE, | |
| 141 base::Bind(&DomStorageContext::DeleteDataModifiedSince, context_, | |
| 142 cutoff)); | |
| 143 } | |
| 144 | |
| 145 void DOMStorageContextImpl::PurgeMemory() { | 136 void DOMStorageContextImpl::PurgeMemory() { |
| 146 DCHECK(context_); | 137 DCHECK(context_); |
| 147 context_->task_runner()->PostShutdownBlockingTask( | 138 context_->task_runner()->PostShutdownBlockingTask( |
| 148 FROM_HERE, | 139 FROM_HERE, |
| 149 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 140 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
| 150 base::Bind(&DomStorageContext::PurgeMemory, context_)); | 141 base::Bind(&DomStorageContext::PurgeMemory, context_)); |
| 151 } | 142 } |
| 152 | 143 |
| 153 void DOMStorageContextImpl::SetClearLocalState(bool clear_local_state) { | 144 void DOMStorageContextImpl::SetClearLocalState(bool clear_local_state) { |
| 154 DCHECK(context_); | 145 DCHECK(context_); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 178 int64 DOMStorageContextImpl::LeakyCloneSessionStorage( | 169 int64 DOMStorageContextImpl::LeakyCloneSessionStorage( |
| 179 int64 existing_namespace_id) { | 170 int64 existing_namespace_id) { |
| 180 DCHECK(context_); | 171 DCHECK(context_); |
| 181 int64 clone_id = context_->AllocateSessionId(); | 172 int64 clone_id = context_->AllocateSessionId(); |
| 182 context_->task_runner()->PostTask( | 173 context_->task_runner()->PostTask( |
| 183 FROM_HERE, | 174 FROM_HERE, |
| 184 base::Bind(&DomStorageContext::CloneSessionNamespace, context_, | 175 base::Bind(&DomStorageContext::CloneSessionNamespace, context_, |
| 185 existing_namespace_id, clone_id)); | 176 existing_namespace_id, clone_id)); |
| 186 return clone_id; | 177 return clone_id; |
| 187 } | 178 } |
| OLD | NEW |