| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/in_process_webkit/dom_storage_context.h" | 5 #include "content/browser/in_process_webkit/dom_storage_context.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (special_storage_policy_->IsStorageProtected(origin)) | 191 if (special_storage_policy_->IsStorageProtected(origin)) |
| 192 continue; | 192 continue; |
| 193 | 193 |
| 194 file_util::FileEnumerator::FindInfo find_info; | 194 file_util::FileEnumerator::FindInfo find_info; |
| 195 file_enumerator.GetFindInfo(&find_info); | 195 file_enumerator.GetFindInfo(&find_info); |
| 196 if (file_util::HasFileBeenModifiedSince(find_info, cutoff)) | 196 if (file_util::HasFileBeenModifiedSince(find_info, cutoff)) |
| 197 file_util::Delete(path, false); | 197 file_util::Delete(path, false); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 void DOMStorageContext::DeleteSessionOnlyData() { |
| 202 // Make sure that we don't delete a database that's currently being accessed |
| 203 // by unloading all of the databases temporarily. |
| 204 PurgeMemory(); |
| 205 |
| 206 file_util::FileEnumerator file_enumerator( |
| 207 data_path_.Append(kLocalStorageDirectory), false, |
| 208 file_util::FileEnumerator::FILES); |
| 209 for (FilePath path = file_enumerator.Next(); !path.value().empty(); |
| 210 path = file_enumerator.Next()) { |
| 211 GURL origin(WebSecurityOrigin::createFromDatabaseIdentifier( |
| 212 webkit_glue::FilePathToWebString(path.BaseName())).toString()); |
| 213 if (!special_storage_policy_->IsStorageSessionOnly(origin)) |
| 214 continue; |
| 215 if (special_storage_policy_->IsStorageProtected(origin)) |
| 216 continue; |
| 217 |
| 218 file_util::Delete(path, false); |
| 219 } |
| 220 } |
| 221 |
| 201 void DOMStorageContext::DeleteLocalStorageFile(const FilePath& file_path) { | 222 void DOMStorageContext::DeleteLocalStorageFile(const FilePath& file_path) { |
| 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 203 | 224 |
| 204 // Make sure that we don't delete a database that's currently being accessed | 225 // Make sure that we don't delete a database that's currently being accessed |
| 205 // by unloading all of the databases temporarily. | 226 // by unloading all of the databases temporarily. |
| 206 // TODO(bulach): both this method and DeleteDataModifiedSince could purge | 227 // TODO(bulach): both this method and DeleteDataModifiedSince could purge |
| 207 // only the memory used by the specific file instead of all memory at once. | 228 // only the memory used by the specific file instead of all memory at once. |
| 208 // See http://crbug.com/32000 | 229 // See http://crbug.com/32000 |
| 209 PurgeMemory(); | 230 PurgeMemory(); |
| 210 file_util::Delete(file_path, false); | 231 file_util::Delete(file_path, false); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 291 } |
| 271 | 292 |
| 272 FilePath DOMStorageContext::GetLocalStorageFilePath( | 293 FilePath DOMStorageContext::GetLocalStorageFilePath( |
| 273 const string16& origin_id) const { | 294 const string16& origin_id) const { |
| 274 FilePath storageDir = data_path_.Append( | 295 FilePath storageDir = data_path_.Append( |
| 275 DOMStorageContext::kLocalStorageDirectory); | 296 DOMStorageContext::kLocalStorageDirectory); |
| 276 FilePath::StringType id = | 297 FilePath::StringType id = |
| 277 webkit_glue::WebStringToFilePathString(origin_id); | 298 webkit_glue::WebStringToFilePathString(origin_id); |
| 278 return storageDir.Append(id.append(kLocalStorageExtension)); | 299 return storageDir.Append(id.append(kLocalStorageExtension)); |
| 279 } | 300 } |
| OLD | NEW |