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

Side by Side Diff: webkit/dom_storage/dom_storage_context.cc

Issue 10413072: Teaching BrowsingDataRemover how to delete application data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "webkit/dom_storage/dom_storage_context.h" 5 #include "webkit/dom_storage/dom_storage_context.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_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 void DomStorageContext::DeleteOrigin(const GURL& origin) { 92 void DomStorageContext::DeleteOrigin(const GURL& origin) {
93 DCHECK(!is_shutdown_); 93 DCHECK(!is_shutdown_);
94 DomStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId); 94 DomStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId);
95 local->DeleteOrigin(origin); 95 local->DeleteOrigin(origin);
96 } 96 }
97 97
98 void DomStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) { 98 void DomStorageContext::DeleteDataModifiedSince(
99 const base::Time& cutoff,
100 int origin_set_mask) {
99 std::vector<UsageInfo> infos; 101 std::vector<UsageInfo> infos;
100 const bool kIncludeFileInfo = true; 102 const bool kIncludeFileInfo = true;
101 GetUsageInfo(&infos, kIncludeFileInfo); 103 GetUsageInfo(&infos, kIncludeFileInfo);
102 for (size_t i = 0; i < infos.size(); ++i) { 104 for (size_t i = 0; i < infos.size(); ++i) {
103 if (infos[i].last_modified > cutoff) { 105 if (infos[i].last_modified > cutoff) {
104 if (!special_storage_policy_ || 106 if (!special_storage_policy_ ||
105 !special_storage_policy_->IsStorageProtected(infos[i].origin)) { 107 // Skip packaged apps and extensions (non-websafe origin) unless
108 // EXTENSION is set.
109 ((origin_set_mask & quota::SpecialStoragePolicy::EXTENSION) &&
110 infos[i].origin.SchemeIs("chrome-extension")) ||
111 // Skip the open web (unprotected and websafe origins) unless
112 // UNPROTECTED_WEB is set.
113 ((origin_set_mask & quota::SpecialStoragePolicy::UNPROTECTED_WEB) &&
114 !infos[i].origin.SchemeIs("chrome-extension") &&
115 !special_storage_policy_->IsStorageProtected(infos[i].origin)) ||
116 // Skip hosted applications (protected and websafe origins) unless
117 // PROTECTED_WEB is set.
118 ((origin_set_mask & quota::SpecialStoragePolicy::PROTECTED_WEB) &&
119 !infos[i].origin.SchemeIs("chrome-extension") &&
120 special_storage_policy_->IsStorageProtected(infos[i].origin))) {
106 DeleteOrigin(infos[i].origin); 121 DeleteOrigin(infos[i].origin);
107 } 122 }
108 } 123 }
109 } 124 }
110 } 125 }
111 126
112 void DomStorageContext::PurgeMemory() { 127 void DomStorageContext::PurgeMemory() {
113 // We can only purge memory from the local storage namespace 128 // We can only purge memory from the local storage namespace
114 // which is backed by disk. 129 // which is backed by disk.
115 StorageNamespaceMap::iterator found = 130 StorageNamespaceMap::iterator found =
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 FilePath database_file_path = localstorage_directory_.Append( 246 FilePath database_file_path = localstorage_directory_.Append(
232 DomStorageArea::DatabaseFileNameFromOrigin(origin)); 247 DomStorageArea::DatabaseFileNameFromOrigin(origin));
233 file_util::Delete(database_file_path, kNotRecursive); 248 file_util::Delete(database_file_path, kNotRecursive);
234 file_util::Delete( 249 file_util::Delete(
235 DomStorageDatabase::GetJournalFilePath(database_file_path), 250 DomStorageDatabase::GetJournalFilePath(database_file_path),
236 kNotRecursive); 251 kNotRecursive);
237 } 252 }
238 } 253 }
239 254
240 } // namespace dom_storage 255 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698