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

Side by Side Diff: content/browser/in_process_webkit/dom_storage_context.cc

Issue 7619010: Session-only local storage cleared on exit. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Code review comments (tiny). Created 9 years, 4 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) 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
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 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
203
204 // Make sure that we don't delete a database that's currently being accessed
205 // by unloading all of the databases temporarily.
206 PurgeMemory();
207
208 file_util::FileEnumerator file_enumerator(
209 data_path_.Append(kLocalStorageDirectory), false,
210 file_util::FileEnumerator::FILES);
211 for (FilePath path = file_enumerator.Next(); !path.value().empty();
212 path = file_enumerator.Next()) {
213 GURL origin(WebSecurityOrigin::createFromDatabaseIdentifier(
214 webkit_glue::FilePathToWebString(path.BaseName())).toString());
215 if (!special_storage_policy_->IsStorageSessionOnly(origin))
216 continue;
217 if (special_storage_policy_->IsStorageProtected(origin))
218 continue;
219
220 file_util::Delete(path, false);
221 }
222 }
223
201 void DOMStorageContext::DeleteLocalStorageFile(const FilePath& file_path) { 224 void DOMStorageContext::DeleteLocalStorageFile(const FilePath& file_path) {
202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
203 226
204 // Make sure that we don't delete a database that's currently being accessed 227 // Make sure that we don't delete a database that's currently being accessed
205 // by unloading all of the databases temporarily. 228 // by unloading all of the databases temporarily.
206 // TODO(bulach): both this method and DeleteDataModifiedSince could purge 229 // TODO(bulach): both this method and DeleteDataModifiedSince could purge
207 // only the memory used by the specific file instead of all memory at once. 230 // only the memory used by the specific file instead of all memory at once.
208 // See http://crbug.com/32000 231 // See http://crbug.com/32000
209 PurgeMemory(); 232 PurgeMemory();
210 file_util::Delete(file_path, false); 233 file_util::Delete(file_path, false);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 293 }
271 294
272 FilePath DOMStorageContext::GetLocalStorageFilePath( 295 FilePath DOMStorageContext::GetLocalStorageFilePath(
273 const string16& origin_id) const { 296 const string16& origin_id) const {
274 FilePath storageDir = data_path_.Append( 297 FilePath storageDir = data_path_.Append(
275 DOMStorageContext::kLocalStorageDirectory); 298 DOMStorageContext::kLocalStorageDirectory);
276 FilePath::StringType id = 299 FilePath::StringType id =
277 webkit_glue::WebStringToFilePathString(origin_id); 300 webkit_glue::WebStringToFilePathString(origin_id);
278 return storageDir.Append(id.append(kLocalStorageExtension)); 301 return storageDir.Append(id.append(kLocalStorageExtension));
279 } 302 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/dom_storage_context.h ('k') | content/browser/in_process_webkit/dom_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698